mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-05-28 18:26:54 +00:00
fix(curriculum): clarify step descriptions in movie ticket booking calculator workshop (#66400)
This commit is contained in:
+2
-2
@@ -20,9 +20,9 @@ if condition1:
|
||||
|
||||
Now you will calculate service charges based on the type of seat the user has selected.
|
||||
|
||||
Still inside your last `if` statement body, create a variable named `service_charges` and set it to `0`.
|
||||
Inside the body of the last `if` statement, below the `print('Ticket booking condition satisfied')` line, create a variable named `service_charges` and set it to `0`. Make sure to indent your code by four spaces to keep it inside the outer `if` statement body.
|
||||
|
||||
Then, create a nested `if` statement to check if `seat_type` is equal to `Premium`. Inside the body of the `if` statement, update the `service_charges` value to `5`.
|
||||
Then, create a nested `if` statement to check if `seat_type` is equal to `Premium`. Inside the body of the nested `if` statement, update the `service_charges` value to `5`.
|
||||
|
||||
# --hints--
|
||||
|
||||
|
||||
+1
-1
@@ -11,7 +11,7 @@ In this final step, you will calculate the final price of the movie ticket using
|
||||
|
||||
The final ticket price is calculated by adding the extra charges and service charges to the base price, and then subtracting the discount.
|
||||
|
||||
At the bottom of your last `if` statement body, calculate the final price of the ticket and store it in a variable named `final_price`.
|
||||
Inside the body of the last `if` statement, below the `print('Service charges:', service_charges)` line, calculate the final price of the ticket and store it in a variable named `final_price`.
|
||||
|
||||
Finally, print a message that shows `Final price of ticket:` followed by the value of `final_price`.
|
||||
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@ if condition1 and condition2:
|
||||
|
||||
The membership discount should only apply to members if their `age` is greater than or equal to `21`.
|
||||
|
||||
Use the `and` operator to combine the existing condition of your `if` statement with another condition checking if `age` is greater than or equal to `21`.
|
||||
Update the condition of the `if is_member:` line by using the `and` operator to combine the existing condition with another condition checking if `age` is greater than or equal to `21`.
|
||||
|
||||
# --hints--
|
||||
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@ if condition1 or condition2:
|
||||
# Code to execute if any condition is True
|
||||
```
|
||||
|
||||
Extra charges should also apply if the show is in the evening. Use the `or` operator to combine the existing condition of your `if` statement with a second condition checking if `show_time` is equal to the string `Evening`.
|
||||
Extra charges should also apply if the show is in the evening. Update the condition of the `if is_weekend:` line by using the `or` operator to combine the existing condition with a second condition checking if `show_time` is equal to the string `Evening`.
|
||||
|
||||
# --hints--
|
||||
|
||||
|
||||
+1
-1
@@ -9,7 +9,7 @@ dashedName: step-16
|
||||
|
||||
Users between `18` and `21` can book tickets, but only when the `show_time` is not `Evening`.
|
||||
|
||||
Use the `and` operator to build an expression checking if `age` is greater than or equal to `18` and `show_time` is not `Evening`. Use the `or` operator to combine it with the existing condition of the last `if` statement. Do not create new variables.
|
||||
Update the condition of the `if age >= 21:` line. Use the `and` operator to build an expression checking if `age` is greater than or equal to `18` and `show_time` is not `Evening`. Then use the `or` operator to combine that expression with the existing condition. Do not create new variables.
|
||||
|
||||
# --hints--
|
||||
|
||||
|
||||
+1
-1
@@ -18,7 +18,7 @@ else:
|
||||
# Code to execute if conditions evaluate to False
|
||||
```
|
||||
|
||||
Now, add another condition to your existing `if` statement using the `or` operator to check if `is_member` is truthy. Use the parentheses `()` to group the `show_time != 'Evening'` and `is_member` conditions together as shown in the above example.
|
||||
Update the condition of the `if age >= 21 or age >= 18 and show_time != 'Evening':` line to add another condition using the `or` operator to check if `is_member` is truthy. Use parentheses `()` to group the `show_time != 'Evening'` and `is_member` conditions together as shown in the above example.
|
||||
|
||||
# --hints--
|
||||
|
||||
|
||||
+4
-4
@@ -18,13 +18,13 @@ else:
|
||||
# Code to execute if all conditions are False
|
||||
```
|
||||
|
||||
Add an `elif` statement to your `if...else` statement and check if `seat_type` is equal to `Gold`. Inside the body of the `elif` statement, update the value of `service_charges` to `3`.
|
||||
Still inside the body of the outer `if` statement, add an `elif` clause between the `if seat_type == 'Premium':` and `else:` lines and check if `seat_type` is equal to `Gold`. Inside the body of the `elif` clause, update the value of `service_charges` to `3`.
|
||||
|
||||
Below the `if...elif..else` statement, use the `print()` call to display a message that shows `Service charges:` followed by the updated value of `service_charges`. Then, check the output in the terminal.
|
||||
Below the nested `if...elif...else` statement, use the `print()` call to display a message that shows `Service charges:` followed by the updated value of `service_charges`. Then, check the output in the terminal.
|
||||
|
||||
# --hints--
|
||||
|
||||
You should have an `elif` statement.
|
||||
You should have an `elif` clause.
|
||||
|
||||
```js
|
||||
({ test: () => (runPython(`
|
||||
@@ -33,7 +33,7 @@ assert not _cond.is_empty()
|
||||
`)) })
|
||||
```
|
||||
|
||||
Your `elif` statement condition should be `seat_type == 'Gold'`.
|
||||
Your `elif` clause condition should be `seat_type == 'Gold'`.
|
||||
|
||||
```js
|
||||
({ test: () => (runPython(`
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@ dashedName: step-19
|
||||
|
||||
# --description--
|
||||
|
||||
Now, add an `else` clause to your `if` statement and update the `service_charges` value to `1` inside the `else` body.
|
||||
Still inside the body of the outer `if` statement, add an `else` clause to the nested `if seat_type == 'Premium':` statement and update the `service_charges` value to `1` inside the `else` body. Make sure to keep the `else` indented by four spaces to stay inside the outer `if` statement body.
|
||||
|
||||
# --hints--
|
||||
|
||||
|
||||
Reference in New Issue
Block a user