Module 2 Assignments

Short Project 01

Due date: Sep 10, 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 3

Due date: Sep 10, Tuesday at 7pm

Write two python functions. The first function does the following:

  1. Its name is celsius_to_fahrenheit.
  2. It takes a float argument, celsius.
  3. It calculates the Fahrenheit temperature based on the given celsius temperature. To do so multiply the Celsius temperature by 1.8 (or 9/5) and add 32.
  4. It returns the Fahrenheit temperature with two decimals of precision.

The other function convert temperatures in degrees from Fahrenheit to Celsius.

  1. Its name is fahrenheit_to_celsius.
  2. It takes a float argument, fahrenheit.
  3. It calculates the Celsius temperature based on the given Fahrenheit temperature. To do so subtract 32 from the Fahrenheit temperature and multiply the result by 5/9.
  4. It returns the Celsius temperature with two decimals of precision.

Name the program temperatures.py. Make sure that gradescope gives you the points for passing the test cases.

Development test cases:

print( celsius_to_fahrenheit(15) ) # 59.0
print( celsius_to_fahrenheit(25) ) # 77.0
print( celsius_to_fahrenheit(38) ) # 100.4
print( fahrenheit_to_celsius(100) ) # 37.78
print( fahrenheit_to_celsius(115) ) # 46.11
print( fahrenheit_to_celsius(75) ) # 23.89

You can also download the ready-to-run script to test your solution.

Programming Problem 4

Due date: Sep 10, Tuesday at 7pm

Write two python functions. The first function does the following:

  1. Its name is feet_to_inches.
  2. It takes a float argument, feet.
  3. It converts the feet measurement to inches. As you might already know, an inch is 1/12th of a foot.
  4. It returns the measure in inches as a rounded integer.

The second function does the following:

  1. Its name is feet_to_meters.
  2. It takes a float argument, feet.
  3. It converts the feet measurement to meter (divide the feet measurement by 3.281)
  4. It returns the measure in meters as an rounded to two decimal places.

Name the program measures.py. Make sure that gradescope gives you the points for passing the test cases.

Development test cases:

print( feet_to_inches(1) ) # 12
print( feet_to_inches(2.5) ) # 30
print( feet_to_inches(5.4) ) # 65
print( feet_to_meters(1) ) # 0.3
print( feet_to_meters(5) ) # 1.52
print( feet_to_meters(20) ) # 6.1

You can also download the script to test your solution.