From 3fbf3eb87c5d5ae082a2ccbf2efa09a43e342f66 Mon Sep 17 00:00:00 2001 From: Edward Bigos Date: Tue, 28 Oct 2025 09:08:08 -0400 Subject: [PATCH] Lecture 10-28 code additions --- .../function1/rectangle-area06.py | 4 ++-- bigos/lecture20251028/list01/milesPerGallon04.py | 16 ++++++++-------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/bigos/lecture20251028/function1/rectangle-area06.py b/bigos/lecture20251028/function1/rectangle-area06.py index d9203b2..ec46838 100644 --- a/bigos/lecture20251028/function1/rectangle-area06.py +++ b/bigos/lecture20251028/function1/rectangle-area06.py @@ -1,8 +1,8 @@ #!/usr/bin/python3 import sys -# Program: reactangle-area06.py -# Objective: Calculate the area of a rectangle. Check for numeric error on length. +# Program: milesPerGallon04.py +# Objective: Calculate the milage at fill-up. # Revisions # Specify the type of the error as ValueError and print the error type. # Added same to width. diff --git a/bigos/lecture20251028/list01/milesPerGallon04.py b/bigos/lecture20251028/list01/milesPerGallon04.py index 8d61798..d92e60a 100644 --- a/bigos/lecture20251028/list01/milesPerGallon04.py +++ b/bigos/lecture20251028/list01/milesPerGallon04.py @@ -1,12 +1,14 @@ #!/usr/bin/python3 import sys -# Program: milesPerGallon01.py +# Program: milesPerGallon04.py # Objective: Calculate the milage for a vehicle using the fill-up data. # Revisions # Check for division by zero error # Edward Bigos +fillupList = [[200,10],[400,19], [190,9.8]] + def calculateMilesPerGallon(miles,gallons): try: milesPerGallon = miles / gallons @@ -25,11 +27,9 @@ def getFloatValue(message): sys.exit(-1) return fValue +for fillup in fillupList: + miles = fillup[0] + gallons = fillup[1] - -miles = getFloatValue("Enter a number of miles traveled") -gallons = getFloatValue("Enter the number of gallons on the last fill-up") - -milesPerGallon = calculateMilesPerGallon(miles,gallons) - -print(f"The miles per gallon is {milesPerGallon:.1f}") \ No newline at end of file + milesPerGallon = calculateMilesPerGallon(miles,gallons) + print(f"The miles per gallon is {milesPerGallon:.1f}") \ No newline at end of file