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

help pls ill mark as brainliest if correct
please help i am timed
Which section from the article BEST explains why Chisholm's run for president was not successful
Please help, this is for 8th grade math.
what is the relationship between wealth and happiness
what is the value of 4.112-8​
Suggest two reasons why developing brownfield sites is often more sustainable than developing a greenfield site. (4 marks) (2 paragraphs for 2 different reasons
Beth goes on holiday to Spain. The exchange rate is £1 = €1.13 She changes £350 into Euros (€). (a) Work out how many Euros she receives. When Beth returns from
Help all just here for points comments will be reported
What are factors in an experiment that are not changed but are kept the same for both and normal group and the experiment group?