Answer to Question #197122 in Python for Angelie Suarez

Question #197122

create a program that has a dictionary:

studentgrade={

"john" :90,

"doe" :70,

"jane":83,

"marie":67,

"robert":59,

}

change the value into its equivalent:

91-100-oustanding

81-90-verygood

71-80-good

61-70-poor

51-60-failed


sample output:

{'john' : 'verygood', 'doe':'poor','jane':'verygood','marie':'poor',

'robert':'failed'}


1
Expert's answer
2021-05-23T08:04:59-0400
studentgrade={


"john" :90,


"doe" :70,


"jane":83,


"marie":67,


"robert":59,


}




for key, value in studentgrade.items():
    # do something with value
    if studentgrade[key]>=91 and studentgrade[key]<=100:
        studentgrade[key]="oustanding"
    elif studentgrade[key]>=81 and studentgrade[key]<=90:
        studentgrade[key]="verygood"
    elif studentgrade[key]>=71 and studentgrade[key]<=80:
        studentgrade[key]="good"
    elif studentgrade[key]>=61 and studentgrade[key]<=70:
        studentgrade[key]="poor"
    elif studentgrade[key]>=51 and studentgrade[key]<=60:
        studentgrade[key]="failed"  
print(studentgrade)

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