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')
Var allt tydligt?
Tack för dina kommentarer!
Avsnitt 3. Kapitel 2
Fråga AI
Fråga AI
Fråga vad du vill eller prova någon av de föreslagna frågorna för att starta vårt samtal
Suggested prompts:
Ställ mig frågor om detta ämne
Sammanfatta detta kapitel
Visa verkliga exempel
Awesome!
Completion rate improved to 2.7
If/else Statements
Svep för att visa menyn
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')
Var allt tydligt?
Tack för dina kommentarer!
Avsnitt 3. Kapitel 2