Python Tutorial #5 - The if-Statement

View this thread on: d.buzz | hive.blog | peakd.com | ecency.com
·@lordrazor·
0.000 HBD
Python Tutorial #5 - The if-Statement
![](https://steemit-production-imageproxy-thumbnail.s3.amazonaws.com/U5driGN82RvVwsvBrbF74LLFeFjUdHE_1680x8400)

Welcome back to the Python Tutorial! Today we're gonna take a look at if-Statements.

With if-Statements we basically tell the Computer to check whether a condition is true or false. If it's **true**, the computer executes the code, if it's **false**, it doesn't.

Let's look at a little example:

```python
a = 0

if a == 0:
      print("a equals 0!")
```

In this case, the Output would always be *a equals 0!* because we set a to 0. If we would do something like `a = 1` first, nothing would happen.

There are a view other statements to look at:

```python
a = 0

if a == 0:
      print("a equals 0!")

elif a == 1:
      print("a equals 1!")

else:
      print("a fulfils none of the specified conditions!")
```

The elif statement basically says the following: *If the main condition is not true, try this one.*
You can include an unlimited number of elifs.
else is saying: *If not a single condition is fulfilled, do this.*

And that's basically it! If you have any Questions please write them in the commentaries! We almost did it. After taking a look at functions in the next tutorial, we can program our own little calculator.
👍 , , ,