# 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("6_comments_q", "week_2", "readings", assignment_points = 12.0, assignment_tag = 'week2-readings')

# Initialize Otter
import otter
grader = otter.Notebook("6_comments_q.ipynb")

โ“ Commenting#

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

Commenting Simon Says#

We have provided you with a function that:

  1. Takes a single argument command, which is a string.

  2. Executes one of four predefined actions based on the value of the command string:

    • If the command is โ€œjumpโ€, return โ€œSimon says: Jump high!โ€.

    • If the command is โ€œrunโ€, return โ€œSimon says: Run fast!โ€.

    • If the command is โ€œstopโ€, return โ€œSimon says: Stop immediately!โ€.

    • If the command is โ€œdanceโ€, return โ€œSimon says: Show your moves!โ€.

    • If the command is anything else, return โ€œSimon didnโ€™t say that!โ€.

Instructions:#

Include comments within the function to describe each action explicitly. The comments should be structured like this:

if command == "walk":
        # If the command is "walk", Simon says to walk slow.
        return "Simon says: Walk slow!"
def simon_says_actions(command):

    # Check the command and respond accordingly
    if command == "jump":
        ...
        return "Simon says: Jump high!"
    elif command == "run":
        ...
        return "Simon says: Run fast!"
    elif command == "stop":
        ...
        return "Simon says: Stop immediately!"
    elif command == "dance":
        ...
        return "Simon says: Show your moves!"
    else:
        # If the command is unrecognized, Simon didn't say that.
        return "Simon didn't say that!"
    
print(simon_says_actions("jump")) # Should return "Simon says
grader.check("question-Simon-Says")

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("week2-readings", "6_comments_q")