Guess the Number
Beginner
Guess the Number
Let's create a cool function where you have to guess a secret number. Imagine a friend has chosen a secret number, and you need to find out if your guess is correct.
Here's the twist: You won't see the secret number! Your function needs to compare your guess to the secret number and tell if it's too low, too high, or just right!
How does it work?
You will write a function guess_the_number that takes two numbers as arguments:
secret_number: the number your friend has chosenguess: the number you think might be the secret number
The function should return:
'correct'if theguessis the same as thesecret_number'too low'if theguessis less than thesecret_number'too high'if theguessis more than thesecret_number
Examples
Let's see some examples of how this function should behave:
# Example 1 result = guess_the_number(10, 7) # Your guess is too low! # Output: 'too low' # Example 2 result = guess_the_number(10, 15) # Your guess is too high! # Output: 'too high' # Example 3 result = guess_the_number(10, 10) # You got it right! # Output: 'correct'
Are you ready to help your friend guess the secret number? Let's start coding!
Inputs
Arg 1:
10Arg 2:
7Expected Output
"too low"Actual Output