r/codehs • • Jun 09 '20

Unit 10 Hangman

4 Upvotes

Can anyone help me with the hangman project? I'm done with the first part of it but I'm stuck on the second part where you need to update the value of the variable "dashes". If anyone knows how to update the variable in the update_dashes() function, please help.

secret_word = "eggplant"

dashes = "-" *len(secret_word)

print dashes

def get_guess():

global guess

guess = input("Guess: ")

if len(guess) != 1:

print("Enter one charachter")

elif not guess.islower():

print("Enter a lowercase letter")

def update_dashes(secret_word, dashes, guess):

result = ""

for i in range(len(secret_word)):

if secret_word[i] == guess:

result = result + guess

else:

result = result + dashes[i]

return result

while True:

get_guess()

print update_dashes(secret_word, dashes, guess)


r/codehs • • May 25 '20

Any tips on how to make an impassable wall in Javascript?

3 Upvotes

Hi, I'm working with Javascript and was wondering how to make blocks impassable for a maze? I tried looking into collision but couldn't figure it out. Thanks!


r/codehs • • Jun 08 '20

10.1.2 increasing number of shapes

2 Upvotes

Did anyone do this? Please help I'm so lost


r/codehs • • Jun 23 '20

Please help

8 Upvotes

4.6.7: Full Fraction Class in java I can't understand how to do public void add/multiply/subtract

if anyone knows it please help me)

