No products in the cart.

Write a program to store students …

CBSE, JEE, NEET, CUET

CBSE, JEE, NEET, CUET

Question Bank, Mock Tests, Exam Papers

NCERT Solutions, Sample Papers, Notes, Videos

Write a program to store students names and their percentage I. A dictionary and delete a particular students names from the dictionary also display the dictionary after deletion.
  • 1 answers

Preeti Dabral 2 years, 11 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"

http://mycbseguide.com/examin8/

Related Questions

What are called tokens
  • 2 answers

myCBSEguide App

myCBSEguide

Trusted by 1 Crore+ Students

Test Generator

Test Generator

Create papers online. It's FREE.

CUET Mock Tests

CUET Mock Tests

75,000+ questions to practice only on myCBSEguide app

Download myCBSEguide App