Page 1 of 1

2 #Lab 10 Blood Drive. #the main function def main(): endProgram 'no' print while endProgram == 'no': option = 0 print p

Posted: Fri Jul 08, 2022 6:38 am
by answerhappygod
2 Lab 10 Blood Drive The Main Function Def Main Endprogram No Print While Endprogram No Option 0 Print P 1
2 Lab 10 Blood Drive The Main Function Def Main Endprogram No Print While Endprogram No Option 0 Print P 1 (155.97 KiB) Viewed 24 times
2 #Lab 10 Blood Drive. #the main function def main(): endProgram 'no' print while endProgram == 'no': option = 0 print print ('Enter 1 to enter in new data and store to file') print ('Enter 2 to display data from the file') option=input('Enter now ->') print # Declare variables 7 pints= [0] totalPints 0 averagePints=0 if option 1: #Function calls. pints= getPints(pints) totalPints= getTotal (pints, totalPints) averagePints= getAverage (totalPints, averagePints) writeToFile(averagePints, pints) else: readFromFile(averagePints, pints) end Program=input('Do you want to end the program? (Enter no or yes): ') while not (end Program == 'yes' or endProgram == 'no'): print('Please enter a yes or no'). end Program=input('Do you want to end program? (Enter no or yes): Library/Mobile Documents/com-apple-CloudD.. #the getPints function def getPints (pints): counter = 0 =__ while counter < 7: pints [counter] = int(input('Enter pints collected: ')) counter counter + 1 return pints #the getTotal function. def getTotal(pints, totalPints): counter 0 while counter < 7: totalPints= totalPints+ pints [counter] counter = counter + 1 return totalPints #the getAverage function def getAverage (totalPints, averagePints): Ln: 84 Col: 16 >>> >>> IDLE Shell 3.10.2 Python 3.10.2 (v3.10.2:a58ebcc701, Jan 13 2022, 14:50:16) [Clang 13.0.0 (clang-1300.0. 29.30)] on darwin Type "help", "copyright", "credits" or "license()" for more information. = RESTART: /Us S 305/ ..py Enter 1 to enter in new data and store to file Enter 2 to display data from the file Enter now >1 Traceback (most recent call last): File "/Users 05/... main() File "/Users/* 85/ e/Library/Mobile Documents/com-apple~CloudDocs/Education/C /Library/Mobile Documents/com-apple-CloudDocs/Education/CS 3 Lab10.py", line 92, in <> 05/" /Library/Mobile Documents/com-apple-CloudDocs/Education/CS 3 Lab10.py", line 32, in main readFromFile(averagePints, pints) File "/Users/ -/Library/Mobile Documents/com-apple-CloudDocs/Education/CS 3 Lab10.py", line 77, in readFromFile inFile= open('blood.txt', 'P FileNotFoundError: [Errno 2] No such file or directory: 'blood.txt' Ln: 16 Col: 0
brary/Mobile Documents/com-apple-CloudD.. hat ragi am one pa print('Please enter a yes or no'). vener regres end Program=input('Do you want to end program? (Enter no or yes): #the getPints function def getPints (pints): counter 0 while counter < 7: pints [counter] = int(input('Enter pints collected: ')) counter counter + 1 return pints #the getTotal function def getTotal(pints, totalPints): counter 0 while counter < 7: counter totalPints= totalPints+ pints [counter] counter counter + 1 return totalPints #the getAverage function. def getAverage (totalPints, averagePints): averagePints float(totalPints) / 7 return averagePints #the writeToFile function def writeToFile(average Pints, pints): outFile= open('blood. txt', 'a') print outFile, 'Pints Each Hour' counter 8 while counter < 7: outFile.write(str(pints [counter])+ '\n') counter counter + 1 outfile.write(str('Average Pints') + '\n') outFile.write(str(averagePints) + '\n\n') outfile.close() #the readFromFile function def readFromFile(averagePints, pints): inFile open('blood.txt', 'r') stri inFile.read() print (str1) pints inFile.read() print (pints) print str2= inFile.read() print (str2) averagePints inFile.read() print (averagePints) inFile.close() #calls main main() Ln: 84 Col: 16 >>> IDLE Shell 3.10.2 Python 3.10.2 (v3.10.2:a58ebcc701, Jan 13 2022, 14:50:16) [Clang 13.0.0 (clang-1300.0. 29.30)] on darwin Type "help", "copyright", "credits" or "license()" for more information. = RESTART: /User, S 305/ Lab10.py Enter 1 to enter in new data and store to file Enter 2 to display data from the file Enter now ->1 Traceback (most recent call last): File "/Users/ 85, main () File "/ilcars/. brary/Mobile Documents/com-apple~CloudDocs/Education/C 85/ ../Library/Mobile Documents/com-apple-CloudDocs/Education/CS 3 Lab10.py", line 92, in /Library/Mobile Documents/com-apple-CloudDocs/Education/CS 3 Lab10.py", line 32, in main readFromFile(averagePints, pints) e/Library/Mobile Documents/com-apple-CloudDocs/Education/CS 3 ap10.py", line 77, in readFromFile inFile= open('blood.txt', 2) FileNotFoundError: [Errno 2] No such file or directory: 'blood.txt' File "/Users, 05/ Ln: 16 Col: 0