Question

PYTHON import random # VARIABLES first_num = random.randint(1, 100) sec_num = random.randint(1, 100) totalsum = first_num...

PYTHON 

import random

# VARIABLES
first_num = random.randint(1, 100)
sec_num = random.randint(1, 100)
totalsum = first_num + sec_num

def additon(first_num, sec_num):
    return first_num + sec_num;

# INTRO
print("Hello, \n"
      "this is an app that helps you practice your math skills while generating 6 sets of lucky  numbers")

question = input('Are you up for a challenge? [Y/N]')
if question == 'n':
    print('okay, see you later')

if question == 'y':
    print("Let's start!!")

# USER NAME VALUE
uname = input('what is your user name? ')
print('Welcome', uname + ', lets start with some simple addition')

print('Try adding', first_num, '+', sec_num)

user_total = int(input('what is the total of this sum? '))

if user_total == additon(first_num,sec_num):
    print("Congratulations! your answer is correct!, two more to go!")




********* HOW CAN I GET A NEW MATH QUESTION TO BE POPULATED AFTER THE USER GOT THE FIRST ANWER RIGHT? AND HOW CAN I COUNT THE NUMBER OF TRIES WHEN THE USER GET THE ASWERS WRONG? *******

elif user_total != (first_num + sec_num):
    print("The answer is wrong, the correct total is: ", totalsum)

# HOW TO GET THE question TO REPEAT
#restart = input("do  you wish to start again? [Y/N]")
#if restart == "yes":
#    addition(first_num, sec_num)

#else:
#    exit()


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

Python Program:

import random

def additon(first_num, sec_num):
   return first_num + sec_num;

# INTRO
print("Hello, \n this is an app that helps you practice your math skills while generating 6 sets of lucky numbers")

question = input('Are you up for a challenge? [Y/N]')
if question == 'n':
   print('okay, see you later')
  
elif question == 'y':
   print("Let's start!!")
  
   # USER NAME VALUE
   uname = input('what is your user name? ')
   print('Welcome', uname + ', lets start with some simple addition')

   loop = 'y'  
   while loop.lower() == 'y':
       # Generating 6 sets
       for i in range(6):
           # VARIABLES
           first_num = random.randint(1, 100)
           sec_num = random.randint(1, 100)
           # Generating quiz
           print('\nSet #', (i+1), ' Try adding: ', first_num,    '+', sec_num)
           user_total = int(input('what is the total of this sum? '))

           # For counting user tries
           cnt = 0
          
           # Loop till user guess correctly
           while user_total != additon(first_num,sec_num):
               user_total = int(input('Wrong Answer!!! what is the total of this sum? '))  
               cnt = cnt + 1
              
           # Printing message
           print("Congratulations! your answer is correct!, You answered in ", cnt, " number of tries!!!")

       # Prompting for repeat
       loop = input("\n\nDo you wish to start again? [Y/N]")
      
   print("\nThank You!!!\n")  

___________________________________________________________________________________________________

Code Screenshot:

_____________________________________________________________________________________________________

Sample Run:

