If/else Statements
Decision making is required when we want to execute a code only if a certain condition is satisfied.
The if
, elif
, else
statement is used in Python for decision making.
123456price = 999 if price > 1000: print('The price is high. I won't buy it') else: print('OK, I will buy it')
Everything was clear?
Thanks for your feedback!
SectionΒ 3. ChapterΒ 2
Ask AI
Ask AI
Ask anything or try one of the suggested questions to begin our chat
Suggested prompts:
Ask me questions about this topic
Summarize this chapter
Show real-world examples
Awesome!
Completion rate improved to 2.7
If/else Statements
Swipe to show menu
Decision making is required when we want to execute a code only if a certain condition is satisfied.
The if
, elif
, else
statement is used in Python for decision making.
123456price = 999 if price > 1000: print('The price is high. I won't buy it') else: print('OK, I will buy it')
Everything was clear?
Thanks for your feedback!
SectionΒ 3. ChapterΒ 2