PyZombis numpy_pandas@19da491
Social
Runestone in social media:
Follow @iRunestone
Our Facebook Page
Help support us:
Search
Table of Contents
Book Index
User
Assignments
Practice
Change Course
Instructor's Page
Progress Page
Edit Profile
Change Password
Register
Login
Dark Mode
Scratch Activecode
Help
FAQ
Instructors Guide
About Runestone
Report A Problem
5.
Repetitions
¶
from browser import document as doc from browser import html from browser import timer print("Welcome!") number = 0 doc <= html.DIV(id="div_game") # Create the button to play doc["div_game"] <= html.BUTTON("Play", id="btn_play") # Define what the button will do when pressed def guess(): global number number = int(input("Guess the number: ")) if number == 42: print("You won!") else: if number > 42: print("High") else: print("Low") if number != 42: # If the number was not guessed, repeat the function after # 3 seconds timer.set_timeout(guess, 3000) def start(ev): guess() # When the button is pressed, it will call the start function, # which in turn will call guess doc["btn_play"].bind("click", start)
5.1.
Users Still Dislike It
¶
You have attempted
of
activities on this page