Skip to content

Commit e2fe476

Browse files
fix(curriculum): restructure python basics module (freeCodeCamp#64700)
Co-authored-by: majestic-owl448 <26656284+majestic-owl448@users.noreply.github.com>
1 parent b8e09e3 commit e2fe476

28 files changed

Lines changed: 817 additions & 472 deletions

File tree

client/i18n/locales/english/intro.json

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6715,7 +6715,35 @@
67156715
"lecture-introduction-to-python": {
67166716
"title": "Introduction to Python",
67176717
"intro": [
6718-
"In these lessons, you will learn the fundamentals of Python. You'll learn about variables, data types, operators, control flow, functions, and more."
6718+
"In these lessons, you will learn what Python is, how to set up your development environment."
6719+
]
6720+
},
6721+
"lecture-understanding-variables-and-data-types": {
6722+
"title": "Understanding Variables and Data Types",
6723+
"intro": [
6724+
"In these lessons, you will learn about variables and data types in Python."
6725+
]
6726+
},
6727+
"lecture-introduction-to-python-strings": {
6728+
"title": "Introduction to Strings",
6729+
"intro": ["In these lessons, you will learn about strings in Python."]
6730+
},
6731+
"lecture-numbers-and-mathematical-operations": {
6732+
"title": "Numbers and Mathematical Operations",
6733+
"intro": [
6734+
"In these lessons, you will learn about numbers and mathematical operations in Python."
6735+
]
6736+
},
6737+
"lecture-booleans-and-conditionals": {
6738+
"title": "Booleans and Conditionals",
6739+
"intro": [
6740+
"In these lessons, you will learn about booleans and conditionals in Python."
6741+
]
6742+
},
6743+
"lecture-understanding-functions-and-scope": {
6744+
"title": "Understanding Functions and Scope",
6745+
"intro": [
6746+
"In these lessons, you will learn about functions and scope in Python."
67196747
]
67206748
},
67216749
"workshop-caesar-cipher": {
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
title: Introduction to the Booleans and Conditionals
3+
block: lecture-booleans-and-conditionals
4+
superBlock: python-v9
5+
---
6+
7+
## Introduction to the Booleans and Conditionals
8+
9+
In these lessons, you will learn about booleans and conditionals in Python.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
title: Introduction to the Introduction to Strings
3+
block: lecture-introduction-to-python-strings
4+
superBlock: python-v9
5+
---
6+
7+
## Introduction to the Introduction to Strings
8+
9+
In these lessons, you will learn about strings in Python.

client/src/pages/learn/full-stack-developer/lecture-introduction-to-python/index.md renamed to client/src/pages/learn/python-v9/lecture-introduction-to-python/index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
---
22
title: Introduction to Introduction to Python
33
block: lecture-introduction-to-python
4-
superBlock: full-stack-developer
4+
superBlock: python-v9
55
---
66

77
## Introduction to Introduction to Python
88

9-
Learn about Introduction to Python in these lessons.
9+
In these lessons, you will learn what Python is, how to set up your development environment.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
title: Introduction to the Numbers and Mathematical Operations
3+
block: lecture-numbers-and-mathematical-operations
4+
superBlock: python-v9
5+
---
6+
7+
## Introduction to the Numbers and Mathematical Operations
8+
9+
In these lessons, you will learn about numbers and mathematical operations in Python.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
title: Introduction to the Understanding Functions and Scope
3+
block: lecture-understanding-functions-and-scope
4+
superBlock: python-v9
5+
---
6+
7+
## Introduction to the Understanding Functions and Scope
8+
9+
In these lessons, you will learn about functions and scope in Python.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
title: Introduction to the Understanding Variables and Data Types
3+
block: lecture-understanding-variables-and-data-types
4+
superBlock: python-v9
5+
---
6+
7+
## Introduction to the Understanding Variables and Data Types
8+
9+
In these lessons, you will learn about variables and data types in Python.

curriculum/challenges/english/blocks/lecture-introduction-to-python/67fe85a3db9bad35f2b6a2bd.md renamed to curriculum/challenges/english/blocks/lecture-booleans-and-conditionals/67fe85a3db9bad35f2b6a2bd.md

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,17 +42,18 @@ In Python, the most basic conditional is the `if` statement. Here's the basic sy
4242

4343
```python
4444
if condition:
45-
# Code to execute if condition is True
45+
pass # Code to execute if condition is True
4646
```
4747

4848
* `if` statements start with the `if` keyword.
4949

5050
* `condition` is an expression that evaluates to `True` or `False`, followed by a colon (`:`).
5151

52-
* The indentation specifies the block of code within the body of the `if` statement.
52+
* The body of the `if` statement constitutes a <dfn>code block</dfn>, which is a group of statements that belong together. In Python, the level of indentation is what defines a code block.
5353

54+
In the example above, the body of the `if` statement contains a `pass` statement. When a `pass` statement is executed, nothing happens. This is a special keyword that can be used as a placeholder for future code and it is useful when empty code blocks are not allowed.
5455

55-
And here's an example:
56+
The code within the body of the `if` statement runs only when the condition evaluates to `True`. For example:
5657

5758
```python
5859
age = 18
@@ -61,7 +62,22 @@ if age >= 18:
6162
print('You are an adult') # You are an adult
6263
```
6364

64-
But if `age` is anything less than `18`, nothing is printed in the terminal:
65+
Notice the indentation before `print('You are an adult')`. While other programming languages use characters like curly braces to define code blocks, and just use indentation for readability, in Python, code blocks are determined by indentation.
66+
67+
The following code would raise an `IndentationError`, which is Python's way to signal that indentation is required at a certain point of the code:
68+
69+
```py
70+
age = 18
71+
72+
if age >= 18:
73+
print('You are an adult') # IndentationError: expected an indented block after 'if' statement on line 3
74+
```
75+
76+
Though you can use any number spaces (as long as you are consistent) to determine each level of indentation, the Python style guide recommends using four spaces.
77+
78+
Blocks are also found in loops and functions, which you'll learn about in future lessons.
79+
80+
Going back to our example, if `age` is anything less than `18`, nothing is printed in the terminal:
6581

6682
```python
6783
age = 12
@@ -74,9 +90,9 @@ But what if you also want to print something if `age` is less than `18`? That's
7490

7591
```python
7692
if condition:
77-
# Code to execute if condition is True
93+
pass # Code to execute if condition is True
7894
else:
79-
# Code to execute if condition is False
95+
pass # Code to execute if condition is False
8096
```
8197

8298
For example:
@@ -96,11 +112,11 @@ Here's the syntax:
96112

97113
```python
98114
if condition:
99-
# Code to execute if condition is True
115+
pass # Code to execute if condition is True
100116
elif condition2:
101-
# Code to execute if condition2 is True
117+
pass # Code to execute if condition2 is True
102118
else:
103-
# Code to execute if all conditions are False
119+
pass # Code to execute if all conditions are False
104120
```
105121

106122
For example:

curriculum/challenges/english/blocks/lecture-introduction-to-python/68480f431e8568b2056b140b.md renamed to curriculum/challenges/english/blocks/lecture-booleans-and-conditionals/68480f431e8568b2056b140b.md

File renamed without changes.

curriculum/challenges/english/blocks/lecture-introduction-to-python/6839b2ddd01ef657b6bf3b76.md renamed to curriculum/challenges/english/blocks/lecture-introduction-to-python-strings/6839b2ddd01ef657b6bf3b76.md

File renamed without changes.

0 commit comments

Comments
 (0)