Answer to Question #242610 in Python for Ajay D'Cruze

Question #242610
Q1. Suppose there is two different types of dictionary, one dictionary contains registration
number and name of student and another dictionary contains registration number and marks.
Take 5 student details. Now display the student's result in terms of grade from the following
condition:
If marks between 90 to 100:grade'O'
marks between 80 to 90:grade'A+'
marks between 70 to 80:grade'A'
marks between 60 to 70:grade'B+'
marks between 50 to 60:grade'B'
Display result in the form of dictionary.
1
Expert's answer
2021-09-27T01:16:41-0400
def getGrade(mark):
    #If marks between 90 to 100:grade'O'
    if mark>=90 and mark<=100:
        return "O"
    #marks between 80 to 90:grade'A+'
    if mark>=80 and mark<90:
        return "A+"
    #marks between 70 to 80:grade'A'
    if mark>=70 and mark<80:
        return "A"
    #marks between 60 to 70:grade'B+'
    if mark>=60 and mark<70:
        return "B+"
    #marks between 50 to 60:grade'B'
    return "B"


studentNames={}
studentMarks={}


N = int(input("Enter number of students: "))


for i in range(N):
    print("Enter Details of student No.", i+1)
    registrationNumber = int(input("Enter the registration number of the student: "))
    name = input("Enter the name of the student: ")
    mark = int(input("Enter the mark of the student: "))
    studentNames[registrationNumber] = name
    grade=getGrade(mark)
    studentMarks[registrationNumber] = [mark,grade]


print(studentNames)
print(studentMarks)

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS