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
Most email clients contain a ____ that allows the user to read an email message without actually opening it
Stolb23 [73]
Most email clients contain a "subject" that allows the user to read an email message without actually opening it.
4 0
4 years ago
Read 2 more answers
When pasting an existing chart into a Word document, you can choose to _______ using the Paste Options button.
SCORPION-xisa [38]
When pasting an existing chart into a Word document, you can choose to control how text appears when you paste it using the Paste Options button.  <span>The </span>Paste Options<span> button enables you to decide whether you want to paste the data as you originally copied it, or to change the style so that it fits the style of the document into which you are pasting the data, or to apply specific characteristics to the data, based on the content.</span>
8 0
3 years ago
Read 2 more answers
Sandie is writing a report for her environmental science class. She has asked her older sister who is away at college to proof h
vichka [17]
Help each other because if the other sister is older she should have more experience and knowledge

8 0
3 years ago
Read 2 more answers
Your organization has an Active Directory domain. One of the users, Bill, should not have read access to a folder named Accounti
Alborosie

Answer: D. Deny read access to the Accounting folder for Bill through shared access security.

Explanation:

The statement that describes how to stop Bill from having read access to the folder without impacting any other users on the network is to deny read access to the Accounting folder for Bill through shared access security.

It should be noted that the local access security cannot be used in this case because the folder is shared from a network server that is within the active directory domain.

5 0
3 years ago
What is a non-example of job outlook.
Papessa [141]

Answer:

Before you choose a career you should find out what its job outlook is. ... employed in a particular occupation over a set period, for example, two years, five years or ... 2% and 4%); Have little or no change (a decrease or increase of 1% or less) .

Explanation:

4 0
3 years ago
Other questions:
  • A server would experience a __________ attack when a hacker compromises it to acquire information from it from a remote location
    13·1 answer
  • Python provides a special version of a decision structure known as the ________ statement, which makes the logic of the nested d
    13·1 answer
  • Blank spaces or unseen control characters in a data file are referred to as
    5·2 answers
  • which statement draws an accurate comparison between social media marketing and conventional marketing?
    13·1 answer
  • A port is the point at which a peripheral device attaches to or communicates with a computer or mobile device. True False
    15·1 answer
  • 460N of force is exerted on an object with a surface area of 2,5m.How much pressure is felt by the object?​
    11·2 answers
  • Match the characteristics to the mobile operating system that it describes.
    6·1 answer
  • Who play fortnite gameeeeeeee
    14·1 answer
  • Please help. will give u brainliest!! khan academy computers and the internet!!
    12·1 answer
  • If person A creates an image with a creative common license. Person B then uses the image on his website. Who own the image and
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!