In: Computer Science
PYTHON
Ask the user to enter the number of students in the class. Thereafter ask the user to enter the student names and scores as shown. Output the name and score of the student with the 2nd lowest score.
NOTE: You may assume all students have distinct scores between 0 and 100 inclusive and there are at least 2 students
NOTE: You may only use what has been taught in class so far for this assignment. You are not allowed to use more advanced topics like lists, functions, dictionaries etc for this assignment
name=""
score=0
minScore=200
minName=""
secondMinScore=200
secondMinName=""
n=0
n=int(input("Enter number of students: "))
for i in range(n):
name=input("Enter student name: ")
score=int(input("Enter score: "))
if(score<minScore):
secondMinScore=minScore
secondMinName=minName
minScore=score
minName=name
elif score<secondMinScore:
secondMinScore=score
secondMinName=name
print(secondMinName," has the second lowest score : ",secondMinScore)
Note : Please comment below if you have concerns. I am here to help you
If you like my answer please rate and help me it is very Imp for me