python10
python10
https://learning.ccbp.in/course?c_id=a6454e48-d030-4d49-8920-253198052232&t_id=9b13ad84-b75c-4328-9cd3-0c6751ae6b4d&s_id=7944b1f6… 1/9
7/27/24, 9:03 PM Revolutionizing the Job Market | NxtWave
Nested Conditions
Code
PYTHON
1 matches_won = int(input())
2 goals = int(input())
3 if matches_won > 8:
4 if goals > 20:
5 print("Hurray")
6 print("Winner")
Input
10
22
Output
https://learning.ccbp.in/course?c_id=a6454e48-d030-4d49-8920-253198052232&t_id=9b13ad84-b75c-4328-9cd3-0c6751ae6b4d&s_id=7944b1f6… 2/9
7/27/24, 9:03 PM Revolutionizing the Job Market | NxtWave
Hurray
Winner
Input
10
18
Output
Winner
https://learning.ccbp.in/course?c_id=a6454e48-d030-4d49-8920-253198052232&t_id=9b13ad84-b75c-4328-9cd3-0c6751ae6b4d&s_id=7944b1f6… 3/9
7/27/24, 9:03 PM Revolutionizing the Job Market | NxtWave
Code
PYTHON
1 a = 2
2 b = 3
3 c = 1
4 is_a_greatest = (a > b) and (a > c)
5 if is_a_greatest:
6 print(a)
7 else:
8 is_b_greatest = (b > c)
9 if is_b_greatest:
10 print(b)
Expand
Output
Elif Statement
https://learning.ccbp.in/course?c_id=a6454e48-d030-4d49-8920-253198052232&t_id=9b13ad84-b75c-4328-9cd3-0c6751ae6b4d&s_id=7944b1f6… 4/9
7/27/24, 9:03 PM Revolutionizing the Job Market | NxtWave
https://learning.ccbp.in/course?c_id=a6454e48-d030-4d49-8920-253198052232&t_id=9b13ad84-b75c-4328-9cd3-0c6751ae6b4d&s_id=7944b1f6… 5/9
7/27/24, 9:03 PM Revolutionizing the Job Market | NxtWave
Python will execute the elif block whose expression evaluates to true.
If multiple
elif conditions are true, then only the first elif block which is True will be
executed.
https://learning.ccbp.in/course?c_id=a6454e48-d030-4d49-8920-253198052232&t_id=9b13ad84-b75c-4328-9cd3-0c6751ae6b4d&s_id=7944b1f6… 6/9
7/27/24, 9:03 PM Revolutionizing the Job Market | NxtWave
if - elif statements.
Code
https://learning.ccbp.in/course?c_id=a6454e48-d030-4d49-8920-253198052232&t_id=9b13ad84-b75c-4328-9cd3-0c6751ae6b4d&s_id=7944b1f6… 7/9
7/27/24, 9:03 PM Revolutionizing the Job Market | NxtWave
PYTHON
1 number = 5
2 is_divisible_by_10 = (number % 10 == 0)
3 is_divisible_by_5 = (number % 5 == 0)
4 if is_divisible_by_10:
5 print("Divisible by 10")
6 elif is_divisible_by_5:
7 print("Divisible by 5")
8 else:
9 print("Not Divisible by 10 or 5")
Output
Divisible by 5
Possible Mistake
else statement.
https://learning.ccbp.in/course?c_id=a6454e48-d030-4d49-8920-253198052232&t_id=9b13ad84-b75c-4328-9cd3-0c6751ae6b4d&s_id=7944b1f6… 8/9
7/27/24, 9:03 PM Revolutionizing the Job Market | NxtWave
https://learning.ccbp.in/course?c_id=a6454e48-d030-4d49-8920-253198052232&t_id=9b13ad84-b75c-4328-9cd3-0c6751ae6b4d&s_id=7944b1f6… 9/9