Compare Two Numbers
Tags: Math Basics
Credit: CodingChallenge
Difficulty: Beginner
Type: Text
Category: Practice
Time Allowed: 5 s
Description:
Write a function that takes two numbers and returns a string indicating their comparison result. The function should accept two parameters and return:
-
"Greater"
if the first number is greater than the second. -
"Less"
if the first number is less than the second. -
"Equal"
if both numbers are equal.
This problem is designed to help you practice using comparison operators
such as >
, <
, and ==
.
Constraints:
- The inputs will be
integers
orfloats
. - The function should
return
astring
as specified.
Examples:
-
Input:
5, 3
-
Output:
"Greater"
-
Input:
2, 4
-
Output:
"Less"
-
Input:
7, 7
-
Output:
"Equal"
Test Case | Input | Expected Output |
---|---|---|
1 | [5, 3] | "Greater" |
2 | [2, 4] | "Less" |
3 | [7, 7] | "Equal" |
4 | [0, -1] | "Greater" |
5 | [-5, -5] | "Equal" |
6 | [-3, -2] | "Less" |
7 | [3.5, 3.5] | "Equal" |
8 | [2.7, 2.9] | "Less" |
9 | [10, 10.0] | "Equal" |
10 | [1e10, 1e9] | "Greater" |
Leave a Comment
Please login to leave a comment.