Add a comment
Know the answer?
Add Answer to:
PYTHON import random # VARIABLES first_num = random.randint(1, 100) sec_num = random.randint(1, 100) totalsum = first_num...
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
  • Can you please enter this python program code into an IPO Chart? import random def menu():...

    Can you please enter this python program code into an IPO Chart? import random def menu(): print("\n\n1. You guess the number\n2. You type a number and see if the computer can guess it\n3. Exit") while True: #using try-except for the choice will handle the non-numbers #if user enters letters, then except will show the message, Numbers only! try: c=int(input("Enter your choice: ")) if(c>=1 and c<=3): return c else: print("Enter number between 1 and 3 inclusive.") except: #print exception print("Numbers Only!")...

  • Hello, I am trying to solve the following problem using python: Assignment 3: Chatbot A chatbot...

    Hello, I am trying to solve the following problem using python: Assignment 3: Chatbot A chatbot is a computer program designed to emulate human conversation. For this program you will use if statements, user input, and random numbers to create a basic chatbot. Here is the scenario: You have decided to start an online website. You are creating a prototype to show investors so you can raise money and launch your website. You should ask the user at least 5...

  • on python i need to code a guessing game. After the player has guessed the random...

    on python i need to code a guessing game. After the player has guessed the random number correctly, prompt the user to enter their name. Record the names in a list along with how many tries it took them to reach the unknown number. Record the score for each name in another list. When the game is quit, show who won with the least amount of tries. this is what i have so far: #Guess The Number HW assignment import...

  • import random def doTest(operation): ## complete your work here ##    # return True for now...

    import random def doTest(operation): ## complete your work here ##    # return True for now return True    responsesCorrect = 0 print("The software will process a test with 10 questions …… ") for compteur in range (10): operation = random.randint(0,1) if doTest(operation) == True: responsesCorrect += 1 print(responsesCorrect, "Correct responses")    if responsesCorrect <= 6 : print("Ask some help from your instructor.") else: print("Congratulations!") Requirement: You must use the format provided below and then complete the fill! Python! Thanks!...

  • I need the create a Python code that makes a two-player Rock-Paper-Scissors game. (Hint: Ask for...

    I need the create a Python code that makes a two-player Rock-Paper-Scissors game. (Hint: Ask for player plays (using input), compare them, print out a message of congratulations to the winner, and ask if the players want to start a new game) Please help me see why my "continue" is asking the players to start a new game. Here is my code; user1= input("Whats your name? ") user2= input("And your name? ") a = input("%s, do yo want to choose...

  • Can figure out how get my program to keep track of a total score, here is...

    Can figure out how get my program to keep track of a total score, here is my code so far in python 3.6.6 import math import random import turtle def target(): """Turtle drawing the target"""    t = turtle.Turtle() wn = turtle.Screen() wn.bgcolor("black") t.hideturtle() t.speed(0)    #most outside circle worth 10 points t.setposition(0,-275) t.color("grey") t.begin_fill() t.circle(275) t.end_fill()    #2nd most outter circle worth 20 points t.penup() t.setposition(0,-200) t.pendown() t.color("red") t.begin_fill() t.circle(200) t.end_fill()    #3rd most outter circle worth 30 points...

  • Python Language: Please see program listed below of a game called: Rock, Paper, Scissors. Please add...

    Python Language: Please see program listed below of a game called: Rock, Paper, Scissors. Please add an exception, for example if the user inputs something else other than rock, paper or scissors, the exception will print message: "Enter only rock, paper, or scissors". Also add option to keep playing the game, for example: print: "Would you like to play again? Enter Y or N". If the user says Y, the game will repeat, if N, the game will end and...

  • Can you add code comments where required throughout this Python Program, Guess My Number Program, and...

    Can you add code comments where required throughout this Python Program, Guess My Number Program, and describe this program as if you were presenting it to the class. What it does and everything step by step. import random def menu(): #function for getting the user input on what he wants to do print("\n\n1. You guess the number\n2. You type a number and see if the computer can guess it\n3. Exit") while True: #using try-except for the choice will handle the...

  • use python code complete this question 'Assignment 3 o Get information until getting 'n' from user...

    use python code complete this question 'Assignment 3 o Get information until getting 'n' from user Input the name of 1th student : 84 Input the math score of 1th student : 90 Input the english score of 1th student : 80 Input the science score of lth student : 100 Keep moving? (y/n): y Input the name of 2th student : 981 Input the math score of 2th student : 70 Input the english score of 2th student :...

  • VERY URGENT*** THANK YOU IN ADVANCE: THIS IS THE CODE I HAVE GOTTEN SO FAR: PYTHON...

    VERY URGENT*** THANK YOU IN ADVANCE: THIS IS THE CODE I HAVE GOTTEN SO FAR: PYTHON This is a code that is supposed to help someone study/ practice for jeopardy. The two functions described below are required for this assignment. You may add other functions that you think are appropriate: menu() This function, which displays all the user options to the screen, prompt the user for their choice and returns their choice. This function will verify user input and ALWAYS...

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