👋 Welcome to Day 1 of our Python learning journey! 🐍 Today, we're taking our first step into the exciting world of programming with Python. We'll start with the absolute classic: "Hello, World!" This simple program is a tradition for every new language learner and helps you verify your setup is ready to go. Get ready to write your first line of code! 🚀
---
```python
print("Hello, World!")
```
---
Output example:
Hello, World!
---
Small challenge:
Try modifying the code to print your name or a different greeting instead of "Hello, World!". For example, `print("Hello, [Your Name]!")` What happens if you forget the quotation marks around your text? 🤔
---
---
```python
print("Hello, World!")
```
---
Output example:
Hello, World!
---
Small challenge:
Try modifying the code to print your name or a different greeting instead of "Hello, World!". For example, `print("Hello, [Your Name]!")` What happens if you forget the quotation marks around your text? 🤔
---
What is the primary purpose of the `print()` function in Python?
Anonymous Quiz
0%
To perform mathematical calculations
50%
To display output on the console
0%
To define new variables
50%
To read input from the user
👋🐍 Day 2: Variables and Data Types! 💡
Ready to store some information? Today, we're diving into *variables* – your Python program's memory cells! Think of them as labeled containers where you can store different kinds of data. We'll also explore *data types*, which tell Python what kind of information is inside your container (like text, whole numbers, decimals, or true/false values). Let's get hands-on! 🚀
---
### Python Code:
```python
# Storing information in variables
user_name = "Anna" # String (text)
user_age = 25 # Integer (whole number)
user_height = 1.68 # Float (decimal number)
is_active_user = True # Boolean (True or False)
print(f"Hello, {user_name}!")
print(f"You are {user_age} years old.")
print(f"Your height is {user_height} meters.")
print(f"Active user status: {is_active_user}")
# Let's check their types!
print(f"nType of user_name: {type(user_name)}")
print(f"Type of user_age: {type(user_age)}")
print(f"Type of user_height: {type(user_height)}")
print(f"Type of is_active_user: {type(is_active_user)}")
# Variables can be reassigned!
user_age = user_age + 1 # Happy birthday!
print(f"nAfter birthday, user_age is: {user_age}")
```
---
### Output example:
```
Hello, Anna!
You are 25 years old.
Your height is 1.68 meters.
Active user status: True
Type of user_name: <class 'str'>
Type of user_age: <class 'int'>
Type of user_height: <class 'float'>
Type of is_active_user: <class 'bool'>
After birthday, user_age is: 26
```
---
### Small Challenge: 🧠
Create two variables: `product_name` (a string) and `product_price` (a float). Then, print a sentence like: "The [product_name] costs $[product_price]." Don't forget to use f-strings for easy formatting! ✨
---
Keep coding and see you for Day 3! Happy learning! 👨💻👩💻
---
### Quiz Question:
Ready to store some information? Today, we're diving into *variables* – your Python program's memory cells! Think of them as labeled containers where you can store different kinds of data. We'll also explore *data types*, which tell Python what kind of information is inside your container (like text, whole numbers, decimals, or true/false values). Let's get hands-on! 🚀
---
### Python Code:
```python
# Storing information in variables
user_name = "Anna" # String (text)
user_age = 25 # Integer (whole number)
user_height = 1.68 # Float (decimal number)
is_active_user = True # Boolean (True or False)
print(f"Hello, {user_name}!")
print(f"You are {user_age} years old.")
print(f"Your height is {user_height} meters.")
print(f"Active user status: {is_active_user}")
# Let's check their types!
print(f"nType of user_name: {type(user_name)}")
print(f"Type of user_age: {type(user_age)}")
print(f"Type of user_height: {type(user_height)}")
print(f"Type of is_active_user: {type(is_active_user)}")
# Variables can be reassigned!
user_age = user_age + 1 # Happy birthday!
print(f"nAfter birthday, user_age is: {user_age}")
```
---
### Output example:
```
Hello, Anna!
You are 25 years old.
Your height is 1.68 meters.
Active user status: True
Type of user_name: <class 'str'>
Type of user_age: <class 'int'>
Type of user_height: <class 'float'>
Type of is_active_user: <class 'bool'>
After birthday, user_age is: 26
```
---
### Small Challenge: 🧠
Create two variables: `product_name` (a string) and `product_price` (a float). Then, print a sentence like: "The [product_name] costs $[product_price]." Don't forget to use f-strings for easy formatting! ✨
---
Keep coding and see you for Day 3! Happy learning! 👨💻👩💻
---
### Quiz Question:
Which of the following is NOT a valid variable name in Python?
Anonymous Quiz
0%
my_variable
50%
_data
50%
1st_number
0%
userAge
🚀 Day 3: Mastering Python Operators! 💻
Today, we're diving into the essential world of **operators** in Python! These special symbols perform operations on values and variables, allowing you to manipulate data, make comparisons, and control program flow. From basic arithmetic to logical conditions, understanding operators is fundamental to writing effective and dynamic Python code. Get ready to put them into action! ✨
```python
# --- Python Operators Example ---
# Arithmetic Operators
a = 15
b = 4
print(f"Addition (a + b): {a + b}")
print(f"Subtraction (a - b): {a - b}")
print(f"Multiplication (a * b): {a * b}")
print(f"Division (a / b): {a / b}") # Float division
print(f"Floor Division (a // b): {a // b}") # Integer division (rounds down)
print(f"Modulus (a % b): {a % b}") # Remainder
print(f"Exponentiation (a ** b): {a ** b}") # a to the power of b
# Assignment Operators
x = 10
x += 5 # Equivalent to x = x + 5
print(f"x after x += 5: {x}")
# Comparison Operators
print(f"Is a equal to b? (a == b): {a == b}")
print(f"Is a greater than b? (a > b): {a > b}")
print(f"Is a not equal to 15? (a != 15): {a != 15}")
# Logical Operators
is_logged_in = True
has_permission = False
print(f"Can access resource? (is_logged_in and has_permission): {is_logged_in and has_permission}")
print(f"Is user active? (is_logged_in or has_permission): {is_logged_in or has_permission}")
print(f"Is not logged in? (not is_logged_in): {not is_logged_in}")
```
Output example:
Addition (a + b): 19
Subtraction (a - b): 11
Multiplication (a * b): 60
Division (a / b): 3.75
Floor Division (a // b): 3
Modulus (a % b): 3
Exponentiation (a ** b): 50625
x after x += 5: 15
Is a equal to b? (a == b): False
Is a greater than b? (a > b): True
Is a not equal to 15? (a != 15): False
Can access resource? (is_logged_in and has_permission): False
Is user active? (is_logged_in or has_permission): True
Is not logged in? (not is_logged_in): False
---
💡 **Small Challenge:**
Can you write a Python expression using the logical `and` operator that evaluates to `True` only if a variable `age` is between 18 and 65 (inclusive)? Share your solution!
---
Today, we're diving into the essential world of **operators** in Python! These special symbols perform operations on values and variables, allowing you to manipulate data, make comparisons, and control program flow. From basic arithmetic to logical conditions, understanding operators is fundamental to writing effective and dynamic Python code. Get ready to put them into action! ✨
```python
# --- Python Operators Example ---
# Arithmetic Operators
a = 15
b = 4
print(f"Addition (a + b): {a + b}")
print(f"Subtraction (a - b): {a - b}")
print(f"Multiplication (a * b): {a * b}")
print(f"Division (a / b): {a / b}") # Float division
print(f"Floor Division (a // b): {a // b}") # Integer division (rounds down)
print(f"Modulus (a % b): {a % b}") # Remainder
print(f"Exponentiation (a ** b): {a ** b}") # a to the power of b
# Assignment Operators
x = 10
x += 5 # Equivalent to x = x + 5
print(f"x after x += 5: {x}")
# Comparison Operators
print(f"Is a equal to b? (a == b): {a == b}")
print(f"Is a greater than b? (a > b): {a > b}")
print(f"Is a not equal to 15? (a != 15): {a != 15}")
# Logical Operators
is_logged_in = True
has_permission = False
print(f"Can access resource? (is_logged_in and has_permission): {is_logged_in and has_permission}")
print(f"Is user active? (is_logged_in or has_permission): {is_logged_in or has_permission}")
print(f"Is not logged in? (not is_logged_in): {not is_logged_in}")
```
Output example:
Addition (a + b): 19
Subtraction (a - b): 11
Multiplication (a * b): 60
Division (a / b): 3.75
Floor Division (a // b): 3
Modulus (a % b): 3
Exponentiation (a ** b): 50625
x after x += 5: 15
Is a equal to b? (a == b): False
Is a greater than b? (a > b): True
Is a not equal to 15? (a != 15): False
Can access resource? (is_logged_in and has_permission): False
Is user active? (is_logged_in or has_permission): True
Is not logged in? (not is_logged_in): False
---
💡 **Small Challenge:**
Can you write a Python expression using the logical `and` operator that evaluates to `True` only if a variable `age` is between 18 and 65 (inclusive)? Share your solution!
---
Here's your Telegram post for Day 4 of the Python learning series!
---
**Python Learning Series: Day 4 - Conditional Statements**
Day 4 is here! 🚀 Today, we unlock the power of *decision-making* in Python with Conditional Statements: `if`, `elif`, and `else`.
Ever wanted your code to do different things based on certain conditions? 🤔 That's exactly what these statements let you do! They're fundamental for creating dynamic and intelligent programs. Let's dive into controlling your code's flow! 👇
```python
# Example 1: Checking if a number is positive, negative, or zero
number = 5 # Try changing this to 0 or -3 and run the code!
if number > 0:
print("The number is positive.")
elif number == 0:
print("The number is zero.")
else:
print("The number is negative.")
print("-" * 20) # Separator for clarity
# Example 2: Simple age check
age = 18
if age >= 18:
print("You are an adult.")
else:
print("You are a minor.")
```
Output example:
```
The number is positive.
--------------------
You are an adult.
```
Small challenge:
Ready for a quick practice? 🤔 Write a Python script that takes a user's `input()` number and determines if it's "Even" or "Odd" using `if` and `else` statements! (Hint: The modulo operator `%` might be your friend here! 😉)
---
---
**Python Learning Series: Day 4 - Conditional Statements**
Day 4 is here! 🚀 Today, we unlock the power of *decision-making* in Python with Conditional Statements: `if`, `elif`, and `else`.
Ever wanted your code to do different things based on certain conditions? 🤔 That's exactly what these statements let you do! They're fundamental for creating dynamic and intelligent programs. Let's dive into controlling your code's flow! 👇
```python
# Example 1: Checking if a number is positive, negative, or zero
number = 5 # Try changing this to 0 or -3 and run the code!
if number > 0:
print("The number is positive.")
elif number == 0:
print("The number is zero.")
else:
print("The number is negative.")
print("-" * 20) # Separator for clarity
# Example 2: Simple age check
age = 18
if age >= 18:
print("You are an adult.")
else:
print("You are a minor.")
```
Output example:
```
The number is positive.
--------------------
You are an adult.
```
Small challenge:
Ready for a quick practice? 🤔 Write a Python script that takes a user's `input()` number and determines if it's "Even" or "Odd" using `if` and `else` statements! (Hint: The modulo operator `%` might be your friend here! 😉)
---
What will be the output of the following Python code?
```python
score = 75 if score >= 90: result = "Excellent" elif score >= 70: result = "Good" elif score >= 50: result = "Average" else: result = "Fail" print(result) ```
```python
score = 75 if score >= 90: result = "Excellent" elif score >= 70: result = "Good" elif score >= 50: result = "Average" else: result = "Fail" print(result) ```
Anonymous Quiz
0%
Good
0%
Excellent
0%
Average
0%
Fail
Here's your Telegram post for Day 5 of the Python learning series!
---
Hello Python Learners! 👋 Day 5 is here, and we're diving into one of programming's superpowers: *loops*! 🚀 Loops allow your code to repeat actions efficiently, saving you tons of time and effort. Whether you know exactly how many times you need to repeat something (`for` loop) or you need to keep going until a condition is met (`while` loop), loops are your best friends for automation. Let's make our programs dynamic! ✨
```python
# Day 5: Loops (for and while)
# --- The 'for' Loop ---
# Used for iterating over a sequence (like a list, tuple, dictionary, set, or string)
# or other iterable objects. Great when you know how many times you want to loop.
print("--- For Loop Example: Iterating over a list ---")
fruits = ["apple", "banana", "cherry", "date"]
for fruit in fruits:
print(f"I love {fruit}!")
print("n--- For Loop Example: Using range() ---")
# range(start, stop, step) - stop is exclusive
for i in range(3): # This will give 0, 1, 2
print(f"Counting with for: {i}")
# --- The 'while' Loop ---
# Executes a block of code as long as a specified condition is true.
# Be careful not to create an infinite loop!
print("n--- While Loop Example ---")
countdown = 3
while countdown > 0:
print(f"Countdown: {countdown}...")
countdown -= 1 # Decrement the counter to eventually make the condition false
print("Lift off! 🚀")
```
Output example:
```
--- For Loop Example: Iterating over a list ---
I love apple!
I love banana!
I love cherry!
I love date!
--- For Loop Example: Using range() ---
Counting with for: 0
Counting with for: 1
Counting with for: 2
--- While Loop Example ---
Countdown: 3...
Countdown: 2...
Countdown: 1...
Lift off! 🚀
```
**Small Challenge:** 💪
Write a `for` loop that prints all even numbers from 2 to 10 (inclusive). Share your code in the comments! 👇
---
---
Hello Python Learners! 👋 Day 5 is here, and we're diving into one of programming's superpowers: *loops*! 🚀 Loops allow your code to repeat actions efficiently, saving you tons of time and effort. Whether you know exactly how many times you need to repeat something (`for` loop) or you need to keep going until a condition is met (`while` loop), loops are your best friends for automation. Let's make our programs dynamic! ✨
```python
# Day 5: Loops (for and while)
# --- The 'for' Loop ---
# Used for iterating over a sequence (like a list, tuple, dictionary, set, or string)
# or other iterable objects. Great when you know how many times you want to loop.
print("--- For Loop Example: Iterating over a list ---")
fruits = ["apple", "banana", "cherry", "date"]
for fruit in fruits:
print(f"I love {fruit}!")
print("n--- For Loop Example: Using range() ---")
# range(start, stop, step) - stop is exclusive
for i in range(3): # This will give 0, 1, 2
print(f"Counting with for: {i}")
# --- The 'while' Loop ---
# Executes a block of code as long as a specified condition is true.
# Be careful not to create an infinite loop!
print("n--- While Loop Example ---")
countdown = 3
while countdown > 0:
print(f"Countdown: {countdown}...")
countdown -= 1 # Decrement the counter to eventually make the condition false
print("Lift off! 🚀")
```
Output example:
```
--- For Loop Example: Iterating over a list ---
I love apple!
I love banana!
I love cherry!
I love date!
--- For Loop Example: Using range() ---
Counting with for: 0
Counting with for: 1
Counting with for: 2
--- While Loop Example ---
Countdown: 3...
Countdown: 2...
Countdown: 1...
Lift off! 🚀
```
**Small Challenge:** 💪
Write a `for` loop that prints all even numbers from 2 to 10 (inclusive). Share your code in the comments! 👇
---
What will be the output of the following Python code?
```python count = 0 while count < 4: print(count * 2) count += 1 ```
```python count = 0 while count < 4: print(count * 2) count += 1 ```
Anonymous Quiz
0%
0 2 4 6
100%
0 1 2 3
0%
2 4 6 8
0%
0 2 4 6 8
🎉 Hey Python learners! 🚀 Ready for Day 6? Today, we're diving into the superpower of Python: *functions*! 🧱 Functions are reusable blocks of code that perform a specific task, helping you write cleaner, more organized, and less repetitive programs. Think of them as mini-programs within your main program! Let's unlock their magic! ✨
Functions are defined using the `def` keyword, followed by the function name, parentheses `()`, and a colon `:`. Parameters go inside the parentheses.
```python
# Defining a simple function to greet someone
def greet(name):
"""This function takes a name and prints a personalized greeting."""
print(f"👋 Hello, {name}! Welcome to Day 6 of Python!")
# Defining a function that performs a calculation and returns a value
def add_numbers(a, b):
"""This function takes two numbers and returns their sum."""
return a + b
# --- Calling our functions ---
# Call the greet function with different names
greet("Pythonista")
greet("Learner")
# Call the add_numbers function and store its returned value
sum_result = add_numbers(10, 5)
print(f"The sum of 10 and 5 is: {sum_result}")
another_sum = add_numbers(2.5, 7.5)
print(f"The sum of 2.5 and 7.5 is: {another_sum}")
```
Output example:
```
👋 Hello, Pythonista! Welcome to Day 6 of Python!
👋 Hello, Learner! Welcome to Day 6 of Python!
The sum of 10 and 5 is: 15
The sum of 2.5 and 7.5 is: 10.0
```
### Small Challenge:
Your turn! 🚀 Create a function called `multiply(x, y)` that takes two numbers as arguments and returns their product. Then call your `multiply` function with any two numbers and print the result!
---
Functions are defined using the `def` keyword, followed by the function name, parentheses `()`, and a colon `:`. Parameters go inside the parentheses.
```python
# Defining a simple function to greet someone
def greet(name):
"""This function takes a name and prints a personalized greeting."""
print(f"👋 Hello, {name}! Welcome to Day 6 of Python!")
# Defining a function that performs a calculation and returns a value
def add_numbers(a, b):
"""This function takes two numbers and returns their sum."""
return a + b
# --- Calling our functions ---
# Call the greet function with different names
greet("Pythonista")
greet("Learner")
# Call the add_numbers function and store its returned value
sum_result = add_numbers(10, 5)
print(f"The sum of 10 and 5 is: {sum_result}")
another_sum = add_numbers(2.5, 7.5)
print(f"The sum of 2.5 and 7.5 is: {another_sum}")
```
Output example:
```
👋 Hello, Pythonista! Welcome to Day 6 of Python!
👋 Hello, Learner! Welcome to Day 6 of Python!
The sum of 10 and 5 is: 15
The sum of 2.5 and 7.5 is: 10.0
```
### Small Challenge:
Your turn! 🚀 Create a function called `multiply(x, y)` that takes two numbers as arguments and returns their product. Then call your `multiply` function with any two numbers and print the result!
---
Which keyword is used to define a function in Python?
Anonymous Quiz
0%
func
0%
define
0%
def
0%
function
Here's your Telegram post for Day 7!
---
🐍 Python Learning Series - Day 7! ✨ Today, we dive into two fundamental data structures: *Lists* and *Tuples*! 📚 You'll learn how to store collections of items, access them, and understand the key differences between these versatile types. Get ready to organize your data like a pro! 🚀
```python
# Day 7: Lists and Tuples - Organizing Collections
# --- Lists (Mutable, ordered collection) ---
my_list = [1, 2, 3, "apple", True]
print(f"Original list: {my_list}")
# Accessing elements
print(f"First element of list: {my_list[0]}")
print(f"Last element of list: {my_list[-1]}")
# Modifying a list (Lists are mutable!)
my_list.append("banana")
print(f"List after append: {my_list}")
my_list[1] = 20 # Change an element by index
print(f"List after modification: {my_list}")
my_list.remove("apple")
print(f"List after remove: {my_list}")
# Slicing a list
print(f"List slice (index 1 to 3): {my_list[1:4]}")
# --- Tuples (Immutable, ordered collection) ---
my_tuple = (10, 20, "orange", False)
print(f"nOriginal tuple: {my_tuple}")
# Accessing elements (similar to lists)
print(f"First element of tuple: {my_tuple[0]}")
print(f"Last element of tuple: {my_tuple[-1]}")
# Tuples are IMMUTABLE - cannot change after creation!
# Uncommenting the line below would raise a TypeError:
# my_tuple[0] = 100
# print(f"Trying to modify tuple: {my_tuple}") # This will fail!
# Concatenating tuples (creates a NEW tuple)
new_tuple = my_tuple + (True, 50)
print(f"Concatenated tuple (new tuple created): {new_tuple}")
# Checking types
print(f"Type of my_list: {type(my_list)}")
print(f"Type of my_tuple: {type(my_tuple)}")
```
Output example:
```
Original list: [1, 2, 3, 'apple', True]
First element of list: 1
Last element of list: True
List after append: [1, 2, 3, 'apple', True, 'banana']
List after modification: [1, 20, 3, 'apple', True, 'banana']
List after remove: [1, 20, 3, True, 'banana']
List slice (index 1 to 3): [20, 3, True]
Original tuple: (10, 20, 'orange', False)
First element of tuple: 10
Last element of tuple: False
Concatenated tuple (new tuple created): (10, 20, 'orange', False, True, 50)
Type of my_list: <class 'list'>
Type of my_tuple: <class 'tuple'>
```
Small challenge:
Challenge: Create a list of your 3 favorite colors. Now, create a tuple containing the same colors but in a different order. Try to add a 4th color to your *tuple* and observe what happens! 🎨🖌️
---
Here's a quiz question related to today's lesson:
---
🐍 Python Learning Series - Day 7! ✨ Today, we dive into two fundamental data structures: *Lists* and *Tuples*! 📚 You'll learn how to store collections of items, access them, and understand the key differences between these versatile types. Get ready to organize your data like a pro! 🚀
```python
# Day 7: Lists and Tuples - Organizing Collections
# --- Lists (Mutable, ordered collection) ---
my_list = [1, 2, 3, "apple", True]
print(f"Original list: {my_list}")
# Accessing elements
print(f"First element of list: {my_list[0]}")
print(f"Last element of list: {my_list[-1]}")
# Modifying a list (Lists are mutable!)
my_list.append("banana")
print(f"List after append: {my_list}")
my_list[1] = 20 # Change an element by index
print(f"List after modification: {my_list}")
my_list.remove("apple")
print(f"List after remove: {my_list}")
# Slicing a list
print(f"List slice (index 1 to 3): {my_list[1:4]}")
# --- Tuples (Immutable, ordered collection) ---
my_tuple = (10, 20, "orange", False)
print(f"nOriginal tuple: {my_tuple}")
# Accessing elements (similar to lists)
print(f"First element of tuple: {my_tuple[0]}")
print(f"Last element of tuple: {my_tuple[-1]}")
# Tuples are IMMUTABLE - cannot change after creation!
# Uncommenting the line below would raise a TypeError:
# my_tuple[0] = 100
# print(f"Trying to modify tuple: {my_tuple}") # This will fail!
# Concatenating tuples (creates a NEW tuple)
new_tuple = my_tuple + (True, 50)
print(f"Concatenated tuple (new tuple created): {new_tuple}")
# Checking types
print(f"Type of my_list: {type(my_list)}")
print(f"Type of my_tuple: {type(my_tuple)}")
```
Output example:
```
Original list: [1, 2, 3, 'apple', True]
First element of list: 1
Last element of list: True
List after append: [1, 2, 3, 'apple', True, 'banana']
List after modification: [1, 20, 3, 'apple', True, 'banana']
List after remove: [1, 20, 3, True, 'banana']
List slice (index 1 to 3): [20, 3, True]
Original tuple: (10, 20, 'orange', False)
First element of tuple: 10
Last element of tuple: False
Concatenated tuple (new tuple created): (10, 20, 'orange', False, True, 50)
Type of my_list: <class 'list'>
Type of my_tuple: <class 'tuple'>
```
Small challenge:
Challenge: Create a list of your 3 favorite colors. Now, create a tuple containing the same colors but in a different order. Try to add a 4th color to your *tuple* and observe what happens! 🎨🖌️
---
Here's a quiz question related to today's lesson: