Computer Science, asked by SoumadeepGupta, 16 days ago

Write a program to input and store roll number, name and marks in 3 subjects out of 100(checking must be done while taking marks) in 3 subjects for n students. Based on the average marks for each student print the roll number, name, average marks, point secured on average marks of the students having highest average marks. The details of the point is given below. ​

Attachments:

Answers

Answered by Equestriadash
1

The following co‎des have been written using Python.

stud_dict = dict()

while True:

   rn = input("Enter the roll number/Hit enter to stop: ")

   if rn == "":

       break

   name = input("Enter the name: ")

   sub1 = float(input("Enter the marks of subject 1 [out of 100]: "))

   sub2 = float(input("Enter the marks of subject 2 [out of 100]: "))

   sub3 = float(input("Enter the marks of subject 3 [out of 100]: "))

   print()

   if sub1 > 0 and sub2 > 0 and sub3 > 0 and (sub1 + sub2 + sub3) <= 300:

       avgm = round((sub1 + sub2 + sub3)/3, 2)

       stud_dict[rn] = [name, avgm]

   else:

       print()

       print("Invalid marks.")

       print()

   continue

print("Roll Number\t\t", "Name\t\t", "Average Marks\t\t", "Points")

for i in stud_dict:

   if stud_dict[i][1] >= 85 and stud_dict[i][1] <= 100:

       print(i, "\t\t", stud_dict[i][0], "\t\t", stud_dict[i][1], "\t\t", 1)

   elif stud_dict[i][1] >= 75 and stud_dict[i][1] <= 84:

       print(i, "\t\t", stud_dict[i][0], "\t\t", stud_dict[i][1], "\t\t", 2)

   elif stud_dict[i][1] >= 60 and stud_dict[i][1] <= 74:

       print(i, "\t\t", stud_dict[i][0], "\t\t", stud_dict[i][1], "\t\t", 3)

   elif stud_dict[i][1] >= 40 and stud_dict[i][1] <= 59:

       print(i, "\t\t", stud_dict[i][0], "\t\t", stud_dict[i][1], "\t\t", 4)

   elif stud_dict[i][1] < 40:

       print(i, "\t\t", stud_dict[i][0], "\t\t", stud_dict[i][1], "\t\t", 5)

We use an iteration statement to repeatedly ask the user for inputs and use conditional statements to check for necessary conditions while storing the data into the dictionary earlier created for the same. Conditional statements are used again to determine the points scored by each student as per their average marks.

Similar questions