CSE 111: Programming with Functions

W01 Project: Tire Volume

Purpose

Prove that you can write a Python program that gets input from a user, performs math, displays and logs the results to a file.

Project

Background

This week you will write a small program to ensure your system is setup correctly and provide a bit of a review of principles learned in CSE110.

User Requirements

Write a program that will accept user input that describes a tire then calculate and display the tire's volume. Record the tire information in a log file.

  1. Have the user enter a tire width in mm.
  2. Have the user enter the aspect ratio.
  3. Have the user enter the diameter of the wheel in inches.
  4. Calculate and display the tire's volume.
  5. Log the information in a text file.
    1. current date (Do NOT include time)
    2. width of the tire
    3. aspect ratio of the tire
    4. diameter of the wheel
    5. volume of the tire (rounded to two decimal places)

Design

Tire description and calculation

The size of a car tire in the United States is represented with three numbers like this: 205/60R15. The first number is the width of the tire in millimeters. The second number is the aspect ratio. The third number is the diameter in inches of the wheel that the tire fits. The volume of space inside a tire can be approximated with this formula:

v =
π w2awa + 2,540 d
10,000,000,000
Helpful information.

Milestone

Write a Python program named tire_volume.py that reads from the keyboard the three numbers for a tire and computes and outputs the volume of space inside that tire.

  1. Create a folder for this week's project, name it whatever you want.
  2. Open the folder you just created in VSCode.
  3. Create a file named tire_volume.py.

    Name files as instructed! For all assignments in CSE 111, please write your program in a file named as the assignment states. Also, if an assignment requires your program to read from a file or write to a file, please use the filename stated in the assignment. If you name your program or a data file differently than stated in an assignment, it will be harder for the graders to score your submitted assignment.
  4. Write the program to ask the user for the 3 items in the requirements and output the tire volume.

Testing Procedure

Verify that your program works correctly by following each step in this testing procedure:

  1. Run your program and enter the inputs shown below. Ensure that your program’s output matches the output below.
    > python tire_volume.py
    Enter the width of the tire in mm (ex 205): 185
    Enter the aspect ratio of the tire (ex 60): 50
    Enter the diameter of the wheel in inches (ex 15): 14
    The approximate volume is 24.09 liters
    > python tire_volume.py
    Enter the width of the tire in mm (ex 205): 205
    Enter the aspect ratio of the tire (ex 60): 60
    Enter the diameter of the wheel in inches (ex 15): 15
    The approximate volume is 39.92 liters

Milestone Submission

On or before the due date, return to Canvas and report your progress on this milestone.

Project Completion

Many companies wish to understand the needs and wants of their customers more deeply so the company can create products that fill those needs and wants. One way to understand customers more deeply is to record the values entered by customers while they are using a program and then to analyze those values. One common way to record values is for a program to store them in a file.

Complete your program by adding the following features:

  1. Get the current date from the computer’s operating system.
  2. Open a text file named volumes.txt for appending.
  3. Append to the end of the volumes.txt file one line of text that contains the following five values:
    1. current date (Do NOT include time)
    2. width of the tire
    3. aspect ratio of the tire
    4. diameter of the wheel
    5. volume of the tire (rounded to two decimal places)
Helpful information

Testing Procedure

Verify that your program works correctly by following each step in this testing procedure:

  1. Run your program using the inputs shown below. Ensure that your program’s output matches the output shown below.
    > python tire_volume.py
    Enter the width of the tire in mm (ex 205): 185
    Enter the aspect ratio of the tire (ex 60): 50
    Enter the diameter of the wheel in inches (ex 15): 14
    The approximate volume is 24.09 liters
  2. Use VS Code to open the volumes.txt file and verify that the last line of text in the file looks like this, except the date will be different:
    2020-03-18, 185, 50, 14, 24.09
  3. Run your program using the inputs shown below. Ensure that your program’s output matches the output shown below.
    > python tire_volume.py
    Enter the width of the tire in mm (ex 205): 205
    Enter the aspect ratio of the tire (ex 60): 60
    Enter the diameter of the wheel in inches (ex 15): 15
    The approximate volume is 39.92 liters
  4. Use VS Code to open the volumes.txt file and verify that the last two lines of text in the file look like this, except the dates will be different:
    2020-03-18, 185, 50, 14, 24.09
    2020-04-16, 205, 60, 15, 39.92
Exceeding the Requirements

If your program fulfills the requirements for this assignment as described above, your program will earn 93% of the possible points. In order to earn the remaining 7% of points, you will need to add one or more features to your program so that it exceeds the requirements. Use your creativity to add features. Add a comment to the top of your code that explains your enhancement(s). Here are a few ideas.

Document your enhancements:

If you choose to "exceed requirements" place a comment at the top of your code file that describes what you did to enhance your program.

Project Submission

Return to Canvas and upload your tire_volume.py file for feedback.

Don't get a zero!

If an error prevents your program from running to completion the grader will score your assignment with a 0 and request that you fix and resubmit your program. In other words, rather than submitting a program that doesn't work, it's best to ask for help to understand how to fix the problem before submitting your program.

Useful Links:

  1. Return to: Week Overview | Course Home