___  ___    _ _    _  _ _____   _____
 / __|/ _ \  | | |  | || |_ _\ \ / / __|
| (_ | (_) | |_  _| | __ || | \ V /| _|
 \___|\___/    |_|  |_||_|___| \_/ |___|

 --- A GOPHER-LIKE INTERFACE FOR HIVE BLOCKCHAIN ---

Python Tutorial #5 - The if-Statement

BY: @lordrazor | CREATED: Feb. 5, 2018, 4:35 p.m. | VOTES: 3 | PAYOUT: $0.00 | [ VOTE ]

[IMAGE: 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:

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:

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.

TAGS: [ #programming ] [ #python ] [ #computer ] [ #technology ] [ #tutorial ]

Replies

NO REPLIES FOUND.

[ BACK TO TRENDING ] [ BACK TO MENU ]
CMD>