# Functions: try it
def enter_number():
while True:
str_input = input("Please enter a number")
try:
number = int(str_input)
return number
except:
print("Sorry, please try again")
value = enter_number()
print("Thank you, you entered the number", value)
# Challenges
# 1) Call enter_number again and save the return value into a variable called second_value
# 2) Change the function to return a float (real / decimal number) instead of an integer
# 3) Change the function so that it only returns if the user enters a value over 0
# Functions: try it
def enter_number():
while True:
str_input = input("Please enter a number")
try:
number = int(str_input)
return number
except:
print("Sorry, please try again")
value = enter_number()
print("Thank you, you entered the number", value)
# Challenges
# 1) Call enter_number again and save the return value into a variable called second_value
# 2) Change the function to return a float (real / decimal number) instead of an integer
# 3) Change the function so that it only returns if the user enters a value over 0
Write each prediction of what the program will output.
You can also predict variable values e.g. a = 10
This code has been sabotaged with some common mistakes. Can you find and fix them all?
Click on the button to add 5 more errors to the code
You get more points for each python skill you use from the keywords section
Click on "tests" to see a description of which python skills to aim for and keep track of which ones you've already used