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
What are some ways to find out what skills you need to develop at work? Check all of the boxes that apply.
Anarel [89]

Answer:

Attend traings

Explanation:

Because if you do you can learn diffent waay to do it and choose your way that you like.

ANd do not obseve poeple who has it easy  

7 0
3 years ago
Read 2 more answers
Which option correctly identifies if the researcher’s approach was the best choice in the following scenario and explains why?
Tasya [4]

Answer:

A

Explanation:

go do it

4 0
3 years ago
Read 2 more answers
T F The exit function can only be called from main .
ElenaW [278]

Answer:

FALSE

Explanation:

The exit function is used to terminate or halt the process.

Syntax-

            void exit(int status)  

Exit function (exit()) can be used in any function not only main() and it will terminate your whole process.

<u></u>

<u>Example-</u> C Program

#include<stdio.h>

#include <stdlib.h>  

//  function declaration

float exitexample ( float x );                                

// Driver program

int main( )                

{

 float a, b ;

 printf ( "\nEnter some number for finding square \n");

  scanf ( "%f", &a ) ;

 // function call

 b = exitexample ( a ) ;                      

 printf ( "\nSquare of the given number %f is %f",a,b );  

/*This will not printed as exit function is in exitexample() function*/

}

float exitexample ( float x )   // function definition  

{

 exit(0);    //exit function

   float p ;

  p = x * x ;

return ( p ) ;

}

5 0
4 years ago
A network that is located in a small area, such as a single building is called a
love history [14]
Networks in small areas are called Local Area Network (LAN). LAN's are in small areas like offices and buildings. Computers close to each other can make up a LAN network with the right equipments. A LAN network is good for doing business.
4 0
4 years ago
"In a web app, where is data usually stored? A. Mobile network B. Application storage C. Local computer D. Cloud storage"
ollegr [7]

Answer:

The answer is "Option C".

Explanation:

The local computer also refers to locally, it is a device, that is used by LAN. It is also called as a remote computer, in which all the data is stored in the main computer and accessible by protected password, and certain choices were wrong, which can be described as follows:

  • In option A, It is used in digital communication.
  • In option B, It is used in androids.
  • In option D, It is used to provides web services.
6 0
3 years ago
Other questions:
  • how do you make a circuit so 1 switch will turn on/off all the lights(3 lights) and a second switch will change the lights from
    14·2 answers
  • A 2-dimensional 3x3 array of ints, has been created and assigned to tictactoe. Write an expression whose value is true if the el
    10·1 answer
  • Give 5 uses of software and hardware.
    15·1 answer
  • You type a web address in your web browser. order the steps, which describe the internet name resolution process for the web add
    7·1 answer
  • To print a mailing label, click the Labels button on the MAILINGS tab in the ____ group. A. Building Block B. AutoText C. Templa
    10·2 answers
  • What is the encryption cipher that was the precursor to des??
    5·1 answer
  • Compared to a virtual image, a real image
    15·2 answers
  • A company has a website that has seen a large increase in visitors and they are concerned that if the trend continues, the web s
    13·1 answer
  • Please help I’m not trying to fail
    7·2 answers
  • Dynamics
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!