Respuesta :
def score():
print('enter the name and marks of 5 students to be compared')
s1=(input('enter the name of student1:'))
ss1=int(input('enter the score of student1:'))
s2=(input('enter the name of student2: '))
ss2=int(input('enter the score of student2:'))
s3=(input('enter the name of student3: '))
ss3=int(input('enter the score of student3:'))
s4=(input('enter the name of student4: '))
ss4=int(input('enter the score of student4:'))
s5=(input('enter the name of student5: '))
ss5=int(input('enter the score of student5:'))
if ss1>ss2 and ss1>ss3 and ss1>ss4 and ss1>ss5:
if ss2>ss3 and ss2>ss4 and ss2>ss5:
print('the first two highest marks are ',s1,':',ss1,'&',s2,':',ss2)
elif ss3>ss2 and ss3>ss4 and ss3>ss5:
print('the first two highest marks are ',s1,':',ss1,'&',s3,':',ss3)
elif ss4>ss2 and ss4>ss3 and ss4>ss5:
print('the first two highest marks are ',s1,':',ss1,'&',s4,':',ss4)
else:
print('the first two highest marks are ',s1,':',ss1,'&',s5,':',ss5)
elif ss2>ss1 and ss2>ss3 and ss2>ss4 and ss2>ss5:
if ss1>ss3 and ss1>ss4 and ss1>ss5:
print('the first two highest marks are ',s2,':',ss2,'&',s1,':',ss1)
elif ss3>ss1 and ss3>ss4 and ss3>ss5:
print('the first two highest marks are ',s2,':',ss2,'&',s3,':',ss3)
elif ss4>ss1 and ss4>ss3 and ss4>ss5:
print('the first two highest marks are ',s2,':',ss2,'&',s4,':',ss4)
else:
print('the first two highest marks are ',s2,':',ss2,'&',s5,':',ss5)
elif ss3>ss1 and ss3>ss2 and ss3>ss4 and ss3>ss5:
if ss1>ss3 and ss1>ss4 and ss1>ss5:
print('the first two highest marks are ',s3,':',ss3,'&',s1,':',ss1)
elif ss2>ss2 and ss2>ss4 and ss2>ss5:
print('the first two highest marks are ',s3,':',ss3,'&',s2,':',ss2)
elif ss4>ss2 and ss4>ss1 and ss4>ss5:
print('the first two highest marks are ',s3,':',ss3,'&',s4,':',ss4)
else:
print('the first two highest marks are ',s3,':',ss3,'&',s5,':',ss5)
elif ss4>ss1 and ss4>ss2 and ss4>ss3 and ss4>ss5:
if ss2>ss3 and ss2>ss1 and ss2>ss5:
print('the first two highest marks are ',s4,':',ss4,'&',s2,':',ss2)
elif ss3>ss2 and ss3>ss1 and ss3>ss5:
print('the first two highest marks are ',s4,':',ss4,'&',s3,':',ss3)
elif ss1>ss2 and ss1>ss3 and ss1>ss5:
print('the first two highest marks are ',s4,':',ss4,'&',s1,':',ss1)
else:
print('the first two highest marks are ',s4,':',ss4,'&',s5,':',ss5)
elif ss5>ss1 and ss5>ss2 and ss5>ss3 and ss5>ss4:
if ss2>ss3 and ss2>ss4 and ss2>ss1:
print('the first two highest marks are ',s5,':',ss5,'&',s2,':',ss2)
elif ss3>ss2 and ss3>ss4 and ss3>ss1:
print('the first two highest marks are ',s5,':',ss5,'&',s3,':',ss3)
elif ss4>ss2 and ss4>ss3 and ss4>ss1:
print('the first two highest marks are ',s5,':',ss5,'&',s4,':',ss4)
else:
print('the first two highest marks are ',s5,':',ss5,'&',s1,':',ss1)
else:
print('the values are wrong')
Explanation:
The above program is a user defined program named source ().The structure of the program is based on if, elif, and else statements. While we run the above program, it shows the five different students name with their respective score as a user input. Using the if, elif, else statements, it compares the scores of each student and give the result of top two students.