feat(curriculum): add steps for report card printer workshop (#64801)

Co-authored-by: majestic-owl448 <26656284+majestic-owl448@users.noreply.github.com>
Co-authored-by: Dario <105294544+Dario-DC@users.noreply.github.com>
Co-authored-by: Zaira <33151350+zairahira@users.noreply.github.com>
This commit is contained in:
Phyu Sin Shin Thant
2026-01-20 23:01:02 +08:00
committed by GitHub
parent 7fe7e8e1d4
commit 028844450c
13 changed files with 475 additions and 0 deletions
+6
View File
@@ -6928,6 +6928,12 @@
"In these lessons, you will learn about variables and data types in Python."
]
},
"workshop-report-card-printer": {
"title": "Build a Report Card Printer",
"intro": [
"In this workshop, you will build a report card printer to work with primitive data types in Python."
]
},
"lecture-introduction-to-python-strings": {
"title": "Introduction to Strings",
"intro": ["In these lessons, you will learn about strings in Python."]
@@ -0,0 +1,9 @@
---
title: Introduction to the Build a Report Card Printer
block: workshop-report-card-printer
superBlock: python-v9
---
## Introduction to the Build a Report Card Printer
In this workshop, you will be declaring a few variables, and work with `type()` and `isinstance()` functions to check the data type of those variables.
@@ -0,0 +1,46 @@
---
id: 69461e4f98594012939bc1c6
title: Step 1
challengeType: 20
dashedName: step-1
---
# --description--
In this workshop, you will practice Python data types by building a simple report card printer.
As you learned in previous lessons, variables are assigned in this way:
```py
greeting = 'Hello World'
```
In the example above, the variable `greeting` has the value of a string, which is a sequence of characters surrounded by quotes.
Create a variable called `name` and assign it the string `Alice`. Remember to surround the value with either single or double quotes as shown in the example.
**Important:** Python uses indentation (the spaces at the beginning of a line) to organize code. For this workshop, make sure there are no extra spaces at the start of each line of code. Adding extra spaces will cause an `IndentationError` and prevent your code from running.
# --hints--
You should have a `name` variable.
```js
({ test: () => runPython(`assert _Node(_code).has_variable('name')`) })
```
The variable `name` should store the value `'Alice'`.
```js
({ test: () => runPython(`assert _Node(_code).find_variable("name").is_equivalent("name = 'Alice'")`) })
```
# --seed--
## --seed-contents--
```py
--fcc-editable-region--
--fcc-editable-region--
```
@@ -0,0 +1,41 @@
---
id: 694648abde178bb8202d9511
title: Step 3
challengeType: 20
dashedName: step-3
---
# --description--
You should now see the student name printed in the terminal.
Python provides a function named `type()` that you can use to check the type of a value.
```py
platform = 'freeCodeCamp'
print(type(platform)) # Output: <class 'str'>
```
In the example above, the output `<class 'str'>` means that the variable passed to the `type()` function is a string.
Use the `type()` function with `name` as its argument and print the output like the example. Check the output in the terminal that shows `name` is of the type `str` (string).
# --hints--
You should print the result of calling `type(name)`.
```js
({ test: () => runPython(`assert _Node(_code).has_call("print(type(name))")`) })
```
# --seed--
## --seed-contents--
```py
name = 'Alice'
print(name)
--fcc-editable-region--
--fcc-editable-region--
```
@@ -0,0 +1,42 @@
---
id: 694648acde178bb8202d9512
title: Step 4
challengeType: 20
dashedName: step-4
---
# --description--
The report card should also show whether the student is currently enrolled. This can be represented using a boolean value.
Boolean values represent a yes-or-no condition, and they are often used to make decisions in code. There are only two boolean values: `True` and `False`.
Declare a variable named `is_student` and assign it the value `True`.
# --hints--
You should have an `is_student` variable.
```js
({ test: () => runPython(`assert _Node(_code).has_variable("is_student")`) })
```
The variable `is_student` should store the value `True`. Do not surround the value with quotes.
```js
({ test: () => runPython(`assert _Node(_code).find_variable("is_student").is_equivalent("is_student = True")`) })
```
# --seed--
## --seed-contents--
```py
name = 'Alice'
print(name)
print(type(name))
--fcc-editable-region--
--fcc-editable-region--
```
@@ -0,0 +1,47 @@
---
id: 694648acde178bb8202d9513
title: Step 6
challengeType: 20
dashedName: step-6
---
# --description--
The student name should follow the same format as the other details.
Remove the earlier outputs of the `name` variable. Then, print `name` and `type(name)` together on one line separated by a comma like the previous step.
# --hints--
You should not have `print(name)` in your code.
```js
({ test: () => runPython(`assert not _Node(_code).has_call("print(name)")`)})
```
You should not have `print(type(name))` in your code.
```js
({ test: () => runPython(`assert not _Node(_code).has_call("print(type(name))")`)})
```
You should print `name` and `type(name)` in the same `print()` call using a comma separator.
```js
({ test: () => runPython(`assert _Node(_code).has_call("print(name, type(name))")`) })
```
# --seed--
## --seed-contents--
```py
name = 'Alice'
--fcc-editable-region--
print(name)
print(type(name))
--fcc-editable-region--
is_student = True
print(is_student, type(is_student))
```
@@ -0,0 +1,51 @@
---
id: 694648acde178bb8202d9514
title: Step 7
challengeType: 20
dashedName: step-7
---
# --description--
Now you need to add the student's age to the report card. For that you'll use an integer, one of the numeric data types in Python.
Declare a variable named `age` and assign it the integer value `20`.
Then, print the value and data type of `age` together separated by a comma. Check the output in the terminal that shows the value of `age`, and its type as `int` (integer).
# --hints--
You should have an `age` variable.
```js
({ test: () => runPython(`assert _Node(_code).has_variable("age")`) })
```
The variable `age` should store the value `20`. Do not surround the value with quotes.
```js
({ test: () => runPython(`assert _Node(_code).find_variable("age").is_equivalent("age = 20")`) })
```
You should print `age` and `type(age)` using a comma separator.
```js
({ test: () => runPython(`assert _Node(_code).has_call("print(age, type(age))")`) })
```
# --seed--
## --seed-contents--
```py
name = 'Alice'
print(name, type(name))
is_student = True
print(is_student, type(is_student))
--fcc-editable-region--
--fcc-editable-region--
```
@@ -0,0 +1,61 @@
---
id: 694648acde178bb8202d9515
title: Step 8
challengeType: 20
dashedName: step-8
---
# --description--
Now, add the student's score.
Declare a variable named `score` and assign it the value `80.5`.
Although both `age` and `score` are numbers, they may not be the same kind. Python provides a function called `isinstance()` to check this.
```py
x = 10
print(isinstance(x, int)) # Output: True
```
Use `isinstance()` to check whether `score` is an `int`, and print the result to the terminal as shown in the example above.
# --hints--
You should have a `score` variable.
```js
({ test: () => runPython(`assert _Node(_code).has_variable("score")`) })
```
The variable `score` should store the value `80.5`. Do not surround the value with quotes.
```js
({ test: () => runPython(`assert _Node(_code).find_variable("score").is_equivalent("score = 80.5")`) })
```
You should print the result of `isinstance(score, int)`.
```js
({ test: () => runPython(`assert _Node(_code).has_call("print(isinstance(score, int))")`) })
```
# --seed--
## --seed-contents--
```py
name = 'Alice'
print(name, type(name))
is_student = True
print(is_student, type(is_student))
age = 20
print(age, type(age))
--fcc-editable-region--
--fcc-editable-region--
```
@@ -0,0 +1,70 @@
---
id: 694648acde178bb8202d9516
title: Step 9
challengeType: 20
dashedName: step-9
---
# --description--
The output is `False`, which shows that `score` is not an `int`.
Another common kind of number in Python is `float`, which represents a number with decimals. Replace `int` with `float` in the existing `isinstance()` call to confirm this.
Finally, print `score` and its data type to complete the report card.
# --hints--
You should replace `int` with `float` in the existing `isinstance(score, int)` call.
```js
({ test: () => runPython(`
assert not _Node(_code).has_call("print(isinstance(score, int))")
assert _Node(_code).has_call("print(isinstance(score, float))")
`) })
```
You should print `score` and `type(score)` using a comma separator.
```js
({ test: () => runPython(`assert _Node(_code).has_call("print(score, type(score))")`) })
```
# --seed--
## --seed-contents--
```py
name = 'Alice'
print(name, type(name))
is_student = True
print(is_student, type(is_student))
age = 20
print(age, type(age))
score = 80.5
--fcc-editable-region--
print(isinstance(score, int))
--fcc-editable-region--
```
# --solutions--
```py
name = 'Alice'
print(name, type(name))
is_student = True
print(is_student, type(is_student))
age = 20
print(age, type(age))
score = 80.5
print(isinstance(score, float))
print(score, type(score))
```
@@ -0,0 +1,40 @@
---
id: 6947a0c2b6de035dd8d3eea1
title: Step 2
challengeType: 20
dashedName: step-2
---
# --description--
You can print the value of a variable using the `print()` function.
```py
greeting = 'Hello World'
print(greeting) # Output: Hello World
```
You will learn more about functions in upcoming lessons. For now, know that a function is a reusable block of code that can be called, or invoked, to run its code, and arguments can be passed to it.
In the example above, `print(greeting)` is a function call, and `greeting` is the argument of the function.
Refer to the example and print the `name` variable. Check the output in the terminal.
# --hints--
You should call `print()` with `name` as its argument.
```js
({ test: () => runPython(`assert _Node(_code).has_call("print(name)")`) })
```
# --seed--
## --seed-contents--
```py
name = 'Alice'
--fcc-editable-region--
--fcc-editable-region--
```
@@ -0,0 +1,40 @@
---
id: 6947a3e516bb8a4a681274a7
title: Step 5
challengeType: 20
dashedName: step-5
---
# --description--
The `print()` function can display more than one value at a time. Separate values with a comma (`,`) to print them on the same line.
```py
subject = 'Python'
print(subject, type(subject)) # Output: Python <class 'str'>
```
Print both `is_student` and `type(is_student)` on the same line using a comma `,` as shown in the example. Then, check the output in the terminal that shows the value of `is_student`, and its type as `bool` (boolean).
# --hints--
You should print `is_student` and `type(is_student)` using a comma separator.
```js
({ test: () => runPython(`assert _Node(_code).has_call("print(is_student, type(is_student))")`) })
```
# --seed--
## --seed-contents--
```py
name = 'Alice'
print(name)
print(type(name))
is_student = True
--fcc-editable-region--
--fcc-editable-region--
```
@@ -0,0 +1,21 @@
{
"name": "Build a Report Card Printer",
"isUpcomingChange": false,
"dashedName": "workshop-report-card-printer",
"helpCategory": "Python",
"blockLayout": "challenge-grid",
"challengeOrder": [
{ "id": "69461e4f98594012939bc1c6", "title": "Step 1" },
{ "id": "6947a0c2b6de035dd8d3eea1", "title": "Step 2" },
{ "id": "694648abde178bb8202d9511", "title": "Step 3" },
{ "id": "694648acde178bb8202d9512", "title": "Step 4" },
{ "id": "6947a3e516bb8a4a681274a7", "title": "Step 5" },
{ "id": "694648acde178bb8202d9513", "title": "Step 6" },
{ "id": "694648acde178bb8202d9514", "title": "Step 7" },
{ "id": "694648acde178bb8202d9515", "title": "Step 8" },
{ "id": "694648acde178bb8202d9516", "title": "Step 9" }
],
"blockLabel": "workshop",
"usesMultifileEditor": true,
"hasEditableBoundaries": true
}
@@ -8,6 +8,7 @@
"blocks": [
"lecture-introduction-to-python",
"lecture-understanding-variables-and-data-types",
"workshop-report-card-printer",
"lecture-introduction-to-python-strings",
"lecture-numbers-and-mathematical-operations",
"lecture-booleans-and-conditionals",