# 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 givenamount, 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")