An if statement in Python is a conditional statement, if proved true, performs a
function or
displays information
>>> n=5
>>> if n <=5:
...print("Hello World!")
...else:print("Python is easy!")
Hello World!
This if statment will print "Hello World!" if the condition of
n
is less than or equal to 5 is met. If this condiiton is not met it will print "Python is
easy!"
Let's try assigning n = 6, can you guess what the console will print?
>>> n=6
>>> if n <=5:
...print("Hello World!")
...else:print("Python is easy!")
Python is easy!
Video credits to Sentdex
The range() function helps us iterate through a range of numbers
>>> n = 3 >>> for i in range(n): ...print(i) 0 1 2
We just iterated through range of [0, n]
Now let's choose our start point to be 3 in range 6 [3, 6]
>>> n, m = 3, 6 >>> for i in range(n, m): ...print(i) 3 4 5
Video credits to Amuls Academy