Answer to Question #326714 in Python for Teedow

Question #326714

Create a program using Python for Eduvos based on the above scenario. The program should initially display a welcome message. The program should then do the following: 3.1 Prompt the user to enter the number of students to be captured. 3.2 Handle exceptions to ensure that the user enters a number. 3.3 Prompt the user to enter the student’s name, exam 1 and exam 2 marks. 3.4 Calculate the test average. 3.5 Use tuples to handle records. 3.6 The records should then be written to a file called studentsexammarks.txt. 3.7 The program should display the recorded test marks on the screen.


1
Expert's answer
2022-04-10T12:36:48-0400
#3
print("*************************************")
print("*           Welcome user            *")
print("*************************************")
#3.1 and 3.2
number = '1'
while number.isdigit():
    number = input("Please enter the number of student : ")
    if number.isdigit():
        break
    else:
        print("You didn't enter a number")
        number = '1'
number = int(number)
tmp = ['q', 1, 2]
tmp_tuple = ()
student_tuple = () #main tuple 3.5
#3.3
for i in range(number):
    tmp[0] = input("Please enter name student: ")
    tmp[1] = int(input("Please enter the grade for 1 exam: "))
    tmp[2] = int(input("Please enter the grade for 2 exam: "))
    tmp_tuple = tuple(tmp)
    student_tuple = student_tuple + tmp_tuple
print(student_tuple)
#3.4
average_1 = 0
average_2 = 0
for i in range(1, number*3, 3):
    average_1 += student_tuple[i]
    average_2 += student_tuple[i+1]
average_1 = average_1 / number
average_2 = average_2 / number
print("\nAverage for 1 and 2 exam")
print("1 exam average = " + str(average_1))
print("2 exam average = " + str(average_2))
#3.6
f = open('studentexammarks.txt', 'w')
f.write(str(student_tuple))
f.write("\n1 exam average = " + str(average_1) + "\n 2 exam average = " + str(average_2))
f.close()

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS