Question

In: Computer Science

(Python code please) Of a Guessing game(1-10) with a limited amount of guesses (5)

(Python code please) Of a Guessing game(1-10) with a limited amount of guesses (5)

Solutions

Expert Solution

Program Code Screenshot:

Sample output:

The screenshots are attached below for reference.

Please follow them for proper indentation and output.

Program to copy:

import random
c=0
f=0
while c<5:#loop 5 times
c+=1
n=int(input("Enter your guess(1-10)"))#read input from user to guess
r=random.randint(1,10)#check a random number
if n==r:#check if numbers are same
print("Congratulations! You took ",c," attempts to guess")
f=1
break
else:
print("Try again!")
continue
if f==0:
print("Sorry! you did not guess!")

Note:

Please let me know in case of any help needed in the comments section.

Plese upvote my answer. Thank you.


Related Solutions

Part1. Create a number guessing game in Python. Randomly generate a number from 1 to 10....
Part1. Create a number guessing game in Python. Randomly generate a number from 1 to 10. Have the user guess the number. If it is too high, tell the user to guess lower - it it is too low, tell the user to guess higher. Continue until she guesses the correct number. - Part 2. Allow the user to play a new game after they have guessed correctly.   Part 3. Ask for a different name and keep track of how...
Python: You will modify the given code to create a guessing game that takes user input...
Python: You will modify the given code to create a guessing game that takes user input and allows you to make multiple guesses. There should also be a loop Use the following attached Sample Code as a guide. There are mistakes in the code!!! #Guessing Game import random number=random.randint(1, another number) print("Hello, CIS 101") print("Let's play a guessing Game!called guess my number.") print("The rules are: ") print("I think of a number and you'll have to guess it.") guess = random.randint(1,...
In JAVA Create a simple guessing game, similar to Hangman, in which the user guesses letters...
In JAVA Create a simple guessing game, similar to Hangman, in which the user guesses letters and then attempts to guess a partially hidden phrase. Display a phrase in which some of the letters are replaced by asterisks: for example, G* T*** (for Go Team). Each time the user guesses a letter, either place the letter in the correct spot (or spots) in the phrase and display it again or tell the user the guessed letter is not in the...
Write a program using Python that allows the user to play a guessing game (please provide...
Write a program using Python that allows the user to play a guessing game (please provide a picture of code so it is easier to read). The game will choose a "secret number", a positive integer less than 10000. The user has 10 tries to guess the number. Requirements: Normally, we would have the program select a random number as the "secret number". However, for the purpose of testing your program (as well as grading it), simply use an assignment...
You are asking to develop a “Triangle Guessing” game in Python for the assignment. The program...
You are asking to develop a “Triangle Guessing” game in Python for the assignment. The program accepts the lengths of three (3) sides of a triangle as input from a player. The program output should indicate whether the triangle is a right triangle, an acute triangle, or an obtuse triangle. 1.Tips to help you for this assignment: Make sure each side of the triangle is a positive integer. Use try/except for none positive integer input. 2. Validating the triangle. That...
“Triangle Guessing” game in Python The program accepts the lengths of three (3) sides of a...
“Triangle Guessing” game in Python The program accepts the lengths of three (3) sides of a triangle as input . The program output should indicate if the triangle is a right triangle, an acute triangle, or an obtuse triangle. Make sure each side of the triangle is a positive integer. Use try/except for none positive integer input. validating the triangle. That is the sum of the lengths of any two sides of a triangle is greater than the length of...
Please generate code in PYTHON: In the game of Lucky Sevens, the player rolls a pair...
Please generate code in PYTHON: In the game of Lucky Sevens, the player rolls a pair of dice. If the dots add up to 7, the player wins $4; otherwise, the player loses $1. Suppose that, to entice the gullible, a casino tells players that there are lots of ways to win: (1, 6), (2, 5), and so on. A little mathematical analysis reveals that there are not enough ways to win to make the game worthwhile; however, because many...
Project 5-3: Guessing Game Create an application that lets a user guess a number between 1...
Project 5-3: Guessing Game Create an application that lets a user guess a number between 1 and 100. Console Welcome to the Guess the Number Game ++++++++++++++++++++++++++++++++++++ I'm thinking of a number from 1 to 100. Try to guess it. Enter number: 50 You got it in 1 tries. Great work! You are a mathematical wizard. Try again? (y/n): y I'm thinking of a number from 1 to 100. Try to guess it. Enter number: 50 Way too high! Guess...
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...
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...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT