Python Program to Create Dictionary and Print Student Performance in Examination( Take User Input)

 Python Program to Create Dictionary and Print Student Performance in Examination( Take User Input)


result={}  # empty dictionary

name=input("Enter your name:")

n=int(input("How many key valu pair you want to store in your dictionary:"))

for i in range(n):

    key=input("Enter subject name:")

    value=int(input("Enter subject marks in Examination:"))

    result[key]=value

sum=0

for i in result.values():

    sum=sum+i

P=(sum/500)*100

print("\n-------------------------------------------------")

print(f"Following is {name}'s performance in Examination")

print("\n---------------------------------------------------")

print(f" {name}'s obtained marks in Examination is:",sum,end=" ")

print(f"\nThe percentage of {name} in Examination is:",P,end=" ")

if P>=90:

    print(f"{name} has  OUTSTANDING performance in Examination")

elif P>=80 and P<90:

    print(f"\n{name} has EXCELENT performance in Examination")

elif P>=70 and P<80:

    print(f"\n{name} has DISTINCTION  in Examination")

elif P>=60 and P<70:

    print(f"\n{name} has FIRST CLASS  in Examination")

elif P>=50 and P<60:

    print(f"\n{name} has SECOND CLASS in Examination")

elif P>=40 and P<50:

    print(f"\n{name} is just Pass in Examination")

else:

    print(f"\n{name} is FAIL in Examination")


Output:

Enter your name:Rehan

How many key valu pair you want to store in your dictionary:5

Enter subject name:C

Enter subject marks in Examination:98

Enter subject name:C++

Enter subject marks in Examination:78

Enter subject name:Python

Enter subject marks in Examination:90

Enter subject name:PHP

Enter subject marks in Examination:86

Enter subject name:DBMS

Enter subject marks in Examination:76


-------------------------------------------------

Following is Rehan's performance in Examination

---------------------------------------------------

 Rehan's obtained marks in Examination is: 428 

The percentage of Rehan in Examination is: 85.6 

Rehan has EXCELENT performance in Examination

टिप्पणी पोस्ट करा

0 टिप्पण्या