Need Guessing game (number) with graphics (simple one) / python language
Python Program:
from random import randint
from tkinter import *
import tkinter.messagebox
class GuessingGame:
def __init__(self):
self.number = randint(1,10)
self.window = Tk()
Label(self.window, text='Guess a
number between 1 and 10').pack()
self.guess = Entry(self.window,
width=10)
self.guess.pack()
b = Button(self.window,
text='Guess', command = self.message)
b.pack()
# set up the event handling for
when the user clicks the button
self.window.mainloop()
# this is the event handler
def message(self):
# Fetching value entered in text
box
try:
# Getting
number
guessNumber =
int(self.guess.get());
# Comparing
number
if guessNumber
== self.number:
# If both are matched
tkinter.messagebox.showinfo("Guessing Game", "
Congrats!!! Correct Guess ");
else:
# If not matched
tkinter.messagebox.showinfo("Guessing Game", "
Sorry!!! It is an incorrect Guess ");
# If user enters any value other
than integer
except:
# Displaying
message box
tkinter.messagebox.showinfo("Guessing Game", " Error!!! Please
enter only integers ");
# Calling function
game = GuessingGame();
____________________________________________________________________________________________
Sample Run:
Need Guessing game (number) with graphics (simple one) / python language
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...
1. Use Turtle Graphics to create a tic tac toe game in Python. Write a Python program that allows for one player vs computer to play tic tac toe game, without using turtle.turtle
python code for guessing game users enter the number the computer will guess 8:38 PM 100 nstructure.com 1. Number guessing game : (5 points) 1) Requirements: Your program will ask the user to enter a number between 1 and 1000. Then it will try to guess the correct number with the guaranteed minimal average number of guesses. Which search algorithm should you use? 2) Expected Output: Enter a number between 1 and 1000? 784 Computer guesses: 500 Type 'l' if...
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...
on python i need to code a guessing game. After the player has guessed the random number correctly, prompt the user to enter their name. Record the names in a list along with how many tries it took them to reach the unknown number. Record the score for each name in another list. When the game is quit, show who won with the least amount of tries. this is what i have so far: #Guess The Number HW assignment import...
Write a guessing game where the user has to guess a secret number. After every guess the program tells the user whether their number was too large or too small. At the end the number of tries needed should be printed. It counts only as one try if they input the same number multiple times consecutively. Using PYTHON.
Task 4 (20 points) Implement a simple guessing game. Name your file task4.c. Your game will use rand() to generate a random number from 1 to 10 then prompt user to guess that number. User will have unlimited number of tries to guess the correct number. Your program should work like this hb117@uxb4:$ gco -Wall task4 . c -o task4 hb117@uxb4:~$ ./guessing Guess a number from 1-10: 1 Guess again: 4 Guess again: 2 Guess again: 9 Guess again: 10...
In a number guessing game. You ask a person to guess a number from one 1 to 10. If the person makes a random guess, what is the probability their guess will be less than 99? A bag contains 10 red marbles, 8 white marbles, 5 green marbles. If one marble is drawn from the bag but not replaced, what is the probability of drawing a red marble then a green marble?
Please use python language to solve this problem. 3. Use turtle graphics to draw a spiral as below. It does not have to look exactly like the one below, but it should be a path that spirals around a point many times. Upload a file called spiral py. When we run it using the python command it should draw the picture without any further modification. Hint: use a for or while loop Figure 3: spiral
Swift program: Develop an app that is a Number Guessing Game, (ex: one that allows a player to guess a number between a high and a low number, say between 1 and 10) with the system guiding the player by indicating whether the number is too high or too low after an incorrect guess. This process is repeated until the player correctly guesses the number or simply quit your app. For simplicity purposes, assume the magic number to be guessed...