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:

  1. Its name is kg_to_lbs.
  2. The function prompts the user to enter a value in kilos (use the input() function) – your function should take no arguments
  3. It converts the kilos entered to pounds (by multiplying kilos by 2.205)
  4. It returns the converted weight in pounds with two decimals of precision

The second function does the following:

  1. Its name is liters_to_gallons
  2. The function prompts the user to enter a value in liters (use the input() function) – your function should take no arguments
  3. It converts the liters entered to gallons (divide the quantity in liters by 3.785)
  4. 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:

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 

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:

  1. Its name is is_even
  2. It takes an input number from the user
  3. It returns True if the number entered is even, False if number 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.