본문 바로가기
Python(Eng. ver)

9. Conditional Statements in Python

by 곽정우 2024. 3. 14.

1. Conditional Statements

Conditional statements are used to control the flow of execution in a program. They allow different parts of the code to be executed based on whether a specific condition is true or false.

 

2. If Statement

The if statement is the most basic conditional statement. It allows you to execute a code block only if a certain condition is true.

 

3. Else Statement

The else statement is used to define a code block that will be executed if all of the if and elif conditions in a statement are false. The else statement is optional and can be used to provide a default behavior when none of the conditions are met.

 

4. Elif Staement

The elif statement is used to check for additional conditions in an if-else statement. The elif keyword stands for "else if" and allows you to define multiple conditions, where only one of them will be executed if it is true.

 

'Python(Eng. ver)' 카테고리의 다른 글

11. Collections and Loops  (0) 2024.03.15
10. Loop Statement in Python  (0) 2024.03.14
8. Operator in Python  (0) 2024.03.14
7. Python collection type - Dictionary  (0) 2024.03.14
6. Python collection type - Set  (0) 2024.03.14