Create a dictionary with the roll number, name and marks of n students in a
class and display the names of students who have marks above 75.
Answers
Answer:
here this your answer
Explanation:
make a brilliant
Answer:
A code snippet in Python that creates a dictionary with roll number, name, and marks of n students in a class, and displays the names of students who have marks above 75:
n = int(input("Enter the number of students: "))
student_dict = {}
for i in range(n):
roll_no = int(input("Enter roll number: "))
name = input("Enter name: ")
marks = float(input("Enter marks: "))
student_dict[roll_no] = [name, marks]
for roll_no, details in student_dict.items():
if details[1] > 75:
print("Name of student with marks above 75: ", details[0])
Explanation:
In this code, the user is asked to enter the number of students. Then, a dictionary named student_dict is created, and the user is asked to enter the roll number, name, and marks of each student. These values are stored in the dictionary as key-value pairs, where the roll number is the key, and the name and marks are stored as a list, which is the value. Finally, the loop iterates over the student_dict and checks if the marks of each student are greater than 75. If the condition is True, the name of the student is displayed.
More questions and answers
https://brainly.in/question/32833717?referrer=searchResults
https://brainly.in/question/24225327?referrer=searchResults
#SPJ3