Julie has created a dictionary containing names and marks as key value pairs of 6 students. Write a program, with separate user defined functions to perform the following operations:
● Push the keys (name of the student) of the dictionary into a stack, where the corresponding value (marks) is greater than 75.
● Pop and display the content of the stack. For example: If the sample content of the dictionary is as follows: R={"OM":76, "JAI":45, "BOB":89, "ALI":65, "ANU":90, "TOM":82}
The output from the program should be: TOM ANU BOB OM
Answers
Answered by
10
ANSWER :
This is your required answer check :
Attachments:
Answered by
5
The required programme is as follows:
Explanation:
R={"OM":76, "JAI":45, "BOB":89,
"ALI":65, "ANU":90, "TOM":82}
def PUSH(S,N):
S.append(N) def POP(S):
if S!=[ ]:
return S.pop()
else:
return None
ST=[ ]
for k in R:
if R[k]>=75:
PUSH(ST,k)
while True:
if ST!=[ ]:
print(POP(ST),end=" ")
else:
break
Similar questions