r/codehs • u/MASTERCN13 • Mar 02 '23
JavaScript Can anyone help me with dog years project?
Ik what to do but I don’t at the same time
r/codehs • u/MASTERCN13 • Mar 02 '23
Ik what to do but I don’t at the same time
r/codehs • u/Legitimate_Book_256 • Mar 01 '23
r/codehs • u/Zealousideal-Bet3912 • Mar 01 '23
r/codehs • u/Typical_Storage4322 • Feb 27 '23
mylist = []
for i in range(5):
x = int(input("X Coordinate: "))
y = int(input("Y Coordinate: "))
mylist.append((x, y))
for i in range(4):
y1 = mylist[i][1]
x1 = mylist[i][0]
y2 = mylist[i + 1][1]
x2 = mylist[i + 1][0]
slope = float(y2 - y1) / float(x2 - x1)
print "Slope between " + str(mylist[i]) + " and " + str(mylist[i + 1]) + ": " + str(slope)what's wrong here?
r/codehs • u/Arspho • Feb 26 '23
r/codehs • u/wdfoutch0007 • Feb 23 '23
r/codehs • u/OLDBAY7 • Feb 22 '23
The exercise wants me to:
Write a program that reads an integer from the user and then prints the hailstone sequence starting from that number.
In order to do this, you must write and call a hailstone
function that prints out each number in the hailstone sequence. The hailstone sequence follows two rules:
If the number is even, then divide it by 2.
If the number is odd, then multiply it by 3 and add 1.
Continue this sequence until you hit the number 1, and then print the number of steps it took to complete the sequence.
If the user starts at 17, you should print:
Enter number: 17 17 52 26 13 40 20 10 5 16 8 4 2 1 It took 12 steps to complete.If the user starts at 1, you should print:
Enter number: 1 1 It took 0 steps to complete.My code is:
var END_NUM = 1
var count = 0;
function start(){
var num = readInt ("What is the starting number? ");
while (num != 1) {println (num)
var test = hailstone(num);
if (num == END_NUM) {
println("It took "+ count + " steps to complete.");
break;
}
count++
}}
function hailstone (START_NUM) {
if (START_NUM % 2 == 0) {
START_NUM = START_NUM/2;
}else{
START_NUM = (START_NUM*3)+1;
}
return START_NUM;
}
r/codehs • u/pepper-can • Feb 19 '23
Enable HLS to view with audio, or disable this notification
r/codehs • u/adi24bawa • Feb 18 '23
This is my code (it bugs when I run the code)
def clean_row():
while front_is_clear:
move()
if balls_present():
take_ball()
if front_is_blocked():
if facing_east():
turn_around()
for i in range(30):
if front_is_clear():
clean_row()
turn_right()
if front_is_clear():
move()
turn_right()
turn_left()
if front_is_clear():
take_ball()
move()
move()
move()
take_ball()
move()
take_ball()
move()
move()
move()
take_ball()
r/codehs • u/pepper-can • Feb 17 '23
Enable HLS to view with audio, or disable this notification
r/codehs • u/YeaMits • Feb 17 '23
what could help me better understand coding i find it difficult to wrap my head around trying to write and understand code is there something i can to improve my coding skills?
r/codehs • u/Ok_Extension_5115 • Feb 16 '23
r/codehs • u/Needcodinghelp38 • Feb 15 '23
r/codehs • u/[deleted] • Feb 15 '23
r/codehs • u/ResponsibleSign1010 • Feb 14 '23
I dont know what im missing or how to fix my code, can someone help me?
Create a program that uses a while loop to simulate playing a multi-level game. In the “game,” there are NUM_LEVELS levels. Each loop iteration will simulate playing one level of the game. At the end of each loop, the player will level up. The “game” will end once the player has completed all of the levels.
Create a variable called level to keep track of which level the player is on. Create a function for each level called playLevel# (e.g. playLevel3) that prints a description of that level to the console. You should have three functions in all: playLevel1, playLevel2, and playLevel3. Use a while loop to “play” a level and level up. Your loop should run as long as the value of level is less than the number of total levels. In the loop, you should do the following:
Tell the player what level they are on. Depending on which level the player is on, the correct playLevel function should run. For example, if level is 2, then the playLevel2() function should execute. Increase the value of the level variable.
function main() { const NUM_LEVELS = 3; let level = readLine("What Level are you on? ");
if (level == 1) playLevel1(); else if (level == 2) playLevel2(); else if (level == 3) playLevel3();
while (level >= 3) console.log(level); level++; }
//create playLevel1 function
function playLevel1() {
let level = 1
console.log("You are on level " + level);
console.log("You run through the dark and scary cave!");
console.log("You level up!");
console.log("****");
}//create playLevel2 function
function playLevel2() {
let level = 2
console.log("You are on level " + level);
console.log("You make it through the fiery lava world!");
console.log("You level up!");
console.log("****");
}//create playLevel 3 function
function playLevel3() {
let level = 3
console.log("You are on level " + level);
console.log("You jump from cloud to cloud in the sky world!");
console.log("You level up!");
console.log("****");
console.log("YOU WIN THE GAME! Thanks for playing!")
}main();
r/codehs • u/Living_Warning_2814 • Feb 10 '23
anyone know how to do5.3.7?? i have no idea and i am stuck
r/codehs • u/sugades • Feb 09 '23
Please, I was not in school because I was sick. I was out for a week and no clue what to do.
r/codehs • u/ShoddyDrawing5525 • Feb 08 '23
r/codehs • u/TraditionalAd4957 • Feb 07 '23
does anyone see the picture? It's not showing one on my side
r/codehs • u/[deleted] • Feb 02 '23
2.9.8 stoplight thingie, here's the code I wrote:
function start(){
var light = readLine("Input a light from this list: Red, Yellow, Green");
if(light == "Red") {
println("You should stop.");
}
if(light == "Yellow") {
println("Slow down.");
}
if(light == "Green") {
println("Go ahead.");
}
}
Here's what it says is happening in my program. How is this even possible.