In: Computer Science
Write a simple Python program that will generate two random between 1 and 6 ( 1 and 6 are included).
If the sum of the number is grader or equal to 10 programs will display “ YOU WON!!!”. if the sum is less than 10, it will display “YOU LOST”.
After this massage program will ask users a question: “if you want to play again enter Y. if you want to exit enter ‘N’)
If the user enters Y they will continue to play and if they enter N the program terminates.
Program:
Text format:
import random fg = 'Y' while fg == 'Y' or fg =='y': a = random.randint(1, 6) b = random.randint(1, 6) print('a = %d and b = %d' %(a, b)) print("YOU WON!!!") if a+b >= 10 else print("YOU LOST!!!") fg = input('if you want to play again enter Y. if you want to exit enter N: ')
Output
Solving your question and
helping you to well understand it is my focus. So if you face any
difficulties regarding this please let me know through the
comments. I will try my best to assist you. However if you are
satisfied with the answer please don't forget to give your
feedback. Your feedback is very precious to us, so don't give
negative feedback without showing proper reason.
Always avoid copying from existing answers to avoid
plagiarism.
Thank you.