Write a program to store students …
CBSE, JEE, NEET, CUET
Question Bank, Mock Tests, Exam Papers
NCERT Solutions, Sample Papers, Notes, Videos
Related Questions
Posted by Kandeepan Jothivel 6 months, 3 weeks ago
- 2 answers
Posted by Prawar Narang 6 months, 2 weeks ago
- 1 answers
Posted by Manoj Kumar Manoj Kumar 7 months, 1 week ago
- 0 answers
Posted by Hanni Pham 4 months, 1 week ago
- 1 answers
Posted by Priya Shukla 5 months, 2 weeks ago
- 1 answers
Posted by Hanni Pham 4 months, 1 week ago
- 0 answers
Posted by Syedali Fathima 5 months, 3 weeks ago
- 1 answers
myCBSEguide
Trusted by 1 Crore+ Students
Test Generator
Create papers online. It's FREE.
CUET Mock Tests
75,000+ questions to practice only on myCBSEguide app
Preeti Dabral 3 years, 4 months ago
Actually you need to create a nested dictionary with name as values and another dict as keys, in pretty way the nested dict may look like:
{
'anmol': {'chemistrymarks': 3, 'physicsmarks': 2, 'mathmarks': 1},
'uppal': {'chemistrymarks': 6, 'physicsmarks': 5, 'mathmarks': 4}
}
So you need to add the following lines to create a nested dictionary.
num_students = int(raw_input("Please enter number of students:"))
print "you entered %s students" %num_students
student_info = {}
student_data = ['Math marks : ', 'Physics marks : ', 'Chemistry marks : ']
for i in range(0,num_students):
student_name = raw_input("Name :")
student_info[student_name] = {}
for entry in student_data:
student_info[student_name][entry] = int(raw_input(entry)) #storing the marks entered as integers to perform arithmetic operations later on.
#print student_info
print"Please enter student name ?"
name = raw_input("Student name : ")
if name in student_info.keys():
print "Average student marks : ", str(sum(student_info[name].values())/3.0)
else:
print"please enter valid name"
0Thank You