Skip to content

Commit e210356

Browse files
Formatted for a cleaner look
1 parent c4c7c7a commit e210356

1 file changed

Lines changed: 0 additions & 8 deletions

File tree

basics/conditionals.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
11
"""----------Conditionals with Python---------
22
33
# What are conditionals?
4-
54
# Conditionals in Python are statements that allow a program to make decisions and execute different blocks of code based on whether a specified condition is True or False.
65
# They are fundamental for controlling the flow of a program and enabling it to respond dynamically to various inputs or situations.
7-
8-
# Conditionals:
9-
106
# if
117
# elif
128
# else
@@ -32,7 +28,6 @@
3228
print("You are allowed to vote")
3329
else:
3430
print("Please come back when you are 18 or over")
35-
3631
"""
3732
---------------------------
3833
elif : if else
@@ -70,7 +65,6 @@
7065
print(f"You have Access {m}") # We will print you have Access Mary
7166
else:
7267
print("Access Denied") # If none of the names match the names shown above we will then print out Access Denied
73-
7468
"""
7569
---------------------------
7670
Example using Boolean
@@ -82,14 +76,12 @@
8276
print(True)
8377
elif light_on == "off": # if the user types "off" meaning the light is off we will print the Bool False
8478
print(False)
85-
8679
"""
8780
---------------------------
8881
Nested if statement Example
8982
---------------------------
9083
Nested if statements are Conditional statements can be nested within other conditional statements to handle more complex logic
9184
"""
92-
9385
age = 25 # This is the age that we gave ourself or it can be the age of the user
9486
has_license = True # The user has a license therefore we put the Bool True. If the user has no license we can change this to the Bool False
9587
if age >= 18: # If the user age is greater than or equals to 18

0 commit comments

Comments
 (0)