Question

In: Computer Science

Please make a Python program where the computer chooses a number and the player guesses the...

Please make a Python program where the computer chooses a number and the player guesses the number.

You need an input, a random number, if statement, and a while loop.

Please reference these when doing the code:

((random reference))

•>>> import random

•>>> random.randint(1, 100)

•67

((While & if referefence))

•>>> cnum = 3

•>>>while true

•>>> if cnum == 3:

•>>> print(‘correct’)

•>>> break

•>>> elif cnum == 2:

•>>> print(‘incorrect’)

Please post the Python code and the screen shot of your output.

Here is a sample output screen.

What is your guess? 97

Too high

What is your guess? 6

Too low

What is your guess? 82

Too high

What is your guess? 23

Too low

What is your guess? 64

Too high

What is your guess? 46

Too high

What is your guess? 35

Too low

What is your guess? 40

Too high

What is your guess? 37

Too low

What is your guess? 39

Too high

What is your guess? 38

Correct !

>>>

Solutions

Expert Solution

from random import randint

computer = randint(1,100)

guess = 0

while True:

num = int(input("Enter a number between 1 and 100: "))

if num > computer:

    print("Number too High")

elif num < computer:

    print("Number too Low")

else:

    print("Awesome Congratulations !!! you guessed the number in ", guess, "attempts")

    break;

guess = guess + 1

=====================================================

SEE OUTPUT/ CODE FOR INDENTATION

Thanks, PLEASE COMMENT if there is any concern.


Related Solutions

Please make a Python program where the computer chooses a number and the player guesses the...
Please make a Python program where the computer chooses a number and the player guesses the number. You need an input, a random number, if statement, and a while loop. Please reference these when doing the code: ((random reference)) •>>> import random •>>> random.randint(1, 100) •67 ((While & if referefence)) •>>> cnum = 3 •>>>while true •>>> if cnum == 3: •>>> print(‘correct’) •>>> break •>>> elif cnum == 2: •>>> print(‘incorrect’) Please prepare a Word document that has the...
Please add to this Python, Guess My Number Program. Add code to the program to make...
Please add to this Python, Guess My Number Program. Add code to the program to make it ask the user for his/her name and then greet that user by their name. Please add code comments throughout the rest of the program If possible or where you add in the code to make it ask the name and greet them before the program begins. import random def menu(): print("\n\n1. You guess the number\n2. You type a number and see if the...
using java For this assignment, you will write a program that guesses a number chosen by...
using java For this assignment, you will write a program that guesses a number chosen by your user. Your program will prompt the user to pick a number from 1 to 10. The program asks the user yes or no questions, and the guesses the user’s number. When the program starts up, it outputs a prompt asking the user to choose a number from 1 to 10. It then proceeds to ask a series of questions requiring a yes or...
Create a Guess the Number game. Python randomly chooses a secret four-digit number (with no repeating...
Create a Guess the Number game. Python randomly chooses a secret four-digit number (with no repeating digits) and asks the user to guess it. The user has up to ten attempts to guess the number. After each guess, Python gives the user two clues (until the user either guesses the number correctly or runs out of attempts): The number of digit(s) in the user’s guess that is (are) both correct and in the right position. The number of digit(s) in...
In Python please:  Number the Lines in a File: Create a program that adds line numbers to...
In Python please:  Number the Lines in a File: Create a program that adds line numbers to a file. The name of the input file will be read from the user, as will the name of the new file that your program will create. Each line in the output file should begin with the line number, followed by a colon and a space, followed by the line from the input file.
How to make a python program that imports only turtle and math library where I can...
How to make a python program that imports only turtle and math library where I can click once on the screen to set the center of the square, move the mouse to define the edge-length of the square; click a second time to draw the square with the defined edge-length and center point?
Phyton Please!! Make a program where you enter a dollar amount and the program tells you...
Phyton Please!! Make a program where you enter a dollar amount and the program tells you how many $5 bills and $1 bills you will receive. Don’t use a dollar amount that equality of 5. Example: Enter Amount: (user inserts value) Amount Entered: $50.00 5 dollar bills: 5 1 dollar bills: 25
This is done in C++. This is a game where one player thinks of a number...
This is done in C++. This is a game where one player thinks of a number between 1 and a 1000 and the other player has to guess in 10 tries or less. Allow two variations: the computer to pick the number and the player guesses or the player to pick the number and the computer to guesses. 1 – Player one picks a number 2 – Player two guesses the number. 3 – Player one either confirms that the...
IN PYTHON Develop a program in python that includes a number of functions for the multi-server...
IN PYTHON Develop a program in python that includes a number of functions for the multi-server queue. The program accepts arrival and services rates and the number of servers and calls your functions to output the average number of customers and average waiting time in the system.
(Python Code please) Guess the number! You will add to the program you created last week....
(Python Code please) Guess the number! You will add to the program you created last week. This week you will add quite a bit of code to your project. You will add an option for the computer to guess as well as the user to guess a number. In addition, you will add a menu system. Be sure to import random at the beginning of your code and use a comment block explaining what your program does #Guess the number...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT