Question

Exercise 3 Dictionary Computers are playing an increasing role in education. Write a program that will help an elementary sch

Python Object oriented programming

0 0
Add a comment Improve this question Transcribed image text
Answer #1

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))

      

  
C:\UserS\LENOVO\Desktop python x.py How do you say guayaba in spanish ?nine No please try again How do you say guayaba in spa

Add a comment
Know the answer?
Add Answer to:
Python Object oriented programming Exercise 3 Dictionary Computers are playing an increasing role in education. Write...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT