print("Enter 1:")
print( kg_to_lbs() ) # 2.21
print("Enter 6:")
print( kg_to_lbs() ) # 13.23
print("Enter 120:")
print( kg_to_lbs() ) # 264.6
print("Enter 1:")
print( liters_to_gallons() ) # 0.26
print("Enter 3:")
print( liters_to_gallons() ) # 0.79
print("Enter 6:")
print( liters_to_gallons() ) # 1.59
Module 3 Assignments
Short Project 02
Due date: Sep 17, Tuesday at 7pm
Short Programming projects are submitted during our weekly 45-minute in-person lab sessions. Each lab sessions is guided by two TAs. The instructions for the short project will be available only during the lab sessions. To schedule your lab session go to the weekly lab session spreadsheet.
Programming Problems
Programming Problems should be submitted to gradescope.
Programming Problem 5
Due date: Sep 17, Tuesday at 7pm
Write two python functions. The first function does the following:
- Its name is
kg_to_lbs
. - The function prompts the user to enter a value in
kilos
(use theinput()
function) – your function should take no arguments - It converts the
kilos
entered to pounds (by multiplyingkilos
by 2.205) - It returns the converted weight in pounds with two decimals of precision
The second function does the following:
- Its name is
liters_to_gallons
- The function prompts the user to enter a value in
liters
(use theinput()
function) – your function should take no arguments - It converts the
liters
entered to gallons (divide the quantity inliters
by 3.785) - It returns the converted volume in gallons with two decimals of precision
Name the program conversions.py
. Make sure that gradescope gives you the points for passing the test cases.
Development test cases:
You can also download the ready-to-run script to test your solution.
Programming Problem 6
Due date: Sep 17, Tuesday at 7pm
Write a python function that does the following:
- Its name is
is_even
- It takes an input
number
from the user - It returns
True
if thenumber
entered is even,False
ifnumber
is odd
Remember that the modulus operator (%
) returns the remainder of an integer division. Also, 0
is interpreted as False
and 1
as True
.
Name the program even.py
. Make sure that gradescope gives you the points for passing the test cases.
Development test cases:
print("Enter 0:")
print( is_even() ) # True
print("Enter 1:")
print( is_even()) # False
print("Enter 2:")
print( is_even()) # True
print("Enter -2:")
print( is_even()) # True
You can also download the ready-to-run script to test your solution.