if then else
时间: 2023-08-26 20:06:22 浏览: 85
if else 语句
If-then-else is a conditional statement commonly used in programming languages. It allows you to execute different blocks of code based on a condition. Here's an example in Python:
```python
x = 10
if x > 5:
print("x is greater than 5")
else:
print("x is not greater than 5")
```
In this example, if the condition `x > 5` is true, the code within the if block will be executed, which prints "x is greater than 5". Otherwise, the code within the else block will be executed, which prints "x is not greater than 5".
阅读全文