num1 = float(input("Enter the first number: "))
num2 = float(input("Enter the second number: "))
if not (num1 >= num2):
print("The first number is NOT greater than or equal to the second number.")
else:
print("The first number is greater than or equal to the second number.")
#source code --> clcoding.com
Code Explanation:
Taking User Input
num1 = float(input("Enter the first number: "))
num2 = float(input("Enter the second number: "))
The user enters two numbers, stored in num1 and num2.
float() is used to handle decimal numbers as well as integers.
Checking the Condition
if not (num1 >= num2):
Step 1: Condition inside not
The expression num1 >= num2 checks if num1 is greater than or equal to num2.
If num1 is greater than or equal to num2, it returns True.
If num1 is less than num2, it returns False.
Step 2: Using not
not (num1 >= num2) reverses the result.
If num1 is less than num2, the condition becomes True, meaning num1 is NOT greater than or equal to num2.
Printing the Result
print("The first number is NOT greater than or equal to the second number.")
If the condition is True, it prints that num1 is NOT greater than or equal to num2.
else:
print("The first number is greater than or equal to the second number.")
Otherwise, it prints that num1 is greater than or equal to num2.
0 Comments:
Post a Comment