Python Object oriented programming
Code:
import random
q=''
correct=["Excellent!","Very Good!","Nice work!","Keep up the good
work!"]
wrong=["No please try again","Wrong try once more","Don't give
up!","No. Keep trying"]
dataTable={'uno':'one','dos':'two','tres':'three','cuatro':'four','cinco':'five','seis':'six','siete':'seven','ocho':'eight','nueve':'nine','diez':'ten','azul':'blue','rojo':'red','verde':'green','amarillo':'yellow','negro':'black','manzana':'apple','naranja':'orange','uvas':'grapes','guayaba':'guava'}
while(q.casefold()!="exit"): """checks if student hasn't typed
exit, also casefold() ignores the case of spring""""
solution=False
q=''
key,value=random.choice(list(dataTable.items()))
""used random function to get key value pair"""
while(solution==False and q.casefold()!="give
up"):
q=input("How do you say "+key+" in
spanish ?")
if(q.casefold()==value.casefold()):
print
(random.choice(correct))
solution=True
elif(q.casefold()=="give
up"):
print("Correct
answer is "+value)
solution=True
elif(q.casefold()=="exit"):
solution=True
else:
print
(random.choice(wrong))
Python Object oriented programming Exercise 3 Dictionary Computers are playing an increasing role in education. Write...