
you’re going to make a “Guess the Number” game. The computer will think of a random number from 1 to 1000, and ask you to guess it. The computer will tell you if each guess is too high or too low.
1. # This is a guess the number game.
2. import random
3.
4. guessesTaken = 0
5.
6. print('Hello! What is your name?')
7. myName = input()
8.
9. number = random.randint(1, 1000)
10. print('Well, ' + myName + ', I am thinking of a number between 1 and 1000.')
11.
12. while guessesTaken < 6:
13. print('Take a guess.') # There are four spaces in front of print.
14. guess = input()
15. guess = int(guess)
16.
17. guessesTaken = guessesTaken + 1
18.
19. if guess < number:
20. print('Your guess is too low.') # There are eight spaces in front of print.
21.
22. if guess > number:
23. print('Your guess is too high.')
24.
25. if guess == number:
26. break
27.
28. if guess == number:
29. guessesTaken = str(guessesTaken)
30. print('Good job, ' + myName + '! You guessed my number in ' + guessesTaken + ' guesses!')
31.
32. if guess != number:
33. number = str(number)
34. print('Nope. The number I was thinking of was ' + number)
python code for guessing game users enter the number the computer will guess 8:38 PM 100...
Write a Java program that implements the number guessing game where the computer tries to guess a number in your head. You pick a number between 0 and 100, and the computer generates a guess. You then type 1 if your number is larger than the computer’s guess, -1 if your number is smaller, and 0 if the number is correct. The computer should keep trying to guess the number by adjusting the guess based on your feedback (so if...
Number Guessing Game Games Write program in C++. For this game, the computer will select a random number between 1 and 100 (inclusive). The computer will then ask the (human) player to guess the number the computer has selected. After the player’s guess is input to the computer, the computer will output one of three responses, depending on the relationship of the number the player guessed to the number the computer selected: “Your guess was too low.” “Your guess was...
Lab #6 Number Guessing Game – Loops and Nested Loops Requirements: Design, develop, test, and submit a program for a Number Guessing game. The program will select a random number between 0 and 100, allow the user to try up to 10 times to guess the number, and tell the user if each guess is too high, too low, or correct. The actual game portion must be a function...you can use more than one function in your program. The amount...
A Backwards Guessing Game For this assignment, you will be a making a guessing game with a twist. You will play the role of the computer, and the computer will try to guess the number. You will think of a number (you don’t have to read it in as input) between 1 and 100. You will create a loop that runs 5 times. In this loop, the computer will try to guess the number in the range it knows is...
C++ Guessing game. Create a project titled Lab4_Guess with a single file titled guess.cpp Program the following game. The computer selects a random number between 1 and 100 and asks the user to guess the number. If the user guesses incorrectly, the computer advises to try larger or smaller number. The guessing repeats until the user guesses the number. The dialog should look as follows (user input is shown in bold): Guess a number between 1 and 100: 50 try...
Python Program
Python: Number Guessing Game Write a Python function called "Guess.py" to create a number guessing game: 1. Function has one input for the number to Guess and one output of the number of attempts needed to guess the value (assume input number will always be between 1 and 1000). 2. If no number was given when the function was called, use random.randint(a,b) to generate a random number between a=1 and b=1000. You will also need to add an...
Can you add code comments where required throughout this Python Program, Guess My Number Program, and describe this program as if you were presenting it to the class. What it does and everything step by step. import random def menu(): #function for getting the user input on what he wants to do print("\n\n1. You guess the number\n2. You type a number and see if the computer can guess it\n3. Exit") while True: #using try-except for the choice will handle the...
Can someone upload a picture of the code in
matlab
Write a "Guess My Number Game" program. The program generates a random integer in a specified range, and the user (the player) has to guess the number. The program allows the use to play as many times as he/she would like; at the conclusion of each game, the program asks whether the player wants to play again The basic algorithm is: 1. The program starts by printing instructions on the...
Java Guessing Game Class The class will generate a random number of 1 to 15, and then check to see if the user guessed the number correctly. If the number is incorrect, the user should have the chance to guess again, until they guess the right number or they guess 10 times. The class method should keep track of the number of guesses the user has had, and return this value. The class should have one constructors, a default and...
Java 1) In a game of guessing numbers, one person says, “I’m thinking of a number between 1 and 100.” The other person guesses “50.” The first person replies, “No, the number is less.” The second person then guesses “25,” and so on, until she guesses correctly. Write a program that plays this game. The computer knows the number (a random number between 1 and 100) and the user is the guesser. At the end of the game, the computer...