# You must make sure to run all cells in sequence using shift + enter or you might encounter errors
from pykubegrader.initialize import initialize_assignment

responses = initialize_assignment("3_headis_q", "week_7", "readings", assignment_points = 19.0, assignment_tag = 'week7-readings')

# Initialize Otter
import otter
grader = otter.Notebook("3_headis_q.ipynb")

๐Ÿ“ Classes and Instances in Headis#

Headis is a fast-paced sport that blends table tennis and soccer, where players use their heads instead of paddles to hit the ball. Just like in programming, where we define classes to structure objects, Headis players have their own attributes and behaviorsโ€”speed, agility, and skill levels. Letโ€™s explore how we can represent this sport using Python classes!

# Run this block of code by pressing Shift + Enter to display the question
from questions._3_headis_q import Question1
Question1().show()
# Run this block of code by pressing Shift + Enter to display the question
from questions._3_headis_q import Question2
Question2().show()
# Run this block of code by pressing Shift + Enter to display the question
from questions._3_headis_q import Question3
Question3().show()

Question 1 (Points: 12.0): ๐ŸŽพ Free Response: Design a HeadisPlayer Class#

Imagine youโ€™re creating a HeadisPlayer class in Python. Your class should include:

  • Attributes for the playerโ€™s name, speed, and accuracy.

  • A method called hit_ball() that prints "Player {name} hits the ball!"

  • A method improve_skill() that increases accuracy by a given amount, and print โ€œ{self.name}โ€™s accuracy increased to {self.accuracy}!โ€.

Write your class definition below.

...

# Example usage
player1 = HeadisPlayer("Alex", 8, 75)
player1.hit_ball()
player1.improve_skill(5)
grader.check("headis-player-class-design")

Submitting Assignment#

Please run the following block of code using shift + enter to submit your assignment, you should see your score.

from pykubegrader.submit.submit_assignment import submit_assignment

submit_assignment("week7-readings", "3_headis_q")