Table of Contents
In this tutorial, we will discuss the concept of “if” “elif” “else” statements in python language.
In this post, we are going to learn how to use the if-else statements to decision making
if test_expression: statement(s)
Flow diagram of the if-else statement in Python
Here, first, the program evaluates the test_expression, only when the test_expresssion is true, The statement will be executed
if the test expression is false. The flow of control exit from the if body and skipped the execution
age=19 if age>18: print("you are a teen age boy") print("age is always checked") z_score=1.1; if z_score>1.00: print("your Z_score enough ") print("you can enter uyniversity")
When we executed the above program, it produces the following result
you are a teen age boy age checking is complete your Z_score enough you can enter uyniversity
If… elif…else.. statement in python are used for decision making.
When the test_expression is true,body of if statement(s) is executed. When the test_expression is false, it executes else part of statements.
When we executed the above program, it produces the following result
Checking voting availability
you are allowed to voting
In the above example, age is declared and initialized as 32
The test expression is true and body of if (statement(s)) is executed and loop-control exits from the loop (else part is skipped)
When the test_expression3 is false, execute else part statements.
When we executed the above program, it produced the following result
When we executed the above program, it produced the following result
When we executed the above program, it produced the following result
Subtract two numbers using method overriding Program 1
PHP Star triangle Pattern program Here's a simple Java program that demonstrates how to print…
Using Function or Method to Write to temperature conversion: Fahrenheit into Celsius In this article,…
Function or method of temperature conversion from Fahrenheit into Celsius In this article, we will…
Write temperature conversion program: from Fahrenheit to Celsius In this article, we will discuss the…
How to write a program to convert Fahrenheit into Celsius In this article, we will…
This website uses cookies.