Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Help update python Code below: Make user only have 5 tries to guess the Number print game over from tkinter import * import random class

Help update python Code below: Make user only have 5 tries to guess the Number print game over  from tkinter import * import random class App: def __init__(self, master): frame = Frame(master) frame.pack() self.button = Button(frame, text="QUIT", fg="red", command=frame.quit) self.button.pack(side=LEFT) self.number = Button(frame, text="Guess Your Number", fg="green", command=self.number) self.number.pack(side=LEFT) def number(self): print ("hi there, everyone!") secret_number=0 secret_number=random.randint(1,100) guess=0 tries=0 while guess != secret_number: g=input("guess my number: ") if g == "Q": self.button = Button(frame, text="QUIT", fg="red", command=frame.quit) self.button.pack(side=LEFT) tries=tries+1 guess=int(g) if guess > secret_number: print("high") if guess < secret_number: print("low") if guess == secret_number: print("you win!!! the secret number is: ", secret_number) print("you took ", tries, "tries") print("game over") root = Tk() app = App(root) root.mainloop() 

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

SQL Server Query Performance Tuning

Authors: Sajal Dam, Grant Fritchey

4th Edition

1430267429, 9781430267423

More Books

Students also viewed these Databases questions

Question

Where does the line y = 20x + 15 cross the line y = 2x2 4x + 1?

Answered: 1 week ago

Question

2. Discuss various aspects of the training design process.

Answered: 1 week ago