How to use if/elif/else statements in python

if/elif/else statements  in python



When you need to include a selection part into a python program, you can use the if statement with a condition.
If you want to add only one condition to the program you can use if and else statements.



Lets see how to use that statements using an example.

**Click Here for access to examples and other programs**

if / else

In this code we can find the largest number among the inputted two numbers.








This code give output (pass or fail) according to the mark inputted from the user.





 

 

 

if / elif / else

When user want to add more than one condition then user can use if, elif and else statements.

This program is created for find the largest number among the inputted three numbers.








This program includes a grading system for students according to the mark inputted by user.

0 comments:

Post a Comment