Day 5: Conditional Statements (if statements)
- Conditional Logic:
- Introduce the concept of conditional statements for decision-making in Python.
- Explain how
if,elif(else if), andelsestatements work. - Syntax:
- Show the syntax for an
ifstatement:if condition: # Code to execute if condition is True - Comparison Operators:
- Introduce comparison operators used in conditions:
==(equal to),!=(not equal to),<(less than),>(greater than),<=(less than or equal to),>=(greater than or equal to).
- Examples:
- Provide examples of simple
ifstatements:python age = 20 if age >= 18: print("You are an adult.")
Day 6: Loops (for and while loops)
- For Loops:
- Introduce
forloops for iterating over sequences (e.g., lists, strings, range objects). - Explain the basic syntax:
for item in sequence: # Code to execute for each item - While Loops:
- Introduce
whileloops for repeated execution based on a condition. - Explain the basic syntax:
while condition: # Code to execute while condition is True - Examples:
- Provide examples of
forandwhileloops:# Example of a for loop numbers = [1, 2, 3, 4, 5] for num in numbers: print(num) # Example of a while loop count = 0 while count < 5: print(count) count += 1
Day 7: Basic Input and Output
- Input from the User:
- Introduce the
input()function for getting user input. - Explain how to use
input()to store user input in a variable.name = input("Enter your name: ") - Output to the Console:
- Discuss the
print()function for displaying output to the console. - Show how to format and combine output using
print().print("Hello, " + name + "!") - Formatting Output:
- Introduce basic string formatting techniques (e.g., f-strings):
age = 25 print(f"You are {age} years old.") - Practice Exercises:
- Provide exercises that involve conditional statements, loops, user input, and output to practice the concepts learned.
By the end of Day 7, you should have a solid grasp of control flow in Python, including conditional statements (if, elif, else), loops (for and while), and basic input/output operations. These concepts are fundamental for creating more complex programs and applications in Python.