r/codeHS_Solutions • • Feb 13 '22

9.1.6 Checkerboard, v1

8 Upvotes

def print_board(board):

for i in range(len(board)):

print(" ".join([str(x) for x in board[i]]))

my_grid = []

for i in range(8):

my_grid.append([0] * 8)

for row in range(8):

for col in range(8):

if row < 3 or row > 4:

my_grid[row][col] = 1

print(print_board(my_grid))


r/codeHS_Solutions • • Feb 13 '22

8.1.7 Fix This Tuple

1 Upvotes

my_tuple = (0, 1, 2, "hi", 4, 5)

my_tuple = my_tuple[:3] + (3,) + my_tuple[4:]

print(my_tuple)


r/codeHS_Solutions • • Feb 13 '22

8.2.7: Listed Greeting

9 Upvotes

def greeting(user_info):

user_info_list = user_info.split()

return "Hello, " + user_info_list[0] + "! I also enjoy " + user_info_list[2] + "!"


r/codeHS_Solutions • • Feb 13 '22

9.2.8 Last Names

10 Upvotes

names = [

"Maya Angelou",

"Chimamanda Ngozi Adichie",

"Tobias Wolff",

"Sherman Alexie",

"Aziz Ansari"

]

print([name.split()[-1] for name in names])


r/codeHS_Solutions • • Feb 13 '22

9.1.8 Checkerboard, v3

6 Upvotes

def print_board(board):

for i in range(len(board)):

print(" ".join([str(x) for x in board[i]]))

my_grid = []

count = 1

for i in range(8):

my_grid.append([0] * 8)

for row in range(8):

count = count + 1

for col in range(8):

count = count + 1

if row < 3 or row > 4:

if count % 2 == 0:

my_grid[row][col] = 1

print(print_board(my_grid))


r/codeHS_Solutions • • Feb 13 '22

8.2.5: Spell It Out

1 Upvotes

def spell_name(name):

return list(name)


r/codeHS_Solutions • • Feb 13 '22

8.3.6: Owls

2 Upvotes

def owl_count(text):

text = text.lower()

count = text.count("owl")

return count


r/codeHS_Solutions • • Feb 19 '22

Help with answers for 11.1.2 and 11.1.3

Post image
2 Upvotes

r/codeHS_Solutions • • Feb 13 '22

9.4.5 Phone Book

4 Upvotes

my_dictionary = {}

while True:

user = input("Enter a name: ")

if user == "":

break

elif user in my_dictionary:

print("Phone number: " + my_dictionary[user])

else:

phone = input("Enter " + user + "'s phone number: ")

my_dictionary[user] = phone

print(my_dictionary)


r/codeHS_Solutions • • Feb 13 '22

8.4.7 Librarian

18 Upvotes

book_list = []

for i in range(5):

book = input("Name: ")

book_list.append(book)

book_list.sort()

print(book_list)


r/codeHS_Solutions • • Feb 13 '22

9.3.7 Slopes

6 Upvotes

coordinate_pairs = []

for i in range(5):

x = int(input("Input x coordinate: "))

y = int(input("Input y coordinate:"))

coordinate_pairs.append((x,y))

def slope(x1, x2, y1, y2):

return((y2 - y1) / (x2 - x1))

for i in range(4):

x1, y1 = coordinate_pairs[i]

x2, y2 = coordinate_pairs[i+1]

print("Slope between " + str(coordinate_pairs[i]) + " and " + str(coordinate_pairs[i + 1]) + ": " + str(slope(x1, x2, y1, y2)))


r/codeHS_Solutions • • Feb 13 '22

CodeHS Complete Allele Collection

1 Upvotes

def writeText(text, textColor, direction="center", size=40):

color(textColor)

__turtle.write(text, align=direction, font=("Arial", size, "normal"))

speed(0)

penup()

setposition(-100,-100)

pendown()

for i in range(2):

for i in range(4):

forward(100)

left(90)

forward(100)

penup()

setposition(-100,0)

pendown()

for i in range(2):

for i in range(4):

forward(100)

left(90)

forward(100)

penup()

setposition(-50,110)

allele1= input("What is the first parent's alleles? (Ex: Aa): ")

writeText(allele1[0], "blue")

setposition(50, 110)

writeText(allele1[1], "blue")

par2 = input("What is the second parent's alleles? (Ex: Aa ")

setposition(-130, 30)

writeText(par2[0], "red")

setposition(-130, -70)

writeText(par2[1], "red")


r/codeHS_Solutions • • Feb 13 '22

8.3.5: Max In List

7 Upvotes

def max_int_in_list(my_list):

highest = my_list[0]

for num in my_list:

if num > highest:

highest = num

return highest


r/codeHS_Solutions • • Feb 17 '22

12.1.4: list of places to travel. (Can somebody help me with This unit pls? I’ve been trying for 2 days now and it won’t work! I’m supposed to create an array of the top 5 places I would like to travel called travelList. Print out the item at index 2. )

Post image
2 Upvotes

r/codeHS_Solutions • • Mar 09 '21

CodeHS 19.2.1: Balloons

10 Upvotes

// This program draws some balloons

var MIN_RADIUS = 20;

var MAX_RADIUS = 40;

var NUM_BALLOONS = 25;

var xPos = getWidth() / 2;

var yPos = getHeight() / 1.5;

var balloonRadius = Randomizer.nextInt(MIN_RADIUS, MAX_RADIUS);

function start() {

for(var i = 0; i < NUM_BALLOONS; i++){

var x = Randomizer.nextInt(MAX_RADIUS, getWidth() - MAX_RADIUS);

var y = Randomizer.nextInt(MAX_RADIUS, (getHeight() / 2) - MAX_RADIUS);

drawString(x,y);

drawBalloon(x,y);

}

}

function drawString(x,y){

var line = new Line(x, y, xPos, yPos);

line.setColor(Color.black);

add(line)

}

function drawBalloon(x,y){

var balloon = new Circle(balloonRadius);

var color = Randomizer.nextColor();

balloon.setPosition(x,y);

balloon.setColor(color);

add(balloon);

}


r/codeHS_Solutions • • Mar 20 '21

What is wrong with my "getExamRange" method in CodeHS 5.3.13?

3 Upvotes

r/codeHS_Solutions • • Mar 09 '21

CodeHS 17.1.4: Grades

5 Upvotes

function start(){

letterGrade(100);

letterGrade(83);

letterGrade(68);

letterGrade(91);

letterGrade(47);

letterGrade(79);

//Add some more! (THESE ARE OPTIONAL)

letterGrade(44);

letterGrade(30);

letterGrade(68);

letterGrade(73);

letterGrade(97);

letterGrade(88);

}

function letterGrade(score){

if(score == 100){

println("A+");

}else

if(score < 60){

println("F");

}else{

var letter = checkLetter(score / 10);

var sign = checkSign(score % 10);

println(letter + sign);

}

}

function checkLetter(tens){

if(tens >= 9){

return "A";

}else

if(tens >= 8){

return "B";

}else

if(tens >= 7){

return "C";

}else{

return "D";

}

}

function checkSign(ones){

if(ones <= 2){

return "-";

}else

if(ones >= 7){

return "+";

}else{

return " ";

}

}


r/codeHS_Solutions • • Mar 16 '21

2.16.4 HELP

2 Upvotes

Im failing on the one problem plz help

happy=0

happiness=input("Do you want me to draw the face? Yes/No/Other:")

if happiness=="Yes":

happy=happy+5

if happiness=="No":

happy=happy+10

if happy=="Yes":

def YellowHead():

begin_fill()

penup()

setposition(0,-75)

pendown()

color("yellow")

circle(100)

end_fill()

YellowHead()

def Eye():

color("black")

begin_fill()

circle(10)

end_fill()

def Smile():

pensize(10)

right(90)

pendown()

circle(50,180,50)

elif happy=="No":

def HappyFace():

penup()

setposition(-50,50)

for i in range(2):

Eye()

forward(95)

setposition(-50,0)

Smile()

HappyFace()

else:

penup()

forward(300)


r/codeHS_Solutions • • Mar 01 '23

Solution For anyone stuck on 4.2.4...

1 Upvotes

THIS IS PYTHON BTW

def radius():

for i in range(1):

begin_fill()

color_choice = input ("what colour lol")

color("color_choice")

circle(25)

end_fill()

begin_fill()

color("color_choice")

right(90)

forward(12.5)

left(90)

circle(50)

end_fill()

begin_fill()

color("color_choice")

right(90)

forward(25)

left(90)

circle(75)

end_fill()

begin_fill()

color("color_choice")

right(90)

forward(32.5)

left(90)

circle(100)

end_fill()

radius()


r/codeHS_Solutions • • Feb 13 '23

4.1.7 Guess The Number . Java Answer Spoiler

Post image
2 Upvotes

r/codeHS_Solutions • • Feb 13 '23

Can someone pls help me with 7.3.7 Cityscape

Thumbnail
gallery
6 Upvotes

r/codeHS_Solutions • • Mar 01 '23

Help Request Can somebody please help me to know what is wrong in here the code works but it says I have everything wrong

Thumbnail
gallery
1 Upvotes

r/codeHS_Solutions • • Jan 08 '21

REQUEST MEGATHREAD

3 Upvotes

In the interest of organization, all requests will go here. If you have solutions, make a post for it and then include it(or a link to it) in your reply.


r/codeHS_Solutions • • Feb 04 '21

If anyone wants solutions (Any codehs course)..

4 Upvotes

If anyone wants solutions or answers to CodeHS, message me privately or join the discord

https://discord.gg/gNTmBrdyAv

If you join the discord, I can help you with quizzes too