Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Please help me with the following 8 Python multiple choices questions. Thank you very much. Here's the outline for a class that we'll work with
Please help me with the following 8 Python multiple choices questions. Thank you very much.
Here's the outline for a class that we'll work with in the next few questions. class Hockey Team: " "A hockey team in a league === Attributes === name: the name of this team games_played: number of games this team has played wins: the number of games this team has won name: str games_played: int wins: int def __init__(self, name: str) -> None: "Initialize this hockey team, with no games played ye # TODO: Record team name. # TODO: Set number of games and wins to zero. def record_result(self, result: str) -> None: " "Record a win/loss from a game. Precondition: result == 'W' or result == 'L'. # TODO: Update number of games played and number of win # as appropriate. Question 1 1 pts Which of the following correctly creates a team called the 'DCS timbits'? team.Hockey Team('DCS timbits') team = Hockey Team(self, 'DCS timbits") O team = new Hockey Team('DCS timbits') O team - Hockey Team('DCS timbits, 0,0) team = HockeyTeam('DCS timbits") O team = Hockey Team(self, 'DCS timbits O) Question 2 1 pts Which of the following is true? O An initializer never has a return statement, or always returns None. An initializer has a return statement if and only if the newly constructed object has at least one instance attribue. An initializer may have a return statement that returns a non-None value, but this is optional. An initializer must have a return statement. Question 3 1 pts Now consider the body of our initializer. Which line of code correctly records the team name? name = self.name self.name = teamName self.name = name Oself.teamName = name O name = name Question 4 1 pts Which of the following is a correct body for method HockeyTeam.record_result? self.games_played += 1 if result == 'W': self.wins += 1 return self self.games_played += 1 if result == 'W': self.wins += 1 self.games_played += 1 if result == 'W': self.wins += 1 return HockeyTeam(self.name) self._init__(self.name) self.games_played += 1 if result == 'W': self.wins += 1 D Questi Question 5 1 pts Suppose we complete the class correctly, import it, and run this line of code. team - HockeyTeam('Team 148') Which of the following lines will run without error? team.record_result(team, 'W') team.record_result('W') HockeyTeam.record_result(team, 'W') Hockey Team.record_result('W') team.record_result(self, 'W') Question 6 1 pts Now suppose we successfully call record_result to record a win and the method has just started. The state of memory is as shown below. | id26 Hockey Team name Lidzl games-played ids Hockey Team. record-result wins [idll self result lid30] int -main-- ids team [id26] lidzil str str 148 What id should go in the box next to self in the top stack frame? Write your answer in the form "idX", where X is the correct number. U Question 7 1 pts Suppose we've created another team and stored it in the variable team. Which of the following would be the correct way to get team2 's name? name(team2) team2.name self.name Hockey Team.name(team2) Question 8 1 pts Now, suppose we have both team and team which are Hockey Teams. Both teams have had multiple games recorded, and we want to know if team had more wins than team2 or not. Which of the following would return True if team had more wins than team? team > team2 O team.wins > team2.wins team2.wins > team.wins team.games_played > team2.games_playedStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started