file=open("python_07_04.txt", 'w')
subject="Q"
score="1"
test_dict={subject:score}
while(subject!="Q"):
subject=input()
while(score!="0"):
score=input()
infile.write(subject+" : "+score)
infile.write("total = "+score)
infile.write("average = "+float(score/3))
infile.close()
outfile=open("python_07_04.txt",'r')
text=outfile.read()
print(text)
outfile.close()
I coded the picture above, but it doesn't proceed from one to ten Please advise me how to set up dictionary. Thank you.
python python3
infile=open("python_07_04.txt",'w')
test_dict={'Q':1}
while(test_dict['Q']==1):
subject=input()
score=input()
test_dict[subject]=score
test_dict.pop('Q',None)
total = 0
for a in test_dict:
infile.write(str(a+' : '+test_dict[a]+'\n'))
total+=float(test_dict[a])
infile.write(str("total = {}\n".format(total)))
infile.write(str('avg = {}\n'.format(total/(len(test_dict)))))
infile.close()
outfile=open("python_07_04.txt",'r')
text=outfile.read()
print(text)
outfile.close()
554 rails db:create error: Could not find mysql2-0.5.4 in any of the sources
769 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
554 Who developed the "avformat-59.dll" that comes with FFmpeg?
553 Uncaught (inpromise) Error on Electron: An object could not be cloned
© 2024 OneMinuteCode. All rights reserved.