yaxyesaalim456 yaxyesaalim456
  • 08-05-2020
  • Computers and Technology
contestada

4. Write a program which selects two integer numbers randomly, adds the numbers and asks the user to enter the answer and then checks if the answer is correct or not.

Respuesta :

frknkrtrn
frknkrtrn frknkrtrn
  • 16-05-2020

Answer:

import random

number1 = random.randrange(0, 1000)

number2 = random.randrange(0, 1000)

answer = int(input("Enter a number: "))

if answer == number1 + number2:

   print("Your answer is correct")

else:

   print("Your answer is not correct")

Explanation:

The code is in Python

Create two integer numbers using random

Ask the user for an input

Check if answer is equal to number1 + number2. If they are equal, print "answer is correct". Otherwise, print "answer is not correct".

Answer Link

Otras preguntas

marissa wants to purchase song for hee ipod songs on itunes cost $1.25 each marisa found anothee webside called mp3 golore that offers each song for $1 if a $3
Who received government jobs under the spoils system?
At the turn of the 20th century women began joining men in fields such as doctors, lawyers and engineers.
10. One drawback of a personal marketing survey is that A. the response time if rather long. B. respondents may misinterpret questions. C. it r
Please answer quick in need of an answer
How many moles of ar are in 1.27x10^24 ar atoms?
What is the slope of this line ???
why did hostilities erupt in the Philippines after the Spanish American war
What is a good way to prepare for the likely request, “Tell me about yourself”?
150 words describing Bohr’s model, and the fundamental principles behind it. Also, explain how Bohr’s model is different from Rutherford’s model.