mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2025-12-25 02:14:11 -05:00
feat(curriculum): add content to python chapter review (#62440)
This commit is contained in:
@@ -38,7 +38,7 @@ print('Integer:', my_integer_var) # Integer: 10
|
||||
|
||||
```python
|
||||
my_float_var = 4.50
|
||||
print('Float:', my_float_var) # Float 4.50
|
||||
print('Float:', my_float_var) # Float: 4.50
|
||||
```
|
||||
|
||||
- Complex: A number with a real and imaginary part, like `6 + 7j`.
|
||||
|
||||
@@ -603,6 +603,7 @@ for index, language in enumerate(languages):
|
||||
languages = ['Spanish', 'English', 'Russian', 'Chinese']
|
||||
|
||||
print(list(enumerate(languages)))
|
||||
# [(0, 'Spanish'), (1, 'English'), (2, 'Russian'), (3, 'Chinese')]
|
||||
```
|
||||
|
||||
- The `enumerate()` function also accepts an optional `start` argument that specifies the starting value for the count. If this argument is omitted, then the count will begin at `0`.
|
||||
|
||||
@@ -42,7 +42,7 @@ age = 25
|
||||
# This is a single line comment
|
||||
```
|
||||
|
||||
- **Multi-line Strings**: These types of strings can be used to leave larger notes or to comment out sections of code
|
||||
- **Multi-line Strings**: These types of strings can be used to leave larger notes or to comment out sections of code.
|
||||
|
||||
```py
|
||||
"""
|
||||
@@ -74,7 +74,7 @@ print('Integer:', my_integer_var) # Integer: 10
|
||||
|
||||
```py
|
||||
my_float_var = 4.50
|
||||
print('Float:', my_float_var) # Float 4.50
|
||||
print('Float:', my_float_var) # Float: 4.50
|
||||
```
|
||||
|
||||
- **Complex**: A number with a real and imaginary part:
|
||||
@@ -288,7 +288,7 @@ replaced_my_str = greeting.replace('hello', 'hi')
|
||||
print(replaced_my_str) # 'hi world'
|
||||
```
|
||||
|
||||
- **`str.split()`**: This is used to split a string into a list using a specified separator. A separator is a string specifying where the split should happen.
|
||||
- **`split()`**: This is used to split a string into a list using a specified separator. A separator is a string specifying where the split should happen.
|
||||
|
||||
```py
|
||||
dashed_name = 'example-dashed-name'
|
||||
@@ -297,7 +297,7 @@ split_words = dashed_name.split('-')
|
||||
print(split_words) # ['example', 'dashed', 'name']
|
||||
```
|
||||
|
||||
- **`str.join()`**: This is used to join elements of an iterable into a string with a separator. An iterable is a collection of elements that can be looped over like a list, string or a tuple.
|
||||
- **`join()`**: This is used to join elements of an iterable into a string with a separator. An iterable is a collection of elements that can be looped over like a list, string or a tuple.
|
||||
|
||||
```py
|
||||
example_list = ['example', 'dashed', 'name']
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user