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!...

  • 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...

  • 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 :...

  • Propose: In this lab, you will complete a Python program with one partner. This lab will...

    Propose: In this lab, you will complete a Python program with one partner. This lab will help you with the practice modularizing a Python program. Instructions (Ask for guidance if necessary): To speed up the process, follow these steps. Download the ###_###lastnamelab4.py onto your desktop (use your class codes for ### and your last name) Launch Pyscripter and open the .py file from within Pyscripter. The code is already included in a form without any functions. Look it over carefully....

  • This problem demonstrates the use of import module. The Python programming language has many strengths, but...

    This problem demonstrates the use of import module. The Python programming language has many strengths, but one of its best is the availability to use many existing modules for various tasks, and you do not need to be an experienced computer programmer to start using these modules. We have given you some incomplete code; note that the very first line of that code contains an import statement as follows: import math This statement enables your program to use a math...

  • Your friend is writing a Python program to randomly provide the user with an inspiring quote....

    Your friend is writing a Python program to randomly provide the user with an inspiring quote. Unfortunately, your friend is a terrible programmer, and you promised to help them with their program. Basically, there is a list of inspirational sayings in the code, and the program enters a loop and gives the user a random quote. The program is then supposed to ask the user if they want another quote. If they answer anything other than ‘y’ the program ends....

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
Active Questions
ADVERTISEMENT