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:

  1. secret_number: the number your friend has chosen
  2. guess: the number you think might be the secret number

The function should return:

  • 'correct' if the guess is the same as the secret_number
  • 'too low' if the guess is less than the secret_number
  • 'too high' if the guess is more than the secret_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!

Geek
Inputs

Arg 1:

10

Arg 2:

7
Expected Output
"too low"
Actual Output
Guess the Number [beginner] | Coding for Kids