Learn Python — If Statement

If is branching in Python, so branching logic is a very basic and very important thing to master when we learn a particular programming language

so, if is the fundamental condition, while Elif is the second or third condition up to x, while else is the last condition where none of the previous conditions fulfilled.

If

structure if like this :

if Condition is a variable / value of type boolean data. Even its Tue / False directly, or just a logic expression.

if Condition has a value of True, so Safety() will be executed by the system.

write, and look this program :

if we run this code, the output is :

your code program is work
this program code as always executed because not include in the branch

why?

that’s because If in the second not have a value True, so the statement in there don’t even has executed by system.

and print in the third as always to executed because it is outside the code block

besides using boolean directly, we can also use logic expressions for branching.

look the example :

if we run this code, the output is :

250 is more biggest than 100

--

--

--

Melati Nur Malasari |K3521042 |Pendidikan Teknik Informatika dan Komputer |2021 |Universitas Sebelas Maret |Melati.nur.malasari8@student.uns.ac.id|

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Escape Characters in Java

TOKEN GENERATION EVENT (TGE) - PLAYERMON

OK Google, lets order from Swiggy

Terminolator

Automate the boring stuff: Pattern matching with regular expression

Demystifying Docker Containers Internal and Breaking Myths

Detailed Network Monitoring with Stackdriver

Scraping Air Pollution Data from Thailand EPA

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Melati Nur Malasari

Melati Nur Malasari

Melati Nur Malasari |K3521042 |Pendidikan Teknik Informatika dan Komputer |2021 |Universitas Sebelas Maret |Melati.nur.malasari8@student.uns.ac.id|

More from Medium

Python Unknown (Tips and Tricks) — Part 2

Your Christmas tree in Python 🎄

How to Use Self Healing Python Code to get Remote Host Response and Continue the next stage

Learn Python pt.3 — If.. Elif .. Else