Dan | Machine Learning Engineer
Dan | Machine Learning Engineer

@DanKornas

7 Tweets Dec 09, 2022
Day 9 of #60daysOfMachineLearning
๐Ÿ”ต Python Conditions and If Statements
Conditions are used in programming to execute a specific block of code ONLY when the given condition is met.
๐Ÿงต Here is how to work with conditions ๐Ÿ‘‡
๐Ÿ’  IF Statements
The `if` keyword is used to create a "if statement."
Python uses indentation (whitespace at the start of a line) to define scope in code. Curly-brackets are frequently used for this purpose in other computer languages.
๐Ÿ’  ELIF Statements
The elif keyword in Python means "attempt this condition if the preceding conditions were not true.โ€
๐Ÿ’  ELSE Statements
Anything that isn't covered by the previous conditions is caught by the else keyword.
๐Ÿ’  Nested IF Statements
You can have if statements inside if statements, this is called nested if statements.
๐Ÿ’  PASS Statements
If statements cannot be empty, but if you have an if statement with no content, include the pass statement to prevent an error.
If you missed the previous days, don't worry! You can follow along and go back to day 1 by going to this link ๐Ÿ‘‡

Loading suggestions...