Repository navigation
Expand file tree
/
Copy path100-Comparison-Operators.py
More file actions
86 lines (72 loc) · 3 KB
/
Copy path100-Comparison-Operators.py
File metadata and controls
86 lines (72 loc) · 3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
"""
===============================================================================
File Name : 100-Comparison-Operators.py
Description : Comparison Operators in Python
Author : Shaik Mahaboob Basha
===============================================================================
Definition:
Comparison operators are used to compare two values. They always return
either True or False.
Comparison Operators:
1. == (Equal To)
2. != (Not Equal To)
3. > (Greater Than)
4. < (Less Than)
5. >= (Greater Than or Equal To)
6. <= (Less Than or Equal To)
Syntax:
operand1 operator operand2
Example:
10 > 5
"""
# -----------------------------------------------------------------------------
# Assigning values to two variables.
# -----------------------------------------------------------------------------
number1 = 20
number2 = 10
# -----------------------------------------------------------------------------
# Displaying the input values.
# -----------------------------------------------------------------------------
print("First Number :", number1)
# Output:
# First Number : 20
print("Second Number :", number2)
# Output:
# Second Number : 10
print()
# -----------------------------------------------------------------------------
# Checking whether both values are equal.
# -----------------------------------------------------------------------------
print("Equal To (==) :", number1 == number2)
# Output:
# Equal To (==) : False
# -----------------------------------------------------------------------------
# Checking whether both values are not equal.
# -----------------------------------------------------------------------------
print("Not Equal To (!=) :", number1 != number2)
# Output:
# Not Equal To (!=) : True
# -----------------------------------------------------------------------------
# Checking whether the first value is greater than the second value.
# -----------------------------------------------------------------------------
print("Greater Than (>) :", number1 > number2)
# Output:
# Greater Than (>) : True
# -----------------------------------------------------------------------------
# Checking whether the first value is less than the second value.
# -----------------------------------------------------------------------------
print("Less Than (<) :", number1 < number2)
# Output:
# Less Than (<) : False
# -----------------------------------------------------------------------------
# Checking whether the first value is greater than or equal to the second value.
# -----------------------------------------------------------------------------
print("Greater Than or Equal To (>=) :", number1 >= number2)
# Output:
# Greater Than or Equal To (>=) : True
# -----------------------------------------------------------------------------
# Checking whether the first value is less than or equal to the second value.
# -----------------------------------------------------------------------------
print("Less Than or Equal To (<=) :", number1 <= number2)
# Output:
# Less Than or Equal To (<=) : False