/* */ Click to Join Live Class with Shankar sir Call 9798158723

# Python if Statement

if statement is a simple decision-making statement. It is used to decide whether a certain statement or block of statements will be executed or not i.e if a certain condition is true then a block of statement is executed otherwise not. In this statement only if is present not else

##### Syntex of python if statement

ifcondition:

statement 1
statement 2
statement..n

The block of statement ( after : colon ) is executed if condition is TRUE

Note: The colon (:) is important because it separates the condition from the statements to be executed after the evaluation of the condition. This is specially important for statements where there is only a single statement and the bracket ( ) is not used.

Print Grater of Two number using only if statement
``` \$a=8
\$b=7
\$big=\$a
if \$b>\$big:
\$big=\$b
print(“largest number=”,big)
```
##### Output
largest number = 8

##### Program Explanation

Step 1:-
We declared three variables called a , b and big.
Step 2:-
A Message will give for entering their own values for a and b:- Enter Two No
Step 3:-
User Enter two integer No Let`s We Enter :- 6 3
Step 4:-
hear we will have to print largest elements using only if condition not else. so we take an extra variable i.e big and we assume a is the biggest element and assign a value to big. next If condition checks whether big is greater than b or not. If this condition is True, then b variable value assigns to a big variable. if the condition is not true then it will print big value i.e a is greater than b.
hear we used the Conditional Operator(i.e > greater than) to check whether big is greater than b or not. If this condition is True, then it will be executed if part, which is variable an (b value assign to big). If the first condition fails, then it will be executed else part, which will give output as a is greater than b
Step 5:-
in this program, the condition is true because a is greater than b os if a part will be executed because we have enter 6 and 3 i.e 6 is greater than 3
if we enter 3 and 6 then 3 is less than 6 so else part will be executed
Step 6:-
So Output will be :- a is grater than b