Question
Code block
# starting score
score = 10
# when you help a character, you apply a multiplier of 3
bonus_helping_character_multiplier = 3
# Update score and print
score = score * bonus_helping_character_multiplier
print(score)
# when you help an animal your score increases by 5
bonus_helping_animal = 5
# Update score and print
score = score + bonus_helping_animal
print(score)
# you overcame some obstacles, so your score updates
score = 0
# you helped another character and an an animal so your score increased
score = score * bonus_helping_character_multiplier + bonus_helping_animal
# final print of score!
print(score) Your Task
The value of score at line 3 is[blank]
1 pt
2.
The value of score at line 5 is[blank]
1 pt
3.
The value of score at line 7 is[blank]
1 pt
4.
The value of score at line 12 is[blank]
1 pt
5.
The value of score at line 19 is[blank]
1 pt
# starting score
score = 10
# when you help a character, you apply a multiplier of 3
bonus_helping_character_multiplier = 3
# Update score and print
score = score * bonus_helping_character_multiplier
print(score)
# when you help an animal your score increases by 5
bonus_helping_animal = 5
# Update score and print
score = score + bonus_helping_animal
print(score)
# you overcame some obstacles, so your score updates
score = 0
# you helped another character and an an animal so your score increased
score = score * bonus_helping_character_multiplier + bonus_helping_animal
# final print of score!
print(score) Your Task
The value of score at line 3 is[blank]
1 pt
2.
The value of score at line 5 is[blank]
1 pt
3.
The value of score at line 7 is[blank]
1 pt
4.
The value of score at line 12 is[blank]
1 pt
5.
The value of score at line 19 is[blank]
1 pt
Answers
Answered by
GPT-4o mini
Let's break down the code to find the values at the specified lines.
1. At line 3, after executing the first score update with the character multiplier:
```python
score = score * bonus_helping_character_multiplier
```
Calculation:
- Initial score is 10.
- Score becomes: `10 * 3 = 30`
**Value at line 3:** 30
2. At line 5, after the score is updated by helping an animal:
```python
score = score + bonus_helping_animal
```
Calculation:
- Previous score (after line 3) is 30.
- Score becomes: `30 + 5 = 35`
**Value at line 5:** 35
3. At line 7, the score is reset to 0:
```python
score = 0
```
**Value at line 7:** 0
4. At line 12, after updating the score with the multiplier and the bonus for helping another character and an animal:
```python
score = score * bonus_helping_character_multiplier + bonus_helping_animal
```
Calculation:
- Previous score (at line 7) is 0.
- Score becomes: `0 * 3 + 5 = 0 + 5 = 5`
**Value at line 12:** 5
5. At line 19, this is the final print of the score:
```python
print(score)
```
Since line 12 calculated the score as 5,
**Value at line 19:** 5
### Summary of Values:
1. Value at line 3: **30**
2. Value at line 5: **35**
3. Value at line 7: **0**
4. Value at line 12: **5**
5. Value at line 19: **5**
1. At line 3, after executing the first score update with the character multiplier:
```python
score = score * bonus_helping_character_multiplier
```
Calculation:
- Initial score is 10.
- Score becomes: `10 * 3 = 30`
**Value at line 3:** 30
2. At line 5, after the score is updated by helping an animal:
```python
score = score + bonus_helping_animal
```
Calculation:
- Previous score (after line 3) is 30.
- Score becomes: `30 + 5 = 35`
**Value at line 5:** 35
3. At line 7, the score is reset to 0:
```python
score = 0
```
**Value at line 7:** 0
4. At line 12, after updating the score with the multiplier and the bonus for helping another character and an animal:
```python
score = score * bonus_helping_character_multiplier + bonus_helping_animal
```
Calculation:
- Previous score (at line 7) is 0.
- Score becomes: `0 * 3 + 5 = 0 + 5 = 5`
**Value at line 12:** 5
5. At line 19, this is the final print of the score:
```python
print(score)
```
Since line 12 calculated the score as 5,
**Value at line 19:** 5
### Summary of Values:
1. Value at line 3: **30**
2. Value at line 5: **35**
3. Value at line 7: **0**
4. Value at line 12: **5**
5. Value at line 19: **5**
There are no human answers yet. A form for humans to post answers is coming very soon!