If statements and comparison operators

PHOTO EMBED

Tue Apr 21 2020 06:41:13 GMT+0000 (Coordinated Universal Time)

Saved by @Sarah #python #python #ifstatement #elifstatement #elsestatement #comparisonoperators

x = int(input("Please enter an integer: "))
Please enter an integer: 42 #getting input from user
>>> if x < 0: #1st condition
...    x = 0
...    print('Negative changed to zero')
... elif x == 0: #2nd condition
...    print('Zero')
... elif x == 1: #3rd condition
...    print('Single')
... else: #4th condition
...    print('More')                               
                                
content_copyCOPY

If statements are the conditions if this then do this and comparison operators are basicallly used to compare like greater than, less than, equals to etc. We can use both statements and comparison operators together in python.

https://docs.python.org/3/tutorial/controlflow.html