r/codeHS_Solutions • u/Nexus_X__ • Feb 13 '22
8.1.7 Fix This Tuple
my_tuple = (0, 1, 2, "hi", 4, 5)
my_tuple = my_tuple[:3] + (3,) + my_tuple[4:]
print(my_tuple)
r/codeHS_Solutions • u/Nexus_X__ • Feb 13 '22
my_tuple = (0, 1, 2, "hi", 4, 5)
my_tuple = my_tuple[:3] + (3,) + my_tuple[4:]
print(my_tuple)
r/codeHS_Solutions • u/Nexus_X__ • Feb 13 '22
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 • u/Nexus_X__ • Feb 13 '22
names = [
"Maya Angelou",
"Chimamanda Ngozi Adichie",
"Tobias Wolff",
"Sherman Alexie",
"Aziz Ansari"
]
print([name.split()[-1] for name in names])
r/codeHS_Solutions • u/Nexus_X__ • Feb 13 '22
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 • u/Nexus_X__ • Feb 13 '22
def spell_name(name):
return list(name)
r/codeHS_Solutions • u/Nexus_X__ • Feb 13 '22
def owl_count(text):
text = text.lower()
count = text.count("owl")
return count
r/codeHS_Solutions • u/OutsideHit-fitty-nin • Feb 19 '22
r/codeHS_Solutions • u/Nexus_X__ • Feb 13 '22
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 • u/Nexus_X__ • Feb 13 '22
book_list = []
for i in range(5):
book = input("Name: ")
book_list.append(book)
book_list.sort()
print(book_list)
r/codeHS_Solutions • u/Nexus_X__ • Feb 13 '22
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 • u/Nexus_X__ • Feb 13 '22
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 • u/Nexus_X__ • Feb 13 '22
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 • u/Appropriate-Turn-212 • Feb 17 '22
r/codeHS_Solutions • u/Nexus_X__ • Mar 09 '21
// 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 • u/abgmemer_69 • Mar 20 '21
r/codeHS_Solutions • u/Nexus_X__ • Mar 09 '21
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 • u/TheBirbWhoGoesPOOT • Mar 16 '21
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 • u/typicalar • Mar 01 '23
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 • u/[deleted] • Feb 13 '23
r/codeHS_Solutions • u/Legitimate_Book_256 • Mar 01 '23
r/codeHS_Solutions • u/A_Very_Big_Fan • Jan 08 '21
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 • u/Various_Loss9064 • Feb 04 '21
If anyone wants solutions or answers to CodeHS, message me privately or join the discord
If you join the discord, I can help you with quizzes too
r/codeHS_Solutions • u/Ok_Incident_9147 • Jan 11 '21
public void run()
{
String end = toUpper("hopethishelps");
System.out.println(end);
}
public String toUpper(String str)
{
String out = "";
int l = str.length();
for (int i = 0; i < l; i++ )
{
char index = str.charAt(i);
char j = Character.toUpperCase(index);
String convertedChar = Character.toString(j);
out += convertedChar;
}
return out;
}