From 229635e880708a409a19899648dfb87609e02dd5 Mon Sep 17 00:00:00 2001 From: Ritam Pal Date: Mon, 9 Feb 2026 22:18:03 +0530 Subject: [PATCH] feat(curriculum): add steps for employee profile generator workshop (#64896) Co-authored-by: Ritam Pal Co-authored-by: Dario <105294544+Dario-DC@users.noreply.github.com> --- client/i18n/locales/english/intro.json | 6 ++ .../694bf3af05d10fd89dab05cc.md | 51 ++++++++++ .../694bf6ea530e19a9c48c59f0.md | 36 +++++++ .../694bf6eb530e19a9c48c59f1.md | 48 +++++++++ .../694bf6eb530e19a9c48c59f2.md | 43 ++++++++ .../694bf6eb530e19a9c48c59f3.md | 64 ++++++++++++ .../694bf6eb530e19a9c48c59f4.md | 54 ++++++++++ .../694bf6eb530e19a9c48c59f5.md | 80 +++++++++++++++ .../694bf6eb530e19a9c48c59f6.md | 83 ++++++++++++++++ .../694bf6eb530e19a9c48c59f7.md | 98 +++++++++++++++++++ .../695c96f82af4fb78e59fa9ed.md | 65 ++++++++++++ .../695c9c7c61d446f1451e0ae7.md | 47 +++++++++ .../695c9f21a8b1d53cf1b97841.md | 41 ++++++++ .../695df6480de23758af5a29cd.md | 45 +++++++++ .../695ea1e55c0e619e597fc5c9.md | 43 ++++++++ .../695fcfbba648b3a96a9495a4.md | 38 +++++++ .../695fd3dde03273875e5d6709.md | 37 +++++++ .../69727ea5c9606bedfe36d3d2.md | 76 ++++++++++++++ .../6980d3ecfe800d8a54130f30.md | 41 ++++++++ .../workshop-employee-profile-generator.json | 30 ++++++ .../structure/superblocks/python-v9.json | 1 + 21 files changed, 1027 insertions(+) create mode 100644 curriculum/challenges/english/blocks/workshop-employee-profile-generator/694bf3af05d10fd89dab05cc.md create mode 100644 curriculum/challenges/english/blocks/workshop-employee-profile-generator/694bf6ea530e19a9c48c59f0.md create mode 100644 curriculum/challenges/english/blocks/workshop-employee-profile-generator/694bf6eb530e19a9c48c59f1.md create mode 100644 curriculum/challenges/english/blocks/workshop-employee-profile-generator/694bf6eb530e19a9c48c59f2.md create mode 100644 curriculum/challenges/english/blocks/workshop-employee-profile-generator/694bf6eb530e19a9c48c59f3.md create mode 100644 curriculum/challenges/english/blocks/workshop-employee-profile-generator/694bf6eb530e19a9c48c59f4.md create mode 100644 curriculum/challenges/english/blocks/workshop-employee-profile-generator/694bf6eb530e19a9c48c59f5.md create mode 100644 curriculum/challenges/english/blocks/workshop-employee-profile-generator/694bf6eb530e19a9c48c59f6.md create mode 100644 curriculum/challenges/english/blocks/workshop-employee-profile-generator/694bf6eb530e19a9c48c59f7.md create mode 100644 curriculum/challenges/english/blocks/workshop-employee-profile-generator/695c96f82af4fb78e59fa9ed.md create mode 100644 curriculum/challenges/english/blocks/workshop-employee-profile-generator/695c9c7c61d446f1451e0ae7.md create mode 100644 curriculum/challenges/english/blocks/workshop-employee-profile-generator/695c9f21a8b1d53cf1b97841.md create mode 100644 curriculum/challenges/english/blocks/workshop-employee-profile-generator/695df6480de23758af5a29cd.md create mode 100644 curriculum/challenges/english/blocks/workshop-employee-profile-generator/695ea1e55c0e619e597fc5c9.md create mode 100644 curriculum/challenges/english/blocks/workshop-employee-profile-generator/695fcfbba648b3a96a9495a4.md create mode 100644 curriculum/challenges/english/blocks/workshop-employee-profile-generator/695fd3dde03273875e5d6709.md create mode 100644 curriculum/challenges/english/blocks/workshop-employee-profile-generator/69727ea5c9606bedfe36d3d2.md create mode 100644 curriculum/challenges/english/blocks/workshop-employee-profile-generator/6980d3ecfe800d8a54130f30.md create mode 100644 curriculum/structure/blocks/workshop-employee-profile-generator.json diff --git a/client/i18n/locales/english/intro.json b/client/i18n/locales/english/intro.json index b507eed6669..09094c4c97c 100644 --- a/client/i18n/locales/english/intro.json +++ b/client/i18n/locales/english/intro.json @@ -3657,6 +3657,12 @@ "title": "Introduction to Strings", "intro": ["In these lessons, you will learn about strings in Python."] }, + "workshop-employee-profile-generator": { + "title": "Build an Employee Profile Generator", + "intro": [ + "In this workshop, you will practice the fundamentals of string manipulation in Python by building a tool that generates formatted employee badges and analyzes employee codes." + ] + }, "lecture-numbers-and-mathematical-operations": { "title": "Numbers and Mathematical Operations", "intro": [ diff --git a/curriculum/challenges/english/blocks/workshop-employee-profile-generator/694bf3af05d10fd89dab05cc.md b/curriculum/challenges/english/blocks/workshop-employee-profile-generator/694bf3af05d10fd89dab05cc.md new file mode 100644 index 00000000000..6ce3d4c43a2 --- /dev/null +++ b/curriculum/challenges/english/blocks/workshop-employee-profile-generator/694bf3af05d10fd89dab05cc.md @@ -0,0 +1,51 @@ +--- +id: 694bf3af05d10fd89dab05cc +title: Step 2 +challengeType: 20 +dashedName: step-2 +--- + +# --description-- + +In Python, you can combine strings using the `+` operator. This is called concatenation. Here is an example: + +```python +greeting = 'Hello' + 'World' +print(greeting) # Output: HelloWorld +``` + +Create a variable `full_name` by concatenating `first_name` and `last_name`. Then print `full_name`. + +# --hints-- + +You should have a variable named `full_name`. + +```js +({ test: () => assert(runPython(`_Node(_code).has_variable("full_name")`)) }) +``` + +You should assign a string formed by concatenating `first_name` and `last_name` to your `full_name` variable. + +```js +({ test: () => assert(runPython(`_Node(_code).find_variable("full_name").is_equivalent("full_name = first_name + last_name")`)) }) +``` + +You should print the `full_name` variable. + +```js +({ test: () => assert(runPython(`_Node(_code).has_call("print(full_name)")`)) }) +``` + +# --seed-- + +## --seed-contents-- + +```python +first_name = 'John' +last_name = 'Doe' +print(first_name) +print(last_name) +--fcc-editable-region-- + +--fcc-editable-region-- +``` diff --git a/curriculum/challenges/english/blocks/workshop-employee-profile-generator/694bf6ea530e19a9c48c59f0.md b/curriculum/challenges/english/blocks/workshop-employee-profile-generator/694bf6ea530e19a9c48c59f0.md new file mode 100644 index 00000000000..29f076608cb --- /dev/null +++ b/curriculum/challenges/english/blocks/workshop-employee-profile-generator/694bf6ea530e19a9c48c59f0.md @@ -0,0 +1,36 @@ +--- +id: 694bf6ea530e19a9c48c59f0 +title: Step 3 +challengeType: 20 +dashedName: step-3 +--- + +# --description-- + +If you concatenate two strings like `'John' + 'Doe'`, the result is `'JohnDoe'` with no space. To fix this, you need to concatenate a string containing a space (`' '`) between them. + + +Update your `full_name` variable so it concatenates `first_name`, a space, and `last_name`. + +# --hints-- + +You should add a space (`' '`) between `first_name` and `last_name`. + +```js +({ test: () => assert(runPython(`_Node(_code).find_variable("full_name").is_equivalent("full_name = first_name + ' ' + last_name")`)) }) +``` + +# --seed-- + +## --seed-contents-- + +```python +first_name = 'John' +last_name = 'Doe' +print(first_name) +print(last_name) +--fcc-editable-region-- +full_name = first_name + last_name +--fcc-editable-region-- +print(full_name) +``` diff --git a/curriculum/challenges/english/blocks/workshop-employee-profile-generator/694bf6eb530e19a9c48c59f1.md b/curriculum/challenges/english/blocks/workshop-employee-profile-generator/694bf6eb530e19a9c48c59f1.md new file mode 100644 index 00000000000..007dd45ea33 --- /dev/null +++ b/curriculum/challenges/english/blocks/workshop-employee-profile-generator/694bf6eb530e19a9c48c59f1.md @@ -0,0 +1,48 @@ +--- +id: 694bf6eb530e19a9c48c59f1 +title: Step 5 +challengeType: 20 +dashedName: step-5 +--- + +# --description-- + +Now, your address seems incomplete. You also want to add the apartment number where the employee lives, so you should modify the variable. + +When you want to add content to the end of an existing string variable, you can use the **augmented assignment** operator ,`+=`. This is shorter than writing `var = var + 'new text'`. For example: + +```py +greeting = 'Hello' +greeting += ' World' +print(greeting) # Hello World +``` + +Remember that strings are immutable, therefore this operation does not change the original string. Instead it creates a new string and reassigns it to the variable. + +Use the `+=` operator to add the string `, Apartment 4B` to your `address` variable. + +# --hints-- + +You should use the `+=` operator to add the string `, Apartment 4B` to the `address` variable. + +```js +({ test: () => assert(runPython(`_Node(_code).find_aug_variable("address").is_equivalent("address += ', Apartment 4B'")`)) }) +``` + +# --seed-- + +## --seed-contents-- + +```python +first_name = 'John' +last_name = 'Doe' +print(first_name) +print(last_name) +full_name = first_name + ' ' + last_name +print(full_name) +address = '123 Main Street' +--fcc-editable-region-- + +--fcc-editable-region-- +print(address) +``` diff --git a/curriculum/challenges/english/blocks/workshop-employee-profile-generator/694bf6eb530e19a9c48c59f2.md b/curriculum/challenges/english/blocks/workshop-employee-profile-generator/694bf6eb530e19a9c48c59f2.md new file mode 100644 index 00000000000..5681514506e --- /dev/null +++ b/curriculum/challenges/english/blocks/workshop-employee-profile-generator/694bf6eb530e19a9c48c59f2.md @@ -0,0 +1,43 @@ +--- +id: 694bf6eb530e19a9c48c59f2 +title: Step 11 +challengeType: 20 +dashedName: step-11 +--- + +# --description-- + +Now complete the sentence by concatenating the string ` years old` to the end of `employee_info`. Remember to include a space at the beginning of your string. + +Finally, print `employee_info`. + +# --hints-- + +You should concatenate `' years old'` to the end of the `employee_info` variable. + +```js +({ test: () => assert(runPython(`_Node(_code).find_variable("employee_info").is_equivalent("employee_info = full_name + ' is ' + str(employee_age) + ' years old'")`)) }) +``` + +You should print `employee_info`. + +```js +({ test: () => assert(runPython(`_Node(_code).has_call("print(employee_info)")`)) }) +``` + +# --seed-- + +## --seed-contents-- + +```py +first_name = 'John' +last_name = 'Doe' +full_name = first_name + ' ' + last_name +address = '123 Main Street' +address += ', Apartment 4B' +employee_age = 28 +--fcc-editable-region-- +employee_info = full_name + ' is ' + str(employee_age) + +--fcc-editable-region-- +``` diff --git a/curriculum/challenges/english/blocks/workshop-employee-profile-generator/694bf6eb530e19a9c48c59f3.md b/curriculum/challenges/english/blocks/workshop-employee-profile-generator/694bf6eb530e19a9c48c59f3.md new file mode 100644 index 00000000000..f657a833176 --- /dev/null +++ b/curriculum/challenges/english/blocks/workshop-employee-profile-generator/694bf6eb530e19a9c48c59f3.md @@ -0,0 +1,64 @@ +--- +id: 694bf6eb530e19a9c48c59f3 +title: Step 12 +challengeType: 20 +dashedName: step-12 +--- + +# --description-- + +Now you're going to use the `str()` function one more time. Just like with age, you must convert any numeric variable to a string before concatenating it with other text. + +Create a variable named `experience_years` and assign it the integer `5`. + +Then, create a variable `experience_info`. Assign it a string formed by concatenating `'Experience: '`, the `experience_years` variable (converted to a string), and `' years'`. Print the result to the terminal. + +# --hints-- + +You should have a variable named `experience_years`. + +```js +({ test: () => assert(runPython(`_Node(_code).has_variable("experience_years")`)) }) +``` + +You should assign the integer `5` to your `experience_years` variable. + +```js +({ test: () => assert(runPython(`_Node(_code).find_variable("experience_years").is_equivalent("experience_years = 5")`)) }) +``` + +You should have a variable named `experience_info`. + +```js +({ test: () => assert(runPython(`_Node(_code).has_variable("experience_info")`)) }) +``` + +You should assign a string formed by concatenating `'Experience: '`, `str(experience_years)`, and `' years'` to your `experience_info` variable. + +```js +({ test: () => assert(runPython(`_Node(_code).find_variable("experience_info").is_equivalent("experience_info = 'Experience: ' + str(experience_years) + ' years'")`)) }) +``` + +You should print `experience_info`. + +```js +({ test: () => assert(runPython(`_Node(_code).has_call("print(experience_info)")`)) }) +``` + +# --seed-- + +## --seed-contents-- + +```python +first_name = 'John' +last_name = 'Doe' +full_name = first_name + ' ' + last_name +address = '123 Main Street' +address += ', Apartment 4B' +employee_age = 28 +employee_info = full_name + ' is ' + str(employee_age) + ' years old' +print(employee_info) +--fcc-editable-region-- + +--fcc-editable-region-- +``` diff --git a/curriculum/challenges/english/blocks/workshop-employee-profile-generator/694bf6eb530e19a9c48c59f4.md b/curriculum/challenges/english/blocks/workshop-employee-profile-generator/694bf6eb530e19a9c48c59f4.md new file mode 100644 index 00000000000..a418f08b56d --- /dev/null +++ b/curriculum/challenges/english/blocks/workshop-employee-profile-generator/694bf6eb530e19a9c48c59f4.md @@ -0,0 +1,54 @@ +--- +id: 694bf6eb530e19a9c48c59f4 +title: Step 13 +challengeType: 20 +dashedName: step-13 +--- + +# --description-- + +Concatenating many strings using `+` and converting numbers using `str()` can get messy and hard to read. + +Python 3.6 introduced **f-strings** to solve this. By adding the letter `f` before the opening quote, you can put variables and expressions inside replacement fields represented represented by curly braces `{}`. For example: + +```python +name = 'John' +print(f'Hello {name}') # Output: Hello John +``` + +Create a variable `employee_card` and assign it an f-string that displays `Employee:` followed by a space and the value of the `full_name` variable. + +# --hints-- + +You should have a variable named `employee_card`. + +```js +({ test: () => assert(runPython(`_Node(_code).has_variable("employee_card")`)) }) +``` + +Your `employee_card` variable should have the value `f'Employee: {full_name}'`. + +```js +({ test: () => assert(runPython(`_Node(_code).find_variable("employee_card").is_equivalent("employee_card = f'Employee: {full_name}'")`)) }) +``` + +# --seed-- + +## --seed-contents-- + +```python +first_name = 'John' +last_name = 'Doe' +full_name = first_name + ' ' + last_name +address = '123 Main Street' +address += ', Apartment 4B' +employee_age = 28 +employee_info = full_name + ' is ' + str(employee_age) + ' years old' +print(employee_info) +experience_years = 5 +experience_info = 'Experience: ' + str(experience_years) + ' years' +print(experience_info) +--fcc-editable-region-- + +--fcc-editable-region-- +``` diff --git a/curriculum/challenges/english/blocks/workshop-employee-profile-generator/694bf6eb530e19a9c48c59f5.md b/curriculum/challenges/english/blocks/workshop-employee-profile-generator/694bf6eb530e19a9c48c59f5.md new file mode 100644 index 00000000000..b4cf2fe580f --- /dev/null +++ b/curriculum/challenges/english/blocks/workshop-employee-profile-generator/694bf6eb530e19a9c48c59f5.md @@ -0,0 +1,80 @@ +--- +id: 694bf6eb530e19a9c48c59f5 +title: Step 16 +challengeType: 20 +dashedName: step-16 +--- + +# --description-- + +When working with strings, you'll often need to extract a specific portion of a string. This is called **slicing**. + +The syntax is `string[start:stop]`, where: + +* `start` is the index where the slice begins (**inclusive**). +* `stop` is the index where the slice ends (**exclusive**). + +For example, if `text = 'Python'`, then `text[0:2]` gives `'Py'`. + +Define `employee_code` as `'DEV-2026-JD-001'`. After that, create a variable `department` and assign it the slice of `employee_code` from index `0` to `3`. Then print `department` to the terminal. + +# --hints-- +You should have a variable named `employee_code`. + +```js +({ test: () => assert(runPython(`_Node(_code).has_variable("employee_code")`)) }) +``` + +You should assign the string `DEV-2026-JD-001` to your `employee_code` variable. + +```js +({ test: () => assert(runPython(`_Node(_code).find_variable("employee_code").is_equivalent("employee_code = 'DEV-2026-JD-001'")`)) }) +``` + +You should have a variable named `department`. + +```js +({ test: () => assert(runPython(`_Node(_code).has_variable("department")`)) }) +``` + +You should slice the first three characters of `employee_code` and assign them to your `department` variable. + +```js +({ test: () => runPython(` +dep = _Node(_code).find_variable("department") +assert dep.is_equivalent("department = employee_code[0:3]") or dep.is_equivalent("department = employee_code[:3]") +`) }) +``` + +You should print `department` to the terminal. + +```js +({ test: () => assert(runPython(`_Node(_code).has_call("print(department)")`)) }) +``` + +# --seed-- + +## --seed-contents-- + +```python +first_name = 'John' +last_name = 'Doe' +full_name = first_name + ' ' + last_name +address = '123 Main Street' +address += ', Apartment 4B' +employee_age = 28 +employee_info = full_name + ' is ' + str(employee_age) + ' years old' +print(employee_info) +years_experience = 5 +experience_years = 5 +experience_info = 'Experience: ' + str(experience_years) + ' years' +print(experience_info) +position = 'Data Analyst' +salary = 75000 +employee_card = f'Employee: {full_name} | Age: {employee_age} | Position: {position} | Salary: ${salary}' +print(employee_card) + +--fcc-editable-region-- + +--fcc-editable-region-- +``` diff --git a/curriculum/challenges/english/blocks/workshop-employee-profile-generator/694bf6eb530e19a9c48c59f6.md b/curriculum/challenges/english/blocks/workshop-employee-profile-generator/694bf6eb530e19a9c48c59f6.md new file mode 100644 index 00000000000..a6a9b96940b --- /dev/null +++ b/curriculum/challenges/english/blocks/workshop-employee-profile-generator/694bf6eb530e19a9c48c59f6.md @@ -0,0 +1,83 @@ +--- +id: 694bf6eb530e19a9c48c59f6 +title: Step 17 +challengeType: 20 +dashedName: step-17 +--- + +# --description-- + +You can slice from any part of the string, not just the beginning. And it is helpful in many cases. + +Create a variable `year_code` and assign it the slice of `employee_code` from index `4` to `8`. This will extract `2026`. + +Then create a variable `initials` and assign it the slice of `employee_code` from index `9` to `11`. This will extract `JD`. + +Finally, print both variables to the terminal. + +# --hints-- + +You should have a variable named `year_code`. + +```js +({ test: () => assert(runPython(`_Node(_code).has_variable("year_code")`)) }) +``` + +You should slice `employee_code` from index `4` to `8` and assign the result to your `year_code` variable. + +```js +({ test: () => assert(runPython(`_Node(_code).find_variable("year_code").is_equivalent("year_code = employee_code[4:8]")`)) }) +``` + +You should have a variable named `initials`. + +```js +({ test: () => assert(runPython(`_Node(_code).has_variable("initials")`)) }) +``` + +You should slice `employee_code` from index `9` to `11` and assign the result to your `initials` variable. + +```js +({ test: () => assert(runPython(`_Node(_code).find_variable("initials").is_equivalent("initials = employee_code[9:11]")`)) }) +``` + +You should print `year_code` to the terminal. + +```js +({ test: () => assert(runPython(`_Node(_code).has_call("print(year_code)")`)) }) +``` + +You should print `initials` to the terminal. + +```js +({ test: () => assert(runPython(`_Node(_code).has_call("print(initials)")`)) }) +``` + +# --seed-- + +## --seed-contents-- + +```python +first_name = 'John' +last_name = 'Doe' +full_name = first_name + ' ' + last_name +address = '123 Main Street' +address += ', Apartment 4B' +employee_age = 28 +employee_info = full_name + ' is ' + str(employee_age) + ' years old' +print(employee_info) +years_experience = 5 +experience_years = 5 +experience_info = 'Experience: ' + str(experience_years) + ' years' +print(experience_info) +position = 'Data Analyst' +salary = 75000 +employee_card = f'Employee: {full_name} | Age: {employee_age} | Position: {position} | Salary: ${salary}' +print(employee_card) +employee_code = 'DEV-2026-JD-001' +department = employee_code[0:3] +print(department) +--fcc-editable-region-- + +--fcc-editable-region-- +``` diff --git a/curriculum/challenges/english/blocks/workshop-employee-profile-generator/694bf6eb530e19a9c48c59f7.md b/curriculum/challenges/english/blocks/workshop-employee-profile-generator/694bf6eb530e19a9c48c59f7.md new file mode 100644 index 00000000000..0931526e5f9 --- /dev/null +++ b/curriculum/challenges/english/blocks/workshop-employee-profile-generator/694bf6eb530e19a9c48c59f7.md @@ -0,0 +1,98 @@ +--- +id: 694bf6eb530e19a9c48c59f7 +title: Step 18 +challengeType: 20 +dashedName: step-18 +--- + +# --description-- + +You can also use negative numbers to slice from the end of a string. For example, `-1` refers to the last character, `-2` refers to the second-to-last character, and so on. + +To get the last three characters of a string, you can use `string[-3:]`. Note how the stop parameter is omitted after the colon. This means the slicing should proceed up to the string boundary. + +Create a variable named `last_three`. Use negative indexing to extract the last three characters from `employee_code` (which represent the ID number). Finally, print `last_three` to the terminal. + +With that, the employee card workshop is complete. + +# --hints-- + +You should have a variable named `last_three`. + +```js +({ test: () => assert(runPython(`_Node(_code).has_variable("last_three")`)) }) +``` + +You should slice the last three characters of `employee_code` using negative indexing and assign them your `last_three` variable. + +```js +({ test: () => assert(runPython(`_Node(_code).find_variable("last_three").is_equivalent("last_three = employee_code[-3:]")`)) }) +``` + +You should print `last_three` to the terminal. + +```js +({ test: () => assert(runPython(`_Node(_code).has_call("print(last_three)")`)) }) +``` + +# --seed-- + +## --seed-contents-- + +```python +first_name = 'John' +last_name = 'Doe' +full_name = first_name + ' ' + last_name +address = '123 Main Street' +address += ', Apartment 4B' +employee_age = 28 +employee_info = full_name + ' is ' + str(employee_age) + ' years old' +print(employee_info) +years_experience = 5 +experience_years = 5 +experience_info = 'Experience: ' + str(experience_years) + ' years' +print(experience_info) +position = 'Data Analyst' +salary = 75000 +employee_card = f'Employee: {full_name} | Age: {employee_age} | Position: {position} | Salary: ${salary}' +print(employee_card) +employee_code = 'DEV-2026-JD-001' +department = employee_code[0:3] +print(department) +year_code = employee_code[4:8] +print(year_code) +initials = employee_code[9:11] +print(initials) +--fcc-editable-region-- + +--fcc-editable-region-- +``` + +# --solutions-- + +```python +first_name = 'John' +last_name = 'Doe' +full_name = first_name + ' ' + last_name +address = '123 Main Street' +address += ', Apartment 4B' +employee_age = 28 +employee_info = full_name + ' is ' + str(employee_age) + ' years old' +print(employee_info) +experience_years = 5 +experience_info = 'Experience: ' + str(experience_years) + ' years' +print(experience_info) +position = 'Data Analyst' +salary = 75000 +employee_card = f'Employee: {full_name} | Age: {employee_age} | Position: {position} | Salary: ${salary}' +print(employee_card) +employee_code = 'DEV-2024-JD-001' +department = employee_code[0:3] +print(department) +year_code = employee_code[4:8] +initials = employee_code[9:11] +print(year_code) +print(initials) +last_three = employee_code[-3:] +print(last_three) +``` diff --git a/curriculum/challenges/english/blocks/workshop-employee-profile-generator/695c96f82af4fb78e59fa9ed.md b/curriculum/challenges/english/blocks/workshop-employee-profile-generator/695c96f82af4fb78e59fa9ed.md new file mode 100644 index 00000000000..69e04e48863 --- /dev/null +++ b/curriculum/challenges/english/blocks/workshop-employee-profile-generator/695c96f82af4fb78e59fa9ed.md @@ -0,0 +1,65 @@ +--- +id: 695c96f82af4fb78e59fa9ed +title: Step 1 +challengeType: 20 +dashedName: step-1 +--- + +# --description-- + +Strings are sequences of characters used to store text data. As you might recall from previous lessons, you can create a string by enclosing text inside either single (`'`) or double (`"`) quotes. For example: + +```python +greeting = 'Hello' +print(greeting) # Output: Hello +``` + +Create a variable `first_name` which stores the string `John` and a variable `last_name` which stores the string `Doe`. Then print `first_name` and `last_name`. + +# --hints-- + +You should have a variable named `first_name`. + +```js +({ test: () => assert(runPython(`_Node(_code).has_variable("first_name")`)) }) +``` + +You should assign the string `John` to your `first_name` variable. Remember to enclose the text between either single or double quotes. + +```js +({ test: () => assert(runPython(`_Node(_code).find_variable("first_name").is_equivalent("first_name = 'John'")`)) }) +``` + +You should have a variable named `last_name`. + +```js +({ test: () => assert(runPython(`_Node(_code).has_variable("last_name")`)) }) +``` + +You should assign the string `Doe` to your `last_name` variable. Remember to enclose the text between either single or double quotes. + +```js +({ test: () => assert(runPython(`_Node(_code).find_variable("last_name").is_equivalent("last_name = 'Doe'")`)) }) +``` + +You should print your `first_name` variable to the terminal. + +```js +({ test: () => assert(runPython(`_Node(_code).has_call("print(first_name)")`)) }) +``` + +You should print your `last_name` variable to the terminal. + +```js +({ test: () => assert(runPython(`_Node(_code).has_call("print(last_name)")`)) }) +``` + +# --seed-- + +## --seed-contents-- + +```python +--fcc-editable-region-- + +--fcc-editable-region-- +``` diff --git a/curriculum/challenges/english/blocks/workshop-employee-profile-generator/695c9c7c61d446f1451e0ae7.md b/curriculum/challenges/english/blocks/workshop-employee-profile-generator/695c9c7c61d446f1451e0ae7.md new file mode 100644 index 00000000000..ed14a6f99a3 --- /dev/null +++ b/curriculum/challenges/english/blocks/workshop-employee-profile-generator/695c9c7c61d446f1451e0ae7.md @@ -0,0 +1,47 @@ +--- +id: 695c9c7c61d446f1451e0ae7 +title: Step 4 +challengeType: 20 +dashedName: step-4 +--- + +# --description-- + +Next, create a variable `address` to store the employee's address. Assign it the string `123 Main Street`, and finally print `address`. + +# --hints-- + +You should have a variable named `address`. + +```js +({ test: () => assert(runPython(`_Node(_code).has_variable("address")`)) }) +``` + +You should assign the string `123 Main Street` to your `address` variable. Remember to enclose the text between either single or double quotes. + +```js +({ test: () => assert(runPython(`_Node(_code).find_variable("address").is_equivalent("address = '123 Main Street'")`)) }) +``` + +You should print the `address` variable. + +```js +({ test: () => assert(runPython(`_Node(_code).has_call("print(address)")`)) }) +``` + +# --seed-- + +## --seed-contents-- + +```python +first_name = 'John' +last_name = 'Doe' +print(first_name) +print(last_name) +full_name = first_name + ' ' + last_name +print(full_name) +--fcc-editable-region-- + +--fcc-editable-region-- +``` + diff --git a/curriculum/challenges/english/blocks/workshop-employee-profile-generator/695c9f21a8b1d53cf1b97841.md b/curriculum/challenges/english/blocks/workshop-employee-profile-generator/695c9f21a8b1d53cf1b97841.md new file mode 100644 index 00000000000..3cd4a5fb0b9 --- /dev/null +++ b/curriculum/challenges/english/blocks/workshop-employee-profile-generator/695c9f21a8b1d53cf1b97841.md @@ -0,0 +1,41 @@ +--- +id: 695c9f21a8b1d53cf1b97841 +title: Step 7 +challengeType: 20 +dashedName: step-7 +--- + +# --description-- + +Now create a variable named `employee_age` and assign it the integer `28`. + + +# --hints-- + +You should have a variable named `employee_age`. + +```js +({ test: () => assert(runPython(`_Node(_code).has_variable("employee_age")`)) }) +``` + +You should assign the integer `28` to your `employee_age` variable. Do not surround the text with quotes. + +```js +({ test: () => assert(runPython(`_Node(_code).find_variable("employee_age").is_equivalent("employee_age = 28")`)) }) +``` + + +# --seed-- + +## --seed-contents-- + +```python +first_name = 'John' +last_name = 'Doe' +full_name = first_name + ' ' + last_name +address = '123 Main Street' +address += ', Apartment 4B' +--fcc-editable-region-- + +--fcc-editable-region-- +``` diff --git a/curriculum/challenges/english/blocks/workshop-employee-profile-generator/695df6480de23758af5a29cd.md b/curriculum/challenges/english/blocks/workshop-employee-profile-generator/695df6480de23758af5a29cd.md new file mode 100644 index 00000000000..cce8b16bb01 --- /dev/null +++ b/curriculum/challenges/english/blocks/workshop-employee-profile-generator/695df6480de23758af5a29cd.md @@ -0,0 +1,45 @@ +--- +id: 695df6480de23758af5a29cd +title: Step 8 +challengeType: 20 +dashedName: step-8 +--- + +# --description-- + +Now, you want to create a string that displays the employee's age. + +Start by creating a variable `employee_info` and assign it the result of concatenating: + +- the `full_name` variable. +- a string consisting of the characters `is` preceded and followed by a space. + +# --hints-- + +You should have a variable named `employee_info`. + +```js +({ test: () => assert(runPython(`_Node(_code).has_variable("employee_info")`)) }) +``` + +You should assign `full_name + ' is '` to your `employee_info` variable. + +```js +({ test: () => assert(runPython(`_Node(_code).find_variable("employee_info").is_equivalent("employee_info = full_name + ' is '")`)) }) +``` + +# --seed-- + +## --seed-contents-- + +```python +first_name = 'John' +last_name = 'Doe' +full_name = first_name + ' ' + last_name +address = '123 Main Street' +address += ', Apartment 4B' +employee_age = 28 +--fcc-editable-region-- + +--fcc-editable-region-- +``` diff --git a/curriculum/challenges/english/blocks/workshop-employee-profile-generator/695ea1e55c0e619e597fc5c9.md b/curriculum/challenges/english/blocks/workshop-employee-profile-generator/695ea1e55c0e619e597fc5c9.md new file mode 100644 index 00000000000..d47b058d885 --- /dev/null +++ b/curriculum/challenges/english/blocks/workshop-employee-profile-generator/695ea1e55c0e619e597fc5c9.md @@ -0,0 +1,43 @@ +--- +id: 695ea1e55c0e619e597fc5c9 +title: Step 10 +challengeType: 20 +dashedName: step-10 +--- + +# --description-- + +As you can see Python raised a `TypeError: can only concatenate str (not "int") to str`. This happens because Python does not allow you to concatenate text (strings) and numbers (integers) directly. + +To fix this, you must convert the number to a string first using the `str()` function, which returns the string version of an object: + +```py +my_num = str(42) +print(type(my_num)) # +``` + +Update your `employee_info` assignment to convert `employee_age` to a string using `str(employee_age)`. + +# --hints-- + +You should modify the assignment of your `employee_info` variable by converting `employee_age` into a string with `str(employee_age)`. + +```js +({ test: () => assert(runPython(`_Node(_code).find_variable("employee_info").is_equivalent("employee_info = full_name + ' is ' + str(employee_age)")`)) }) +``` + +# --seed-- + +## --seed-contents-- + +```python +first_name = 'John' +last_name = 'Doe' +full_name = first_name + ' ' + last_name +address = '123 Main Street' +address += ', Apartment 4B' +employee_age = 28 +--fcc-editable-region-- +employee_info = full_name + ' is ' + employee_age +--fcc-editable-region-- +``` diff --git a/curriculum/challenges/english/blocks/workshop-employee-profile-generator/695fcfbba648b3a96a9495a4.md b/curriculum/challenges/english/blocks/workshop-employee-profile-generator/695fcfbba648b3a96a9495a4.md new file mode 100644 index 00000000000..be88e911eb9 --- /dev/null +++ b/curriculum/challenges/english/blocks/workshop-employee-profile-generator/695fcfbba648b3a96a9495a4.md @@ -0,0 +1,38 @@ +--- +id: 695fcfbba648b3a96a9495a4 +title: Step 6 +challengeType: 20 +dashedName: step-6 +--- + +# --description-- + +The output in the terminal is getting crowded. Before you continue, it's time to clean it up. + +Remove all the `print()` statements from your code. + +# --hints-- + +You should not have any `print` calls in your code. + +```js +({ test: () => assert(runPython(`len(_Node(_code).find_calls("print")) == 0`)) }) +``` + +# --seed-- + +## --seed-contents-- + +```py +first_name = 'John' +last_name = 'Doe' +--fcc-editable-region-- +print(first_name) +print(last_name) +full_name = first_name + ' ' + last_name +print(full_name) +address = '123 Main Street' +address += ', Apartment 4B' +print(address) +--fcc-editable-region-- +``` diff --git a/curriculum/challenges/english/blocks/workshop-employee-profile-generator/695fd3dde03273875e5d6709.md b/curriculum/challenges/english/blocks/workshop-employee-profile-generator/695fd3dde03273875e5d6709.md new file mode 100644 index 00000000000..a1bf5002152 --- /dev/null +++ b/curriculum/challenges/english/blocks/workshop-employee-profile-generator/695fd3dde03273875e5d6709.md @@ -0,0 +1,37 @@ +--- +id: 695fd3dde03273875e5d6709 +title: Step 9 +challengeType: 20 +dashedName: step-9 +--- + +# --description-- + +Now try to concatenate `employee_age` to the end of your `employee_info` string. + +Once you've done so, you'll see a `TypeError` in the terminal. In the next step, you'll work on fixing it. + +# --hints-- + +You should concatenate `employee_age` to the end of `employee_info`. + +```js +const regex = /^employee_info\s*=\s*full_name\s*\+\s*(["']) is \1\s*\+\s*employee_age\s*$/m; +assert.match(__helpers.python.removeComments(code), regex); +``` + +# --seed-- + +## --seed-contents-- + +```py +first_name = 'John' +last_name = 'Doe' +full_name = first_name + ' ' + last_name +address = '123 Main Street' +address += ', Apartment 4B' +employee_age = 28 +--fcc-editable-region-- +employee_info = full_name + ' is ' +--fcc-editable-region-- +``` diff --git a/curriculum/challenges/english/blocks/workshop-employee-profile-generator/69727ea5c9606bedfe36d3d2.md b/curriculum/challenges/english/blocks/workshop-employee-profile-generator/69727ea5c9606bedfe36d3d2.md new file mode 100644 index 00000000000..c57b287b990 --- /dev/null +++ b/curriculum/challenges/english/blocks/workshop-employee-profile-generator/69727ea5c9606bedfe36d3d2.md @@ -0,0 +1,76 @@ +--- +id: 69727ea5c9606bedfe36d3d2 +title: Step 15 +challengeType: 20 +dashedName: step-15 +--- + +# --description-- + +Now it's time to add the final details to the card. + +Create a variable named `position` with the value of the string `Data Analyst` and a variable named `salary` with the value of the integer `75000`. + +Then, update your `employee_card` f-string to include the position and salary. It should follow this exact format: `Employee: [full_name] | Age: [employee_age] | Position: [position] | Salary: $[salary]`. Replace the placeholders with the corresponding variables. + +Finally, print `employee_card` to see the result. + +# --hints-- + +You should have a variable named `position`. + +```js +({ test: () => assert(runPython(`_Node(_code).has_variable("position")`)) }) +``` + +You should assign the string `Data Analyst` to your `position` variable. + +```js +({ test: () => assert(runPython(`_Node(_code).find_variable("position").is_equivalent("position = 'Data Analyst'")`)) }) +``` + +You should have a variable named `salary`. + +```js +({ test: () => assert(runPython(`_Node(_code).find_variable("salary").is_equivalent("salary = 75000")`)) }) +``` + +You should assign the integer `75000` to your `salary` variable. + +```js +({ test: () => assert(runPython(`_Node(_code).find_variable("salary").is_equivalent("salary = 75000")`)) }) +``` + +You should update `employee_card` to use the f-string `f'Employee: {full_name} | Age: {employee_age} | Position: {position} | Salary: ${salary}'`. + +```js +({ test: () => assert(runPython(`_Node(_code).find_variable("employee_card").is_equivalent("employee_card = f'Employee: {full_name} | Age: {employee_age} | Position: {position} | Salary: \${salary}'")`)) }) +``` + +You should print `employee_card` to the terminal. + +```js +({ test: () => assert(runPython(`_Node(_code).has_call("print(employee_card)")`))}) +``` + +# --seed-- + +## --seed-contents-- + +```py +first_name = 'John' +last_name = 'Doe' +full_name = first_name + ' ' + last_name +address = '123 Main Street' +address += ', Apartment 4B' +employee_age = 28 +employee_info = full_name + ' is ' + str(employee_age) + ' years old' +print(employee_info) +experience_years = 5 +experience_info = 'Experience: ' + str(experience_years) + ' years' +print(experience_info) +--fcc-editable-region-- + +employee_card = f'Employee: {full_name} | Age: {employee_age}' +--fcc-editable-region-- +``` diff --git a/curriculum/challenges/english/blocks/workshop-employee-profile-generator/6980d3ecfe800d8a54130f30.md b/curriculum/challenges/english/blocks/workshop-employee-profile-generator/6980d3ecfe800d8a54130f30.md new file mode 100644 index 00000000000..a5bd18dd0a6 --- /dev/null +++ b/curriculum/challenges/english/blocks/workshop-employee-profile-generator/6980d3ecfe800d8a54130f30.md @@ -0,0 +1,41 @@ +--- +id: 6980d3ecfe800d8a54130f30 +title: Step 14 +challengeType: 20 +dashedName: step-14 +--- + +# --description-- + +Currently, `employee_card` only shows the employee's name. Now you're going to add more information to it. + +Update the `employee_card` assignment to include the employee's age. The final string should look like this: `Employee: [name] | Age: [age]` with `[name]` replaced with the employee's name, and `[age]` replaced with the employee's age. + +# --hints-- + +You should update `employee_card` to use the f-string `f'Employee: {full_name} | Age: {employee_age}'`. + +```js +({ test: () => assert(runPython(`_Node(_code).find_variable("employee_card").is_equivalent("employee_card = f'Employee: {full_name} | Age: {employee_age}'")`)) }) +``` + +# --seed-- + +## --seed-contents-- + +```py +first_name = 'John' +last_name = 'Doe' +full_name = first_name + ' ' + last_name +address = '123 Main Street' +address += ', Apartment 4B' +employee_age = 28 +employee_info = full_name + ' is ' + str(employee_age) + ' years old' +print(employee_info) +experience_years = 5 +experience_info = 'Experience: ' + str(experience_years) + ' years' +print(experience_info) +--fcc-editable-region-- +employee_card = f'Employee: {full_name}' +--fcc-editable-region-- +``` diff --git a/curriculum/structure/blocks/workshop-employee-profile-generator.json b/curriculum/structure/blocks/workshop-employee-profile-generator.json new file mode 100644 index 00000000000..a12108ac005 --- /dev/null +++ b/curriculum/structure/blocks/workshop-employee-profile-generator.json @@ -0,0 +1,30 @@ +{ + "name": "Build an Employee Profile Generator", + "isUpcomingChange": false, + "dashedName": "workshop-employee-profile-generator", + "helpCategory": "Python", + "blockLayout": "challenge-grid", + "challengeOrder": [ + { "id": "695c96f82af4fb78e59fa9ed", "title": "Step 1" }, + { "id": "694bf3af05d10fd89dab05cc", "title": "Step 2" }, + { "id": "694bf6ea530e19a9c48c59f0", "title": "Step 3" }, + { "id": "695c9c7c61d446f1451e0ae7", "title": "Step 4" }, + { "id": "694bf6eb530e19a9c48c59f1", "title": "Step 5" }, + { "id": "695fcfbba648b3a96a9495a4", "title": "Step 6" }, + { "id": "695c9f21a8b1d53cf1b97841", "title": "Step 7" }, + { "id": "695df6480de23758af5a29cd", "title": "Step 8" }, + { "id": "695fd3dde03273875e5d6709", "title": "Step 9" }, + { "id": "695ea1e55c0e619e597fc5c9", "title": "Step 10" }, + { "id": "694bf6eb530e19a9c48c59f2", "title": "Step 11" }, + { "id": "694bf6eb530e19a9c48c59f3", "title": "Step 12" }, + { "id": "694bf6eb530e19a9c48c59f4", "title": "Step 13" }, + { "id": "6980d3ecfe800d8a54130f30", "title": "Step 14" }, + { "id": "69727ea5c9606bedfe36d3d2", "title": "Step 15" }, + { "id": "694bf6eb530e19a9c48c59f5", "title": "Step 16" }, + { "id": "694bf6eb530e19a9c48c59f6", "title": "Step 17" }, + { "id": "694bf6eb530e19a9c48c59f7", "title": "Step 18" } + ], + "blockLabel": "workshop", + "usesMultifileEditor": true, + "hasEditableBoundaries": true +} diff --git a/curriculum/structure/superblocks/python-v9.json b/curriculum/structure/superblocks/python-v9.json index 4dd9e5d7804..429112f90e6 100644 --- a/curriculum/structure/superblocks/python-v9.json +++ b/curriculum/structure/superblocks/python-v9.json @@ -10,6 +10,7 @@ "lecture-understanding-variables-and-data-types", "workshop-report-card-printer", "lecture-introduction-to-python-strings", + "workshop-employee-profile-generator", "lecture-numbers-and-mathematical-operations", "lecture-booleans-and-conditionals", "workshop-movie-ticket-booking-calculator",