Asked by Name

trainer = "Mr. Brown"

class User:
active = True

def __init__(self,name,age,height,weight,level_of_fitness):
self.name = name
self.age = age
self.height = height
self.weight = weight
self.level_of_fitness = level_of_fitness
self.activities = []

def cancel(self):
self.active = False
print(f"{self.name} has cancelled their account.")

def add_activity(self,activity):
# Check for active membership
if self.active:
self.activities.append(activity)
print(f"{self.name} decided to try {activity} today!")
else:
print(f"{self.name} has an inactive account. Please activate in order to add more activities.")

def reactivation(self):
if self.active:
print(f"{self.name} already has an active account.")
else:
self.active = True
print(f"Welcome back, {self.name}! We're happy to have you back on board the KeepMoving app!")

def __str__(self):
return f"{self.name} is {self.age} years old, {self.height} in inches tall, weighs {self.weight} lbs, and has a level of fitness of {self.level_of_fitness}. Personal Trainer: {trainer}. Account active? {self.active}"

jerry = User("Jerry",22,72,175,7)
susan = User("Susan",31,67,110,10)
rick = User("Rick",19,62,145,3)

print(jerry)
print(susan)
print(rick)

jerry.add_activity("cycling")
print(jerry.activities)

jerry.cancel()
jerry.add_activity("weight lifting")
print(jerry.activities)

jerry.reactivation()
jerry.add_activity("weight lifting")
print(jerry.activities)

print(jerry)
trainer = "Mr. Simmons"
print(susan)
print(rick)

jerry.reactivation()
print(jerry)

In the example above, which of the following statements is false?(1 point)
Responses

The User class occupies lines 3 to 34.
The User class occupies lines 3 to 34.

On line 4, active is a global variable with a value of "True"
On line 4, active is a global variable with a value of "True"

On line 1, trainer is a global variable with a value of "Mr. Brown"
On line 1, trainer is a global variable with a value of "Mr. Brown"

This example instantiates three users.
This example instantiates three users.
Question 2
In the example above, how many methods are included in the User Class?(1 point)
Responses

2
2

3
3

5
5

6
In the example above, we execute the following print statement on line 49:
print(jerry.activities)
Which activities are present in Jerry's activities list on this line?

(1 point)
Responses

[ ]
[ ]

['cycling']
['cycling']

['cycling','weight lifting']
['cycling','weight lifting']

['cycling','weight lifting','Mr. Brown']
['cycling','weight lifting','Mr. Brown']
Question 4
In the example above, which line demonstrates the use of a local variable?(1 point)
Responses

1
1

4
4

20
20

36
In the example above, which lines represent users being instantiated? (1 point)
Responses

Line 6 to Line 12
Line 6 to Line 12

Line 36 to Line 38
Line 36 to Line 38

Line 51
Line 51

Line 40 to Line 42
In the example above, there is a comment on line 19 that reads "# Check for active membership". This is text that will not be executed as code, but is there to provide a rationale for the code that follows it. If you were to add a comment on line 27 BEFORE the "if" statement, which of the following would be the best comment to include?(1 point)
Responses

# Local variable example
# Local variable example

# Check for active membership
# Check for active membership

# Global variable example
# Global variable example

# This is an if-statement
Using the example above, drag and drop the answer choices to categorize the users based on who their trainer is at various stages of the output.(4 points)
Put responses in the correct input to answer the question. Select a response, navigate to the desired input and insert the response. Responses can be selected and inserted using the space bar, enter key, left mouse button or touchpad. Responses can also be moved by dragging with a mouse.
trainer = "Mr. Brown" trainer = "Mr. Simmons"
Select to move response to a response input area.Jerry at Line 40Select to move response to a response input area.Jerry at line 55Select to move response to a response input area.Rick at line 42Select to move response to a response input area.Susan at line 57

All Answers 1

Answered by GPT-5 mini AI
Here are the answers:

Question 1 — Which statement is false?
- On line 4, active is a global variable with a value of "True". (This is false — active is a class variable, not a global variable.)

Question 2 — How many methods are included in the User class?
- 5 (__init__, cancel, add_activity, reactivation, __str__)

Question 3 — What are Jerry's activities at the print on line 49?
- ['cycling']

Question 4 — Which line demonstrates the use of a local variable?
- Line 20 (uses the method parameter/ local variable context such as self/activity)

Question 5 — Which lines represent users being instantiated?
- Line 36 to Line 38

Question 6 — Best comment to add on line 27 BEFORE the "if" statement?
- # Check for active membership

Question 7 — Trainer assignment at the indicated lines:
- Jerry at Line 40 -> trainer = "Mr. Brown"
- Jerry at Line 55 -> trainer = "Mr. Brown"
- Rick at Line 42 -> trainer = "Mr. Brown"
- Susan at Line 57 -> trainer = "Mr. Simmons"