One of the condition statement used in the Python is if-else. If condition checks the set of code and executes only if the condition satisfies. If the condition is not satisfied, else condition is used
Number = int(input ( ” Enter the number ” ))
if number < 100 :
print(” The number is less than 100 “=)
else :
print(” The number is greater then 100″)
Looping statement
Looping statement is used when a set of code has to be repeated. It must have an range for the number of times the loop has to be executed. In Python there are many looping statements like while and for.We look on a example that to print values within the ramge as we the range as input
Range = int(input(” Enter the range “))
n = 1
While n <= Range :
print(n)
n += 1
Thus when we execute the program, the loop starts from 1 and continues to execute this block of code till the range.
Fibonacci series
Fibonacci series is the series of addition of first and second number and producing third number.
a , b = 0, 1
print(a)
while b < 10 :
print(b) # print(b, end=’ ‘ )
a , b = b , a + b
Output
0
1
1
2
3
5
8
Note – When we want to print the above output in a same line, end keyword is used.
0 1 1 2 3 5 8