#How to use the ASK block to make your project interactive # ACTIONS Toolkit - ASK Block # # sprite = codesters.Sprite("codesters",0,-25) fruit_choice = sprite.ask("What is your favorite fruit?") #The answer to the question is stored in the variable to the #left of the equal sign in the sprite.ask statement #Display the answer using the sprite.say block stage.wait(1) sprite.say(fruit_choice) stage.wait(2) sprite.say("My favorite too!") stage.wait(1) #Use the answer in an "if" statement to do a set of actions if fruit_choice == "apples": sprite.say("That is why I love fall!") stage.set_background("fall") else: stage.wait(1) sprite.say("Enjoy your fruit! Bye!")
  • Run Code
  • Show Console
  • Codesters How To (opens in a new tab)