2 #Lab 10 Blood Drive. #the main function def main(): endProgram 'no' print while endProgram == 'no': option = 0 print p
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am
2 #Lab 10 Blood Drive. #the main function def main(): endProgram 'no' print while endProgram == 'no': option = 0 print p
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