How and Why to use control structures?
Conditional
Looping
Flow Modifications: break, continue, exit, goto, etc.
For Loop: Iterate over a sequence of elements.
variable
takes on value of each element in sequence.
What will this output?:
Where can we use loops? Where shouldn’t we use loops?
Execute code based on condition.
> condition
is an expression that evaluates to true or false.
Example:
What if we have alternatives?
Example:
Is there a better way to do this?
lang = input("What's the programming language you want to learn? ")
match lang:
case "JavaScript":
print("You can become a web developer.")
case "Python":
print("You can become a Data Scientist")
case "PHP":
print("You can become a backend developer")
case "Solidity":
print("You can become a Blockchain developer")
case "Java":
print("You can become a mobile app developer")
case _:
print("The language doesn't matter, what matters is solving problems.")
Important Notes:
Where can we use conditional statements?
Group
ManagementError Handling!
Examples:
Where should you handle errors?
A Python function that takes a function as an argument and returns a new function.
Allow you to modify the functionality of a function by wrapping it in another function.
Decorators are implemented using the “@” symbol followed by the name of the decorator function. They are placed before the function definition.
Note this is pseudo-code:
Earth System Data Science in the Cloud