Skip to content

Commit deb63c0

Browse files
updated
1 parent 3d7ba34 commit deb63c0

File tree

182 files changed

+250750
-5
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

182 files changed

+250750
-5
lines changed

docs/1-print.md

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# Chapter 1: Print Statement
2+
3+
## 📺 Video Tutorial
4+
5+
**Start coding with PYTHON in 5 minutes! 🐍** (5:13)
6+
7+
[![Watch on YouTube](https://img.shields.io/badge/Watch-YouTube-red?style=for-the-badge&logo=youtube)](https://youtu.be/Sg4GMVMdOPo)
8+
9+
## �📚 What You'll Learn
10+
In this chapter, you'll learn about the `print()` function, which is your first step in Python programming!
11+
12+
## 🎯 Learning Objectives
13+
- Understand what the `print()` function does
14+
- Learn how to display text to the console
15+
- Write your first Python program
16+
- Understand the basics of Python comments
17+
18+
## 📖 Concept Explanation
19+
20+
### The print() Function
21+
The `print()` function is one of Python's built-in functions that displays output to the console/terminal. It's used to:
22+
- Show messages to users
23+
- Display results of calculations
24+
- Debug your code
25+
- Output any information you want to see
26+
27+
### Syntax
28+
```python
29+
print("Your message here")
30+
```
31+
32+
### Key Points
33+
- Text (strings) must be enclosed in quotes (single `'` or double `"`)
34+
- Each `print()` statement creates a new line by default
35+
- You can print numbers, text, and other data types
36+
37+
## 💡 Examples
38+
39+
### Basic Print
40+
```python
41+
print("Hello, World!")
42+
```
43+
44+
### Multiple Lines
45+
```python
46+
print("Line 1")
47+
print("Line 2")
48+
print("Line 3")
49+
```
50+
51+
## ✍️ Practice Exercises
52+
1. Print your name to the console
53+
2. Print your favorite hobby
54+
3. Create a program that prints a short poem (3-4 lines)
55+
4. Print your age and favorite color on separate lines
56+
57+
## 🚀 Try It Yourself
58+
Modify `main.py` to print information about yourself!
59+
60+
## 📝 Comments
61+
Comments are lines that Python ignores. They help explain your code:
62+
```python
63+
# This is a comment
64+
print("This is code") # This is also a comment
65+
```
66+
67+
## 🎓 Key Takeaways from Video
68+
69+
1. Download Python interpreter from python.org
70+
2. Install an IDE (PyCharm or VS Code) for writing Python code
71+
3. Add Python to PATH during installation (Windows)
72+
4. Create a new Python project and file
73+
5. Lists store multiple items in a single variable
74+
75+
> 💡 *These points cover the main concepts from the video tutorial to help reinforce your learning.*
76+
77+
## 🔗 Next Chapter
78+
Continue to [Chapter 2: Variables](2-variables.md) to learn about storing data!
79+

docs/10-logical-operators.md

Lines changed: 225 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,225 @@
1+
# Chapter 11: Logical Operators
2+
3+
## 📺 Video Tutorial
4+
5+
**Logical operators in Python are easy 🔣** (7:56)
6+
7+
[![Watch on YouTube](https://img.shields.io/badge/Watch-YouTube-red?style=for-the-badge&logo=youtube)](https://youtu.be/W7luvtXeQTA)
8+
9+
## 📺 Video Tutorial
10+
11+
[![Watch on YouTube](https://img.shields.io/badge/Watch-BroCode_Python_Master_Class-red?style=for-the-badge&logo=youtube)](https://youtu.be/TYyKQBC4bwE)
12+
13+
## 📚 What You'll Learn
14+
Combine multiple conditions using logical operators to create powerful decision-making logic!
15+
16+
## 🎯 Learning Objectives
17+
- Understand AND, OR, and NOT logical operators
18+
- Combine multiple conditions in if statements
19+
- Create complex decision-making logic
20+
- Use truth tables to understand operator behavior
21+
22+
## 📖 Concept Explanation
23+
24+
### Logical Operators
25+
Logical operators combine boolean expressions (conditions) to create more complex logic.
26+
27+
| Operator | Description | Example |
28+
|----------|-------------|---------|
29+
| `and` | Both conditions must be True | `age >= 18 and has_license` |
30+
| `or` | At least one condition must be True | `is_weekend or is_holiday` |
31+
| `not` | Reverses the boolean value | `not is_raining` |
32+
33+
### AND Operator
34+
Returns True only if **both** conditions are True:
35+
```python
36+
if temp > 30 and is_sunny:
37+
print("Hot and sunny!")
38+
```
39+
40+
Truth Table for AND:
41+
| Condition 1 | Condition 2 | Result |
42+
|-------------|-------------|--------|
43+
| True | True | **True** |
44+
| True | False | False |
45+
| False | True | False |
46+
| False | False | False |
47+
48+
### OR Operator
49+
Returns True if **at least one** condition is True:
50+
```python
51+
if is_weekend or is_holiday:
52+
print("Day off!")
53+
```
54+
55+
Truth Table for OR:
56+
| Condition 1 | Condition 2 | Result |
57+
|-------------|-------------|--------|
58+
| True | True | **True** |
59+
| True | False | **True** |
60+
| False | True | **True** |
61+
| False | False | False |
62+
63+
### NOT Operator
64+
Reverses the boolean value:
65+
```python
66+
if not is_raining:
67+
print("No umbrella needed!")
68+
```
69+
70+
Truth Table for NOT:
71+
| Condition | Result |
72+
|-----------|--------|
73+
| True | False |
74+
| False | True |
75+
76+
## 💡 Examples
77+
78+
### Example 1: Age and License Check
79+
```python
80+
age = 20
81+
has_license = True
82+
83+
if age >= 18 and has_license:
84+
print("You can drive!")
85+
else:
86+
print("You cannot drive yet.")
87+
```
88+
89+
### Example 2: Weekend or Holiday
90+
```python
91+
is_weekend = False
92+
is_holiday = True
93+
94+
if is_weekend or is_holiday:
95+
print("No work today!")
96+
else:
97+
print("Time to work.")
98+
```
99+
100+
### Example 3: Weather Advisory
101+
```python
102+
temp = 35
103+
is_sunny = True
104+
is_raining = False
105+
106+
if temp > 30 and is_sunny and not is_raining:
107+
print("Perfect beach weather!")
108+
```
109+
110+
### Example 4: Login System
111+
```python
112+
username = "admin"
113+
password = "secret123"
114+
is_verified = True
115+
116+
if (username == "admin" and password == "secret123") and is_verified:
117+
print("Access granted!")
118+
else:
119+
print("Access denied!")
120+
```
121+
122+
## ✍️ Practice Exercises
123+
124+
1. **Voting Eligibility**: Check if person can vote (age >= 18 AND is_citizen)
125+
2. **Discount Calculator**: Apply discount if purchase > $100 OR is_member
126+
3. **Alarm System**: Sound alarm if is_night AND (motion_detected OR door_open)
127+
4. **Grade Pass/Fail**: Pass if score >= 60 AND attendance >= 75%
128+
5. **Weather Outfit**: Suggest outfit based on temp AND (is_raining OR is_snowing)
129+
6. **Access Control**: Grant access if (is_admin OR is_manager) AND is_active
130+
131+
## 🔍 Common Mistakes
132+
133+
### Mistake 1: Confusing AND with OR
134+
```python
135+
# Wrong: This is too restrictive
136+
if day == "Saturday" and day == "Sunday": # day can't be both!
137+
print("Weekend")
138+
139+
# Correct:
140+
if day == "Saturday" or day == "Sunday":
141+
print("Weekend")
142+
```
143+
144+
### Mistake 2: Forgetting Parentheses
145+
```python
146+
# Ambiguous:
147+
if age > 18 and is_student or has_id # Unclear precedence
148+
149+
# Clear:
150+
if (age > 18 and is_student) or has_id # Much better!
151+
```
152+
153+
### Mistake 3: Using = Instead of ==
154+
```python
155+
# Wrong:
156+
if username = "admin": # Assignment, not comparison!
157+
158+
# Correct:
159+
if username == "admin": # Comparison
160+
```
161+
162+
## 📝 Operator Precedence
163+
Python evaluates operators in this order:
164+
1. Parentheses `()`
165+
2. `not`
166+
3. `and`
167+
4. `or`
168+
169+
```python
170+
# Without parentheses
171+
result = True or False and False # True (and evaluated first)
172+
173+
# With parentheses (recommended for clarity)
174+
result = True or (False and False) # True
175+
result = (True or False) and False # False
176+
```
177+
178+
## 🎮 Real-World Examples
179+
180+
### Example: E-commerce Discount
181+
```python
182+
total = 150
183+
is_member = True
184+
has_coupon = False
185+
186+
# Member discount OR coupon discount
187+
if (total >= 100 and is_member) or has_coupon:
188+
discount = total * 0.20
189+
final_price = total - discount
190+
print(f"Discount applied! Final price: ${final_price}")
191+
else:
192+
print(f"Total: ${total}")
193+
```
194+
195+
### Example: Security System
196+
```python
197+
is_armed = True
198+
is_door_open = True
199+
is_night = True
200+
has_motion = False
201+
202+
if is_armed and (is_door_open or (is_night and has_motion)):
203+
print("🚨 ALERT! Intrusion detected!")
204+
else:
205+
print("✓ System normal")
206+
```
207+
208+
## 🚀 Challenge Projects
209+
210+
1. **Smart Thermostat**: Turn on AC if (temp > 75 and is_home) or override_on
211+
2. **Library Fine Calculator**: Fine if overdue AND (not is_student OR days > 7)
212+
3. **Flight Booking**: Available if (seats > 0) and (has_passport or is_domestic)
213+
4. **Game Level Unlock**: Unlock if (score >= 1000 and level >= 5) or has_premium
214+
215+
## 🎓 Key Takeaways from Video
216+
217+
1. Conditionals execute code based on conditions
218+
2. Use if-elif-else for conditional logic
219+
3. Follow along with the video for hands-on practice
220+
221+
> 💡 *These points cover the main concepts from the video tutorial to help reinforce your learning.*
222+
223+
## 🔗 Next Chapter
224+
Continue to [Chapter 12: Conditional Expressions](12-conditional.md) to learn shorthand if-else statements!
225+

0 commit comments

Comments
 (0)