Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
iam-veeramalla authored Nov 1, 2023
1 parent d0b806f commit ba7252a
Showing 1 changed file with 69 additions and 0 deletions.
69 changes: 69 additions & 0 deletions Day-07/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# Conditional Statements in Python

Conditional statements are a fundamental part of programming that allow you to make decisions and execute different blocks of code based on certain conditions. In Python, you can use `if`, `elif` (short for "else if"), and `else` to create conditional statements.

## `if` Statement

The `if` statement is used to execute a block of code if a specified condition is `True`. If the condition is `False`, the code block is skipped.

```python
if condition:
# Code to execute if the condition is True
```

- Example:

```python
x = 10
if x > 5:
print("x is greater than 5")
```

## `elif` Statement

The `elif` statement allows you to check additional conditions if the previous `if` or `elif` conditions are `False`. You can have multiple `elif` statements after the initial `if` statement.

```python
if condition1:
# Code to execute if condition1 is True
elif condition2:
# Code to execute if condition2 is True
elif condition3:
# Code to execute if condition3 is True
# ...
else:
# Code to execute if none of the conditions are True
```

- Example:

```python
x = 10
if x > 15:
print("x is greater than 15")
elif x > 5:
print("x is greater than 5 but not greater than 15")
else:
print("x is not greater than 5")
```

## `else` Statement

The `else` statement is used to specify a block of code to execute when none of the previous conditions (in the `if` and `elif` statements) are `True`.

```python
if condition:
# Code to execute if the condition is True
else:
# Code to execute if the condition is False
```

- Example:

```python
x = 3
if x > 5:
print("x is greater than 5")
else:
print("x is not greater than 5")
```

0 comments on commit ba7252a

Please sign in to comment.