regularpython@gmail.com
Python Decision Making
Decision-making statements are used to filter the data on condition-based or check the condition to execute a particular statement.
Decision Making statements are,
Ø If statement
Ø If…else statement
Ø Nested if statement
If statement:
If the statement is executed based on a Boolean expression.
Example:
If you want to display only Telugu movies. See the below example on how to write using if statement.
If ‘Telugu’ == movie_language:
Print(movie_name)
If..esle statement:
If statement is execute, if condition is true otherwise else statement will be execute.
Example:
if ‘Telugu’ == movie_language:
print(movie_name)
else:
print(‘Telugu movie not found’)
nested if statement:
if you want to multiple if statements than you can use nested if statement.
Example:
If ‘Telugu’ == movie_language:
Print(‘Telugu movie name = ’, movie_name)
elif ‘Hindi’ == movie_language:
print(‘Hindi movie name = ’, movie_name)
elif ‘Tamil’ == movie_language:
print(‘Tamil movie name =’, movie_name )
else:
print(‘Language not found’)