I am struggle at this is where I stopped and figure it out how to do math random because I am new to Python over a month now. UPDATED: After the expected output works well with product so I am trying to add new random int for z with 1-3 which means I am using with 1 is for product, 2 is for sum and 3 is difference by using if-statement by given random select. My Currently Work: (I am working to add sum and difference like the expected output Print("You got %d correct out of %d" % (correct, amount)) Print("What is " + str(x) + " x " +str(y)) UserInput = int(input("Enter a number: ")) My Work for Product Only ( Success): import random I have the expected result when I first run with product but it works so I just need to add with sum and difference included.ĮXPECTED OUTPUT with product ( Some are incorrect for testing with scores): > python3 rand3.py I tried to use z = random.randint(1, 4) is to select from 1 is product, 2 is sum, or 3 is difference and then I used with if variable z is 1, then do product math or if var z is 3, then it should be difference like this x / y, but I couldn't figure it finish it up. I tried using with three product, sum or difference in random to generate. Separate the question asking into a function, as well as the validating user input. At the end of these 10 questions the program will display how many the user got correct out of those questions.Įach question should randomly decide between asking for the product, sum, or difference. These two numbers will be generated randomly between 1 and 10 and it will ask the user 10 times. This program will ask the user a series of questions about two numbers.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |