CodeHS Python Answers Key 2021 [*FREE ACCESS*]


In this session, we will be showing you CodeHS python answers for free.

 

CodeHS Python Answers Key

Before solving Python related problems let us answer few basic definitions you must know:

Q. ()
Ans: A valid way to start a function in Python.

Q. and
Ans: The Boolean operator that only returns true if BOTH of its operands are true.

Q. or
Ans: The Boolean operator that returns true if EITHER of its operands is true.

Q. not
Ans: The Boolean operator that returns true if its single operand is false.

Q. return <value>
Ans: Specifies the value to be returned by a function back to its function call.

Q. time.sleep(seconds)
Ans: Instructs the program to pause for the specified number of seconds.

Q. :
Ans: A colon marks the end of a statement and indicates that the next line should be the beginning of a new block.

Q. Break
Ans: Code if you want to immediately jump out of a block of code.

Q. Monty Python
Ans: A British surreal comedy group after which Python was named.

Q. =
Ans: Assignment operator

Q. <variable> = <expression>
Ans: Assignment statement

Q. import <module>
Ans: Loads an existing Python module into the current program.

Q. block
Ans: One or more lines of code grouped together with the same minimum amount of indentation.

Q. while <condition>:
Ans: Begins a pre-test loop and doesn’t stop until the end of the loop.

Q. if <condition>:
Ans: Begins a binary selection statement.

Q. break
Ans: Tells the program to immediately jump out of a while-block.

Q. random.randint(low, high)
Ans: Returns a random integer between (and including) the two integers we give it.

Q. int(string)
Ans: Converts the string argument to its integer form.

Q. str(number)
Ans: Converts a numeric argument to its string form.

Q. true
Ans: The Boolean data value for yes/on/one.

Q. false
Ans: The Boolean data value for no/off/zero.

Q. ==
Ans: The comparison operator for equality. Used in conditions, “Is value1 equal to value2?”

Q. raw_input()
Ans: A function that takes user keyboard input and returns it to the program as a string.

Q. \
Ans: Backslash, the Python string escape character.

Q. /
Ans: Forward slash, the Python division operator.

Q. \\
Ans: Represents a single backslash in a Python string.

Q. \n
Ans: Represents a new line in a Python string.

Q. \t
Ans: Represents a tabbed space in a Python string.

Q. \’
Ans: Represents an apostrophe in a Python string.

Q.
Ans: A single quote, can be used to surround a string literal value.

Q.
Ans: Double quotes, can be used to surround a string literal value.

Q. end=”
Ans: A keyword parameter for the print() function that causes the function to NOT add a newline at the end of the string.

Q. print string=name_string.upper()
Ans: This would print whatever has been defined as a name in upper case letters.

Q. + – * /
Ans: Mathematical expressions

Q. variable purpose
Ans: Stores a value.

Q. Print
Ans: A function in Python that is always available.

Q. random
Ans: A function you have to call.

Q. < or >
Ans: Comparison operator.

Q. else
Ans: Keyword used to add an alternative condition to an if statement.

 

Solved CodeHS Python Problems

It’s time to do few problems related to Python recommended by CodeHS educators:

Q. HAppy Face
Ans:
speed(0)
happy = input(“are you happy: “)
def happy_face():
if happy == “yes”:
penup()
setposition(0,-50)
pendown()
begin_fill()
color(“yellow”)
circle(50)
end_fill()
penup()
setposition(-15,15)
pendown()
begin_fill()
color(“black”)
circle(5)
end_fill()
penup()
forward(30)
pendown()
begin_fill()
circle(5)
end_fill()
penup()
setposition(-32.5,-5)
pendown()
right(90)
pensize(5)
circle(32,180,100)
else:
pendown()
happy_face()
penup()

 

Q. Black ANd WHithe sq
Ans:
speed(0)
penup()
setposition(-90,0)
pendown()
def black_and_white():
begin_fill()
color(“black”)
for i in range(5):
penup()
forward(30)
left(90)
end_fill()
count = 0
for i in range(5):
penup()
forward(30)
pendown()
if count % 2 != 0:
begin_fill()
color(“black”)
forward(20)
left(90)
forward(20)
left(90)
forward(20)
left(90)
forward(20)
left(90)
if count % 2 != 0:
end_fill()
count = count + 1
black_and_white()

 

Q. 5.2.4
Ans:
def rex():
color(“red”)
left(45)
forward(50)
backward(100)
forward(50)
right(45)
right(45)
forward(50)
backward(100)
forward(50)
def line():
color(“yellow”)
backward(50)
forward(100)
def check():
color(“green”)
right(45)
right(45)
right(45)
backward(100)
forward(200)
right(45)
right(45)
forward(50)
number = int(input(“Enter a rating: “))
if number <= 4:
rex()
elif number == 5:
line()
elif number == 6:
line()
elif number == 7:
line()
else:
check()

 

Q. 5.2.5
Ans:
speed(0)
happy = input(“are you happy: “)
def happy_face():
if happy == “yes”:
penup()
setposition(0,-50)
pendown()
begin_fill()
color(“yellow”)
circle(50)
end_fill()
penup()
setposition(-15,15)
pendown()
begin_fill()
color(“black”)
circle(5)
end_fill()
penup()
forward(30)
pendown()
begin_fill()
circle(5)
end_fill()
penup()
setposition(-32.5,-5)
pendown()
right(90)
pensize(5)
circle(32,180,100)
else:
pendown()
happy_face()
penup()

 

Q. 5.3.4
Ans:
speed(0)
length = 50
while length < 400:
penup()
right(90)
forward(25)
left(90)
backward(length/2)
pendown()
for i in range(4):
forward(length)
left(90)
forward(length/2)
length = length + 50

 

Q. 5.3.5
Ans:
speed(0)
user_number = int(input(“Guess the number: “))
secret_number = 5
def check():
pensize(5)
color(“green”)
right(45)
right(45)
right(45)
backward(100)
forward(200)
right(45)
right(45)
forward(50)
def up():
pensize(5)
left(90)
backward(100)
forward(200)
left(45)
backward(45)
forward(45)
right(45)
right(45)
backward(45)
forward(45)
def down():
pensize(5)
right(90)
backward(100)
forward(200)
left(45)
backward(45)
forward(45)
right(45)
right(45)
backward(45)
forward(45)
if user_number == secret_number:
check()
elif user_number > secret_number:
down()
else:
up()

 

Q. 6.1.5: Weather
Ans:
def is_sunny():
print(“On a sunny day, sandals are appropriate footwear.”)
def is_rainy():
print(“On a rainy day, galoshes are appropriate footwear.”)
def is_snowy():
print(“On a snowy day, boots are appropriate footwear.”)
weather_outside= input(“Whats the weather like? (sunny, rainy, snowy): “)
if weather_outside == “sunny”:
is_sunny()
elif weather_outside == “rainy”:
print(“On a rainy day, galoshes are appropriate footwear.”)
elif weather_outside == “snowy”:
print(“On a snowy day, boots are appropriate footwear.”)
else:
print(“Invalid option.”)

 

Q. 6.2.5: Print Product
Ans:
def print_value(x,y):
print(x)
print(y)
print_value(12,4)
print_value(“dog”)

 

Q. 6.2.6: Print Multiple Times
Ans:
def print_multiple_times(x,y):
print(x)
print(y)
print_multiple_times(4,5)
print_multiple_times(“hi, maybe”)

 

Q. 6.2.8: Area of a Square with default paremeters
Ans:
def calculate_area(side_length = 10):
calculate_area = side_length ** 2
print(“The area of a square with sides of length ” + str(side_length) + “is” + str(calculate_area) + “.”)
side_length = int(input(“How many sides? “))
if side_length <= 0:
calculate_area()
else:
calculate_area(side_length)

 

Q. 6.3.7: Add, Subtract, or Multiply
Ans:
num1 = int(input(“What is the first number?: “))
num2 = int(input(“What is the second number?: “))
def add():
sum = num1+num2
print(str(num1) + ” + ” +str(num2) + ” = ” + str(sum))
def subtract():
sum = num1-num2
print(str(num1) + ” – ” +str(num2) + ” = ” + str(sum))
def multiply():
sum = num1*num2
print(str(num1) + ” * ” +str(num2) + ” = ” + str(sum))
def invalid():
print(“An invalid option was selected”)
Operation = str(input(“Choose an operation (add, subtract, multiply): “))
if(Operation==”add”):
add()
elif(Operation==”subtract”):
subtract()
elif(Operation==”multiply”):
multiply()
else:
invalid()

 

Q. 6.4.4: Add One
Ans:
def return_ten():
return 10
print(return_ten())
x = return_ten()
print(x + 1)
6.4.8: Sum Two Numbers
def return_ten(4,8):
return 10
print(return_ten())
x = return_ten()
print(x + 1)

 

Q. 6.4.9: Temperature Converter
Ans:
# Write your function for converting Celsius to Fahrenheit here.
# Make sure to include a comment at the top that says what
# each function does!
def fahrenheit_to_celcius(fahrenheit):
return (fahrenheit – 32) / 1.8
# Now write your function for converting Fahrenheit to Celsius.
def celcius_to_fahrenheit(celcius):
return celcius * 1.8 + 32
# Now change 0C to F:
print (“0C In F: ” + str(celcius_to_fahrenheit(0)))
# Change 100C to F:
print (“100C In F: ” + str(celcius_to_fahrenheit(100)))
# Change 40F to C:
print (“40F In C: ” + str(fahrenheit_to_celcius(40)))
# Change 80F to C:
print (“80F In C: ” + str(fahrenheit_to_celcius(80)))

 

Q. 6.5.5: Temperature Converter part 2
Ans:
def fahrenheit_to_celcius(fahrenheit):
return (fahrenheit – 32) / 1.8
# Now write your function for converting Fahrenheit to Celsius.
def celcius_to_fahrenheit(celcius):
return celcius * 1.8 + 32
#ask te user to enter a temperature
try:
temperature = int(input(“Enter a temp: “))
except ValueError:
print(“That wasn’t an integer.”)
# Now change 0C to F:
print (“0C In F: ” + str(celcius_to_fahrenheit(0)))
# Change 100C to F:
print (“100C In F: ” + str(celcius_to_fahrenheit(100)))
# Change 40F to C:
print (“40F In C: ” + str(fahrenheit_to_celcius(40)))
# Change 80F to C:
print (“80F In C: ” + str(fahrenheit_to_celcius(80)))

 

Q. 6.5.6: Enter a Positive Number
Ans:
name = input(“Enter your name: “)
age = -1
try:
age = int(input(“Enter your age: “))
except ValueError:
print(“That wasn’t an integer.”)
# Print name and age, using default age if user did not enter an integer
print(“Name: ” + name)
print(“Age: ” + str(age))

 

Q. 5.1.6: 2 Through 20 Even
Ans:
x = 2
while x <= 20:
print (x)
x = x + 2

 

Q. 5.1.7: Divisibility
Ans:
number= 3
numerator = int(input(“Enter a numerator: “))
denominator = int(input(“Enter denominator: “))
# Use a while loop here to repeatedly ask the user for
# a denominator for as long as the denominator is 0
# (or, put another way, until the denominator is not
# equal to 0).
if int(numerator / denominator) * denominator == numerator:
print(“Divides evenly!”)
else:
print(“Doesn’t divide evenly.”)
while number >3:
print(“code complete”)

 

Q. 5.2.5: Counting 10 to 100 by tens
Ans:
for i in range(1,11):
print(i* 10)

 

Q. 5.2.8: Average Test Score
Ans:
total = 0
for i in range(3):
score = int(input(“Enter a score: “))
total = total + score
average = total / 3.0
print (“Average: ” + str(average))

 

Q. 5.2.9: How Many Names?
Ans:
full_name = “”
number_of_names = int(input(“How many names do you have? “))
for i in range(number_of_names):
next_name = input(“Enter a name: “)
full_name = full_name + next_name + ” “
print (full_name)

 

Q. 5.3.7: Higher/ Lower
Ans:
magic_number = 3
while True:
guess = int(input(“Guess my number: “))
if guess == magic_number:
print(“Correct!”)
break
print(“Too high!”)
# Print this sentence once number has been guessed
print(“Great job guessing my number!”)

 

Q. 5.3.8: Higher / Lower 2.0
Ans:
magic_number = 3.3312
while True:
user_number = float(input(“Enter a number between 1 and 100: “))
if round(user_number, 2) == round(magic_number, 2):
print (“Correct!”)
break
elif round(user_number,2) > round(magic_number, 2):
print (“Too high!”)
else:
print (“Too low!”)

 

Q. 5.4.6: Rolling Dice
Ans:
#set numbers i in range
for i in range(1,7):
#set numbers j in range
for j in range(1,7):
#print dice numbers
print (str(i) + “,” + str(j))

 

Q. 5.4.7: Categories
Ans:
for i in range(3):
category = input(“Enter a category: “)  
example = “”
for j in range(3):
example += input(“Enter something in that category: “)
print(category+ “: ” + example)

 

CodeHS Tracy The Turtle Answers

Before solving Python Tracy The Turtle related problems let us show you how it works:

Q. forward(distance)
Ans: Moves Tracy forward a specific distance.

Q. circle(radius)
Ans: Tells Tracy to draw a circle with a specified radius.

Q. backwards(distance)
Ans: Moves Tracy backwards a specified distance.

Q. penup()
Ans: Stops Tracy from leaving a trail.

Q. pendown()
Ans: Has Tracy start drawing a trail.

Q. right(degrees)
Ans: Moves Tracy right a specified amount of degrees.

Q. left(degrees)
Ans: Moves Tracy left a specified amount of degrees.

Q. for loops
Ans: Repeats a code a fixed number of times.

Q. for i in range(number):
Ans: Initiates a loop that repeats the number of times specified.

Q. setposition(x,y)
Ans: Moves Tracy to a specified coordinate.

Q. right(angle)
Ans: Tracy turns right at a specified angle.

Q. left(angle)
Ans: Tracy turns left at a specified angle.

Q. speed(number 0-10)
Ans: Sets how quickly Tracy will move through commands.

Q. #comment
Ans: In line phrases or sentences in the code that give information or direction.

Q. “””Comments”””
Ans: Multi line phrases or sentences in the code that give information or direction.

Q. color(“color_name”)
Ans: Changes the color of Tracy’s trail.

Q. begin_fill()
Ans: Starts filling in drawn shapes.

Q. end_fill()
Ans: Stops filling in drawn shapes.

Q. pensize(number)
Ans: Changes the thickness of Tracy’s trail.

Q. circle(radius, extent, steps)
Ans: Controls the radius, degrees, and number of points of a circle.

Q. comments
Ans: Phrases / sentences we enter into code to give information / direction.

Q. top down design
Ans: A problem solving approach in which a large problem is broken into a smaller more manageable parts to make it easier to find a solution.

 

Solved CodeHS Python Tracy The Turtle Problems

It’s time to do few problems related to Python Tracy The Turtle recommended by CodeHS educators:

Q. 2.1.4: Stretched Slinky
Ans:
circle(35)
forward(40)
circle(35)
forward(40)
circle(35)
forward(40)
circle(35)
forward(40)
circle(35)
forward(40)

 

Q. 2.2.4: Shorter Dashed Line
Ans:
penup()
backward(200)
pendown()
forward(50)
penup()
forward(50)
pendown()
forward(50)
penup()
forward(50)
forward(50)
penup()
forward(50)
pendown()
forward(50)
penup()
forward(50)
pendown()

 

Q. 2.2.5: Caterpillar
Ans:
circle(20)
penup()
forward(40)
pendown()
circle(20)
penup()
forward(40)
pendown()
circle(20)
penup()
forward(40)
pendown()
circle(20)
penup()
forward(40)
pendown()
circle(20)
penup()
forward(40)
pendown()
penup()

 

Q. 2.3.5: Rectangle
Ans:
forward(50)
left(90)
forward(100)
left(90)
forward(50)
left(90)
forward(100)
left(90)

 

Q. 2.3.6: 4 Columns
Ans:
penup()
left(90)
forward(200)
right(90)
right(90)
pendown()
forward(400)
penup()
left(90)
forward(100)
left(90)
pendown()
forward(400)
penup()
left(90)
left(90)
forward(400)
right(90)
forward(200)
right(90)
pendown()
forward(400)

 

Q. 2.4.5: Row of Circles
Ans:
pendown()
backward(190)
for i in range (20):
pendown()
circle(20)
penup()
forward(20)

 

Q. 2.4.6: 4 Columns 2.0
Ans:
pendown()
backward(190)
for i in range (20):
forward(200)
right(90)
right(90)
pendown()
forward(400)
penup()
left(90)
forward(100)
left(90)
pendown()
forward(400)
penup()
left(90)
left(90)
forward(400)
right(90)
forward(200)
right(90)
pendown()
forward(400)

 

Q. 2.5.5: Hexagon
Ans:
left(30)
for i in range(6):
forward(50)
left(60)

 

Q. 2.5.6: ‘X’ Marks the Spot
Ans:
left(45)
for i in range(4):
forward(100)
backward(100)
left(90)

 

Q. 2.5.7: Circle Pyramid
Ans:
penup()
setposition(-100,-200)
for i in range (3):
pendown()
circle(50)
penup()
forward(100)
setposition(-50,-100)
for i in range (2):
pendown()
circle(50)
penup()
forward(100)
setposition(0,0)
for i in range (1):
pendown()
circle(50)
penup()
forward(100)

 

Q. 2.6.4: Circle Pyramid with Comments
Ans:
“””In this code Tracey will build a pyrimid”””
penup()
setposition(-100,-200)
for i in range (3):
pendown()
circle(50)
penup()
forward(100)
setposition(-50,-100)
#Now Tracey will draw a circle
for i in range (2):
pendown()
circle(50)
penup()
forward(100)
setposition(0,0)
for i in range (1):
pendown()
circle(50)
penup()
forward(100)
#Now Tracey will take a break

 

Q. 2.8.4: Beaded Bracelet
Ans:
“””this code will make Tracey a bead bracelet for her b-day”””
def draw_beaded_braclet():
for i in range(36):
forward(10)
pendown()
circle(10)
left(10)
penup()
draw_beaded_braclet()

 

Q. 2.8.5: Shape Stack
Ans:
“””This code will help Tracey put her toy blocks into a tall stack”””
def draw_circle_stack():
for i in range(4):
pendown()
circle(25)
forward(100)
def draw_square_stack():
left(90)
for i in range(4):
pendown()
left(90)
circle(50, 360, 4)
draw_square_stack()
draw_circle_stack()

 

Q. 2.9.5: Four Colored Triangles
Ans:
penup()
backward(100)
def draw_loop_thingy():
for i in range(4):
pensize(5)
pendown()
left(60)
color(“green”)
draw_loop_thingy()
forward(50)
right(120)
color(“blue”)
forward(50)
color(“red”)
right(120)
forward(50)
penup()
left(180)
forward(50)

 

Q. 2.9.6: Colorful Bracelet
Ans:
“””this code will make Tracey a bead bracelet for her b-day”””
def draw_beaded_braclet():
for i in range(36):
color(“purple”)
forward(10)
pendown()
circle(10)
left(10)
penup()
color(“blue”)
forward(10)
color(“red”)
draw_beaded_braclet()

 

Q. 2.11.4: Dartboard
Ans:
penup()
radius=2
for i in range(25,101,25):
setposition(0,0)
right(90)
forward(i)
left(90)
pendown()
circle(i)
penup()
def draw_something():
forward(20)

 

Q. 2.11.5: Line of Increasing Blocks
Ans:
speed(3)
size=10
def make_square():
for i in range(4):
pendown()
forward(size)
left(90)
setposition(-150,0)
for i in range(5):
make_square()
penup()
forward(2*size)
size=size+10

 

Q. 2.12.4: Colored Dartboard
Ans:
radius=100
for i in range(4):
penup()
setposition(0,0)
right(90)
forward(radius)
left(90)
color_choice= input(“what color should the circle be?”)
color(color_choice)
begin_fill()
circle(radius)
end_fill()
radius=radius-25

 

Q. 2.12.5: Four Corners
Ans:
int(input(“square_length”))
penup()
setposition(-200,-200)
pendown()
left(90)
for i in range(4):
forward(50)
right(90)
penup()
forward(400)
pendown()
right(90)
for i in range(4):
forward(50)
right(90)
forward(400)
pendown()
right(90)
for i in range(4):
forward(50)
right(90)
forward(400)
pendown()
right(90)
for i in range(4):
forward(50)
right(90)

 

Q. 2.13.5: Circle in a Square
Ans:
first_radius=int(input(“what is the first circle’s radius?:”))
def draw_square_big(color_choice, radius_choice):
penup()
backward(first_radius)
pendown()
color(color_choice)
begin_fill()
for i in range(4):
forward(first_radius*2)
left(90)
end_fill()
def draw_circle_wide(color_choice, radius_choice):
pendown()
color(color_choice)
begin_fill()
circle(radius_choice)
end_fill()
penup()
setposition(0,-first_radius)
draw_square_big(“red”, first_radius)
penup()
setposition(0,-first_radius)
draw_circle_wide(“blue”, first_radius)

 

Q. 2.13.6: Snowman
Ans:
# put imput
inputs = [100]
#functions
def draw_circle(radius):
pendown()
begin_fill()
circle(radius)
end_fill()
penup()
left(90)
forward(radius*2)
right(90)
penup()
setposition(0,-200)
color(“gray”)
bottom_radius = int(input(“What should the radius of the bottom circle be?: “))
#parameters
draw_circle(bottom_radius)
draw_circle(bottom_radius/2)
draw_circle(bottom_radius/4)

 

Q. 2.14.4: Geometry 2.0
Ans:
penup()
setposition(0,-100)
pendown()
radius = 20
for i in range(7):
circle(radius,360,i)
radius=(radius + 20)

 

Q. 2.15.4: Dartboard using i
Ans:
penup()
radius=2
for i in range(25,101,25):
setposition(0,0)
right(90)
forward(i)
left(90)
pendown()
circle(i)
penup()
def draw_something():
forward(20)

 

Q. 2.15.5: Phone Signal
Ans:
for i in range(10, 51, 10):
forward(10)
left(90)
forward(i)
left(90)
forward(10)
left(90)
forward(i)
left(90)
penup()
forward(25)
pendown()

 

Q. 2.16.4: Happy Face
Ans:
inputs = [“Yes”]
def draw_eye():
color(“black”)
begin_fill()
pendown()
circle(10)
end_fill()
penup()
happy = input(“Are you happy? (Yes/No): “)
if happy == “Yes”:
penup()
right(90)

 

Q. 2.16.5: Black and White Squares
Ans:
inputs = [“Yes”]
def draw_black_square():
color(“black”)
begin_fill()
pendown()
circle(10)
end_fill()
penup()
black = input(“Is square black? (Yes/No): “)
if black %”Yes”:
penup()
right(90)
for i in range(1):
pendown()

 

Q. 2.17.4: Rating
Ans:
rating= 8
def red_ex():
pensize(5)
color(“red”)
left(45)
for i in range(4):
forward(100)
backward(100)
left(90)
def yellow_line():
pensize(5)
color(“yellow”)
forward(100)
def green_check():
pensize(5)
color(“green”)
left(45)
for i in range(2):
forward(100)
backward(100)
number = int(input(“Enter a number: “))
if number < 5:
red_ex()
elif number == 7:
yellow_line()
else:
green_check()
Happy/ Sad Face
inputs = [“Yes”]
def draw_eye():
color(“black”)
begin_fill()
pendown()
circle(10)
end_fill()
penup()
happy = input(“Are you happy? (Yes/No): “)
if happy == “Yes”:
penup()
right(90)

 

Q. 2.18.4: Increasing Squares
Ans:
length = 50
speed(0)
#while loop for drawing the squares
def drawSquare(l):
for i in range(4):
forward(l)
left(90)
while length < 400:
penup()
backward(length/2)
right(90)
forward(length/2)
left(90)
pendown()
drawSquare(length)
penup()
forward(length/2)
left(90)
forward(length/2)
right(90)
length = length + 50

 

Q. 2.18.5: Guess a Number
Ans:
“tracy is ask user to guess number from 1-10”
#user number
user_number= int(input(“Pick a number from 1-10?:”))
#variable for secret number
secret_number=7
def draw_checkmark():
penup()
backward(50)
right(90)
pendown()
pensize(15)
color(“green”)
left(45)
forward(50)
left(90)
forward(100)
penup()
draw_checkmark()

 

Q. 2.19.4: Guess a Number 2.0
Ans:
“tracy is ask user to guess number from 1-10”
#user number
user_number= int(input(“Pick a number from 1-10?:”))
#variable for secret number
secret_number=7
def draw_checkmark():
penup()
backward(50)
right(90)
pendown()
pensize(15)
color(“green”)
left(45)
forward(50)
left(90)
forward(100)
penup()
draw_checkmark()
if user_number < 5:
circle(50)
elif count > 5:
circle(50,360,4)
else:
forward(50)

 

Q. 2.19.5: Circle Pyramid 2.0
Ans:
radius = int(input(“What is the radius of the circle? “))
row_value= int(input(“What is the row value of the circle? “))
def row_value():
setposition(0, radius)
for i in range(15):
circle(25)
row_value()

 

Q. 2.19.6: Checkerboard
Ans:
speed(0)
def move_up_a_row():
left(90)
forward(40)
right(90)
backward(400)
def square():
for i in range(4):
forward(40)
left(90)
def draw_two_square_rows():
color_value= 0
for i in range(10):
pendown()
if color_value % 2 == 0:
color_value= color_value+ 1
color(“black”)
else:
color_value= color_value+ 1
color(“red”)
begin_fill()
square()
end_fill()
penup()
forward(40)
move_up_a_row()
for i in range(10):
pendown()
if color_value % 2 == 0:
color_value= color_value+ 1
color(“red”)
else:
color_value= color_value+ 1
color(“black”)
begin_fill()
square()
end_fill()
penup()
forward(40)
# Send Tracy to starting position in bottom left corner.
penup()
setposition(-200,-200)
# Call square drawing function
for i in range(5):
draw_two_square_rows()
left(90)
forward(40)
left(90)
forward(400)
left(180)

 

About CodeHS Python

CodeHS Python Answers Key

CodeHS covers python perfectly for beginners to the most advanced levels. Their syllabus includes python 3, python graphics, python data science in which you can learn python graphics with help of Tracy the turtle which makes complex coding easier to understand.

 

>> Check Other CodeHS Topics Answers <<

That’s it…

We hope you are able to find CodeHS Python answers key by browsing with us. If it helps please share it with your friends. Thank you!


Leave a Comment

Sorry! Copy-paste disabled.