If/Elif/Else
If we want to add one additional cases in the problem we need to use elif
statement.



12345678# What year was the first computer invented? i = 1927 if i == 1927: print('You are right!') elif i == 1925: print('You are almost right') else: print('You are not right!')
If you want to go deeper into if/elif/else statements, we have a course with more tasks to learn more about if/else blocks.
Let's add an additional case to the problem from the previous task.
Swipe to start coding
Do you recall analysts from the if-else chapter? They decided to set new discounts. If the price
is bigger than 25
, the discount
will be 25%
; if the price
is lower than or equals 25
, the discount will be 15%
. Otherwise, 5%
.
- Set the condition if the
price
is bigger than25
. - Set the
25%
discount if theprice
is greater than25
. - Set the condition if the
price
is lower than or equals25
or greater the10
. - Set the
15%
discount in case of the 3. item.!
- Otherwise, set the
5%
discount. - Print the
price_upd
.
!
To set the 15%
discount use value * 0.85
Solution
Thanks for your feedback!
single
Ask AI
Ask AI
Ask anything or try one of the suggested questions to begin our chat
Summarize this chapter
Explain the code in file
Explain why file doesn't solve the task
Awesome!
Completion rate improved to 2.08
If/Elif/Else
Swipe to show menu
If we want to add one additional cases in the problem we need to use elif
statement.



12345678# What year was the first computer invented? i = 1927 if i == 1927: print('You are right!') elif i == 1925: print('You are almost right') else: print('You are not right!')
If you want to go deeper into if/elif/else statements, we have a course with more tasks to learn more about if/else blocks.
Let's add an additional case to the problem from the previous task.
Swipe to start coding
Do you recall analysts from the if-else chapter? They decided to set new discounts. If the price
is bigger than 25
, the discount
will be 25%
; if the price
is lower than or equals 25
, the discount will be 15%
. Otherwise, 5%
.
- Set the condition if the
price
is bigger than25
. - Set the
25%
discount if theprice
is greater than25
. - Set the condition if the
price
is lower than or equals25
or greater the10
. - Set the
15%
discount in case of the 3. item.!
- Otherwise, set the
5%
discount. - Print the
price_upd
.
!
To set the 15%
discount use value * 0.85
Solution
Thanks for your feedback!
Awesome!
Completion rate improved to 2.08single