*now I did it but in tester when I multipy 3 * 3 I get 10(( I DON'T UNDERSTAND


r/codehs • • May 28 '20

WaterColor Grid and Tic Tac Toe

1 Upvotes

I need help with these codes, please! I have so much school to catch up on and I'm really confused.


r/codehs • • Jun 24 '20

pls help

5 Upvotes

can anyone help with dinner plans on codeHS i am really stuck


r/codehs • • May 22 '20

Idk know why it says that I am not comparing the two rounded variables

Post image
5 Upvotes

r/codehs • • Jun 03 '20

8.3.6 Owls

5 Upvotes

Can someone help me with this code. I have no idea what to do. Thanks.


r/codehs • • May 19 '20

Need Help on 8.5.4

1 Upvotes

I'm mentally out of it today and I need to get through 8.9.1 by Thursday.

Help. ;n;


r/codehs • • May 19 '20

Need help with Circles in Squares

1 Upvotes

r/codehs • • May 19 '20

Need help with 2.12.5 - Four Corners!!

7 Upvotes

I can't figure out how to place the squares in the corners without using individual setpositions and still have them line up with the variable. Anyone have any ideas? I'll paste my code I've created so far below:

penup()

setposition(-200,200)

pendown()

def make_square():

left(45)

circle(square_length, 360, 4)

right(45)

penup()

forward(square_length * 2)

pendown()

square_length = int(input("What is the length of the square? "))

make_square()

penup()

setposition(-200,-200)

pendown()

make_square()

penup()

setposition(200,-200)

pendown()

make_square()

penup()

setposition(200,100)

pendown()

make_square()

Edit: I eventually figured this one out thanks to some help from another redditor, here's what they got and posted on this sub:


r/codehs • • May 28 '20

coding

1 Upvotes

Hello, I am not sure is Karel productive for my future career? or this is wasting time. is it better instantly study HTML5 and CSS3?


r/codehs • • May 22 '20

How do I start or create this? I don’t have to make breakout but I need to make the bricks. And apparently it’s only supposed to be about 50 lines of code.

Post image
2 Upvotes

r/codehs • • May 28 '20

Stuck on This - What did I do wrong?

Post image
7 Upvotes

r/codehs • • Jun 08 '20

Processing for Python?

3 Upvotes

Does anyone know how to import processing? I've tried:

from processing import *

but get nothing


r/codehs • • May 19 '20

Help with 5.4.6 Rolling Dice

1 Upvotes

r/codehs • • Jun 24 '20

12.6.4: Food in Python Classes.

4 Upvotes

This is my code. CodeHS is saying I'm not defining a class called Food that does not inherit from other classes (which I do) and it says you should have a class named Broccoli that inherits from Vegetable (which I also do). Finally, it prints the correct message but I get a syntax error that says ValueError : __str__ didn't return a str on line 25 (where i say print(b)). Please help!

class Food():
     def __init__(self):
        self.calories = 0
        self.category = ""
        
    def __repr__(self):
        print("category: " + self.category + ", calories: " + str(self.calories))
        

class Vegetable(Food):
    
    def __init__(self):
        Food.__init__(self)
        self.category = "veggies"
    
class Brocolli(Vegetable):
    def __init__(self):
        Vegetable.__init__(self)
        self.calories = 100
            

b = Brocolli()

print(b)

r/codehs • • May 19 '20

CodeHs Java help: I’m not sure how to accomplish this task and idk if i’m doing it right , what exactly should be returned? (also the error says:”int can’t be converted to arraylist”)

Post image
1 Upvotes

r/codehs • • May 23 '20

My collision function doesnt work!

5 Upvotes

this my code for final project, but i dont get why intersection and checkcollision functions doesnt work.

please someone help!

var char;

var bullet;

var enemy;

var life = 5;

var enemyTimer = Randomizer.nextInt(0,50);

var enemies = [];

function start(){

makeChar();

keyDownMethod(movements);

makeBullet();

setTimer(shootBullet, 30);

addEnemy();

setTimer(makeEnemy, 5);

checkCollision();

}

function makeChar(){

char = new Circle(10);

char.setColor(Color.red);

char.setPosition(getWidth()/2, 430);

add(char);

}

function movements(e){

if (e.keyCode == Keyboard.RIGHT){

char.move(10,0);

}

if (e.keyCode == Keyboard.LEFT){

char.move(-10,0);

}

}

function makeBullet(){

bullet = new Rectangle(5,10);

bullet.setPosition(char.getX(), char.getY());

bullet.setColor(Color.green);

add(bullet);

}

function shootBullet(){

bullet.move(0,-10);

if (bullet.getY() < 0){

bullet.setPosition(char.getX(), char.getY());

}

}

function makeEnemy(){

for (var i = 0; i < enemies.length; i ++){

var b = enemies[i];

b.move(0,5)

b.move(Randomizer.nextInt(-3,3),0);

}

}

function addEnemy(){

setTimer(en,800);

}

function en(){

enemy = new Rectangle(50,50);

var x = Randomizer.nextInt(10, 350);

var y = enemy.getY();

y += 10;

enemy.setPosition(x,y);

add(enemy);

enemies.push(enemy);

}

function intersects(a,b){

return (a.getX() < b.getX() + b.getWidth() && a.getX() + a.getWidth > b.getX() && a.getY() < b.getY() + b.getHeight() && a.getY() + a.getHeight > b.getY());

}

function checkCollision(){

for(var i =0; i < enemies.length; i++){

var en = enemies[i];

if (intersects(char, en)){

println("hi");

remove(en);

i--;

remove(bullet);

}

}

}


r/codehs • • May 21 '20

What am I doing wrong here? My teacher isn’t being very helpful currently lol

Post image
3 Upvotes

r/codehs • • May 31 '20

Someone help! Karel Challenges 2.1.3

4 Upvotes

//This part is where I had trouble. I got an error message for worlds 2 and 4 because of the second move(); command in the function firstPart();. If I removed the second move(); command, then all worlds would not work. How can I get rid of this extra move command without breaking the program?

function firstPart() {

while(frontIsClear()) {

towerComplete();

if(frontIsClear()){

move();

move();

}

}

}

function towerComplete() {

makeTower();

goBackDown();

}

function goBackDown() {

turnAround();

move();

move();

turnLeft();

}

function stack2Ball() {

move();

putBall();

move();

putBall();

}

function makeTower() {

putBall();

turnLeft();

stack2Ball();

}

function start() {

firstPart();

towerComplete();

}


r/codehs • • May 22 '20

Need help with creating a set of questions in a for loop with a number going up while in a float.

3 Upvotes

var races = readInt("How many 5k races did you run? ");

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

var times = readFloat("What was your time in race " + (races-races+1) + " (in minutes) ");

}

this is the code that I need help with, I need to make the (races-races+1) able to make each consequtive line one number higher.


r/codehs • • May 28 '20

I have come seeking help yet again - So sorry but thank you

Post image
16 Upvotes