2.17.4 Rating CodeHS Answers

We thoroughly check each answer to a question to provide you with the most correct answers. Found a mistake? Tell us about it through the REPORT button at the bottom of the page. Ctrl+F (Cmd+F) will help you a lot when searching through such a large set of questions.

The most common answer is:

rating= 8
def red_ex():
for i in range(4):
def yellow_line():
def green_check():
for i in range(2):
number = int(input("Enter a number: "))
if number < 5:
elif number == 7:

Turtle graphics allows for drawing shapes and patterns by moving a “turtle” around the screen. The script defines three different functions (red_ex, yellow_line, and green_check) to draw specific shapes in different colors, and then executes one of these functions based on user input. Here’s a breakdown of how the script works:

  1. Setting a Default Rating: Initially, a variable rating is set to 8, but it’s not used anywhere in the provided code. It might be a remnant from an earlier version of the script or intended for future use.
  2. Function Definitions:
    • red_ex(): Draws an “X” shape in red. It sets the pen size to 5, changes the color to red, rotates 45 degrees to the left, and then draws lines in a loop to create the “X” shape.
    • yellow_line(): Draws a single line in yellow. It sets the pen size to 5, changes the color to yellow, and moves forward to draw the line.
    • green_check(): Draws a checkmark shape in green. It sets the pen size to 5, changes the color to green, rotates 45 degrees to the left, and then draws lines in a loop to create the checkmark.
  3. User Input: The script asks the user to enter a number via the input() function. Based on this input, it decides which shape to draw:
    • If the number is less than 5, it calls red_ex() to draw a red “X”.
    • If the number is exactly 7, it calls yellow_line() to draw a yellow line.
    • For any other number, it calls green_check() to draw a green checkmark.
  4. Execution Flow: The script waits for the user’s input, evaluates the input number, and then executes one of the defined functions to draw the corresponding shape.

This script illustrates conditional logic, function definition and invocation, and the basics of turtle graphics in Python. However, to run this script, you must ensure it’s executed in an environment where the turtle graphics library is supported and properly imported. The pensize(), color(), left(), forward(), backward(), and similar functions are part of the turtle graphics API, and they control the drawing turtle’s appearance and movement.

Without the necessary import statement (usually import turtle at the beginning of the script), the script would raise an error due to undefined functions.

Was this helpful?

Quizzma Team
+ posts

The Quizzma Team is a collective of experienced educators, subject matter experts, and content developers dedicated to providing accurate and high-quality educational resources. With a diverse range of expertise across various subjects, the team collaboratively reviews, creates, and publishes content to aid in learning and self-assessment.
Each piece of content undergoes a rigorous review process to ensure accuracy, relevance, and clarity. The Quizzma Team is committed to fostering a conducive learning environment for individuals and continually strives to provide reliable and valuable educational resources on a wide array of topics. Through collaborative effort and a shared passion for education, the Quizzma Team aims to contribute positively to the broader learning community.

Leave a Comment

Your email address will not be published. Required fields are marked *