1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
cupoosta [38]
3 years ago
8

Python Question: write a program that generates a random number in the range of 1 through 100, and asks the user to guess what t

he number is. If the user’s guess is higher that the random number the program should display "too high try again." If the user’s guess is lower than the random number, the program should display "too low,try again" If the user guesses the number the application should congratulate the user and then generate a new random number so the game can start over.
This is what I have so far..

#generates and imports a random number between 1-100
import random
number=random.randint(1,100)

#sets main function
def main():
print("This is a number guessing game.")
print("Guess what number we thought of between 1 and 100")
#print statement

num = number()
#stores number of user guesses
user = 0
#stores number of guesses
guesses = 0
#while statement
while user != num:

user=int(input("Enter your best guess!"))

guesses=guesses +1

if (user > num):
print ("Too high, try again")
else:
print("Congrats, you won!")
print("Restarting game")


main()
Computers and Technology
1 answer:
natima [27]3 years ago
6 0

Answer:

import random

arr=[]

for i in range(100):

   arr.append(i)

while True:

   answer=random.choice(arr)

   guess=int(input("enter your guess number between 0-100: "))

   if answer is guess:

       print("right guess\ncongratulations.....")

       print("the answer was: "+str(answer))

       break

   elif guess < answer-20:

       print("you guessed too low....\ntry again")

       print("the answer was: "+str(answer))

   elif guess > answer+20:

       print("you guessed too high....\ntry again")

       print("the answer was: "+str(answer))

   else:

       print("incorrect guess\ntry again")

       print("the answer was: "+str(answer))

Explanation:

You might be interested in
Explaing why the findings are different between a general purpose search engine ( google) and a meta search engine ( ask jeeves)
Softa [21]
A lot of people use google and on all search engines the sites are ordered in what people click on the most. Popularest website that fits in with the key words and different people used different websites and different search engines
6 0
3 years ago
Why is it important to be a good digital citizen? 2-3 sentences
weqwewe [10]

Answer:

It's nice to be a good digital citizen because you'll stay out of trouble. It will help make someone's day without any negativity. It helps ensure that there is no cyberbullying occuring.

6 0
3 years ago
Read 2 more answers
Select the correct answer.
Umnica [9.8K]

Answer:

OB. by zooming in on them

hope it helps

7 0
3 years ago
Which three are characteristics of flow
miskamm [114]

Answer:

concentration on the task

clarity of goals

reward in mind

immediate feedback

Explanation:

3 0
3 years ago
The first electric, general-purpose computer, ENIAC, was programmed by calculating algorithms on paper entering code directly in
JulsSmile [24]

Complete Question:

The first electric, general-purpose computer, ENIAC, was programmed by?

Group of answer choices.

A. Calculating algorithms on paper.

B. Entering code directly into the computer.

C. Flipping switches by hand.

D. Using MS-DOS as the operating system.

Answer:

C. Flipping switches by hand.

Explanation:

The first electric, general-purpose computer, ENIAC, was programmed by flipping switches by hand.

ENIAC is an acronym for Electronic Numerical Integrator and Computer, it was developed in 1945 by John Mauchly and J. Presber Eckert. ENIAC was used for solving numerical problems or calculation-related tasks by the process of reprogramming.

In order to give the ENIAC a series of machine instructions to follow in the execution of a task, the programmers had to undergo the cumbersome procedure of connecting, removing, reconnecting cables and flipping switches by hand because data couldn't be stored in memory.

4 0
4 years ago
Other questions:
  • After earning a learners license what test must be successfully passed to earn an operators license in Florida
    14·1 answer
  • Software that people commonly use in the workplace to make their lives easier is called
    15·1 answer
  • Add three methods to the Student class that compare twoStudent objects. One method should test for equality. A second method sho
    13·1 answer
  • What is the target audience for this poster?
    5·2 answers
  • 1.<br> The correct way to use a seat belt is
    8·1 answer
  • 20. A computer freezes at odd times. At first, you suspected the power supply or overheating, but you have eliminated overheatin
    6·1 answer
  • You are utilizing BitLocker Drive Encryption, and are attempting to update Windows Server 2016. What must be done so that the up
    14·1 answer
  • Which control program flow options runs to the end of the code block and resumes the break mode at the statement that follows?
    12·1 answer
  • What is a Web server application?
    7·1 answer
  • Which file types have exe and png as their extensions?
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!