02 Prove: Calling Functions

Purpose

Prove that you can write a Python program that calls functions and methods to get the current date and to append values to a text file.

Problem Statement

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.

Assignment

The previous lesson’s prove milestone required you to write a program named tire_volume.py that computes the approximate volume of air inside a tire. Add code near the end of that program that does the following:

  1. Gets the current date from the computer’s operating system.
  2. Opens a text file named volumes.txt for appending.
  3. Appends to the end of the volumes.txt file one line of text that contains the following five values:
    1. current date
    2. width of the tire
    3. aspect ratio of the tire
    4. diameter of the wheel
    5. volume of the tire

Helpful Documentation

Help from a Tutor

As a BYU-Idaho campus or online student you can get help from a tutor to complete your CSE 111 assignments. Each tutor is a current BYU-Idaho student employed by BYU-Idaho. Meeting with a tutor is free. It will not cost you any money to meet with a tutor. To get help from a tutor, you simply make an appointment and then meet with the tutor. Campus students meet with tutors in the tutoring center. Online students meet with tutors in Zoom. To make an appointment, follow the instructions in the course tutoring guide.

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 in the previous prove milestone and the Assignment section 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. Here are a few suggestions for additional features that you could add to your program if you wish.

Ponder

During this assignment, you wrote code that gets the current date from your computer’s operating system and that writes text to a file on your computer’s hard drive. The code that you wrote calls the datetime.now(), open(), and print() functions. Would this assignment have been more difficult if those three functions didn’t exist? Now that you know what functions are and how to call them in your code, are you able to write more complex programs?

Submission

To submit your program, return to I‑Learn and do these two things:

  1. Upload your program (the .py file) for feedback.
  2. Add a submission comment that specifies the grading category that best describes your program along with a one or two sentence justification for your choice. The grading criteria are:
    1. Some attempt made
    2. Developing but significantly deficient
    3. Slightly deficient
    4. Meets requirements
    5. Exceeds requirements