fix(curriculum): clarify step 4 instructions and update tests (#66047)

This commit is contained in:
Bảo Nguyễn 2026-03-04 14:37:42 +07:00 committed by GitHub
parent 1bfc65a7d1
commit 5d6860f4c4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 16 additions and 8 deletions

View File

@ -64,7 +64,7 @@ main_courses = 57.34
desserts = 39.39
drinks = 64.21
running_total = appetizers + main_courses + desserts + drinks
running_total += appetizers + main_courses + desserts + drinks
print('Total bill so far:', running_total)
--fcc-editable-region--

View File

@ -48,7 +48,7 @@ main_courses = 57.34
desserts = 39.39
drinks = 64.21
running_total = appetizers + main_courses + desserts + drinks
running_total += appetizers + main_courses + desserts + drinks
print('Total bill so far:', running_total)
tip = running_total * 0.25

View File

@ -64,7 +64,7 @@ main_courses = 57.34
desserts = 39.39
drinks = 64.21
running_total = appetizers + main_courses + desserts + drinks
running_total += appetizers + main_courses + desserts + drinks
print('Total bill so far:', running_total)
tip = running_total * 0.25

View File

@ -67,7 +67,7 @@ main_courses = 57.34
desserts = 39.39
drinks = 64.21
running_total = appetizers + main_courses + desserts + drinks
running_total += appetizers + main_courses + desserts + drinks
print('Total bill so far:', running_total)
tip = running_total * 0.25
@ -96,7 +96,7 @@ main_courses = 57.34
desserts = 39.39
drinks = 64.21
running_total = appetizers + main_courses + desserts + drinks
running_total += appetizers + main_courses + desserts + drinks
print('Total bill so far:', running_total)
tip = running_total * 0.25

View File

@ -9,7 +9,15 @@ dashedName: step-4
Now that you have stored the individual costs, you can calculate the total. In Python, you use the addition operator `+` to sum values together.
Update the `running_total` variable by adding `appetizers`, `main_courses`, `desserts`, and `drinks` together.
The `+=` operator adds a value to an existing variable and updates it at the same time. For example:
```py
total = 10
total += 2 + 2 + 1
print(total) # total is now 15
```
Use the `+=` operator once to add `appetizers`, `main_courses`, `desserts`, and `drinks` to `running_total`.
Finally, use `print()` to display the string `Total bill so far:` followed by a space and the value of `running_total`.
@ -17,7 +25,7 @@ Finally, use `print()` to display the string `Total bill so far:` followed by a
# --hints--
You should update `running_total` using the `+` operator to sum all four courses cost.
You should update `running_total` using the `+=` operator once to add all four course costs.
```js
({
@ -25,7 +33,7 @@ You should update `running_total` using the `+` operator to sum all four courses
import itertools
perms = itertools.permutations(['+ appetizers', '+ main_courses', '+ desserts', '+ drinks'])
values = (' '.join(perm).lstrip('+') for perm in perms)
solutions = (f'running_total = {v}' for v in values)
solutions = (f'running_total += {v}' for v in values)
assert any(_Node(_code).has_stmt(s) for s in solutions)`)
})
```