r/codeHS_Solutions • u/[deleted] • May 24 '22
Solution DM for any Lesson 4 answers
just send me what lesson u need for the SQL chapter 4 lessons and I’ll respond in less than an hour
r/codeHS_Solutions • u/[deleted] • May 24 '22
just send me what lesson u need for the SQL chapter 4 lessons and I’ll respond in less than an hour
r/codeHS_Solutions • u/[deleted] • May 22 '22
r/codeHS_Solutions • u/Kind-Breath-5188 • May 17 '22
Couldn’t find this anywhere, but now I have, I did it boys here you go.
Unit 3 https://youtu.be/SRi8hX6PwHI Unit 4 https://youtu.be/FbizZEzlD_E
r/codeHS_Solutions • u/No-Parfait8990 • Apr 29 '22
Does anybody have the code? It's really bothering me. Here is mine. It gives me lossy conversion errors.
import java.util.*;
public class BinarySearchTest
{
static int count;
public static void main(String[] args)
{
// Use the helper code to generate arrays, calculate the max
// iterations, and then find the actual iterations for a randomly
// selected value.
System.out.println("Array Size: 100");
System.out.println("Max iterations: " + binaryMax(100));
System.out.println("Actual iterations: " + binaryRec(generateArrayOfLength(100), 2, 0, 99));
System.out.println("Array Size: 1000");
System.out.println("Max iterations: " + binaryMax(1000));
System.out.println("Actual iterations: " + binaryRec(generateArrayOfLength(1000), 2, 0, 999));
System.out.println("Array Size: 10000");
System.out.println("Max iterations: " + binaryMax(10000));
System.out.println("Actual iterations: " + binaryRec(generateArrayOfLength(10000), 2, 0, 9999));
System.out.println("Array Size: 100000");
System.out.println("Max iterations: " + binaryMax(100000));
System.out.println("Actual iterations: " + binaryRec(generateArrayOfLength(100000), 2, 0, 99999));
}
public static int binaryRec(int[] array, int target, int begin, int end)
{
if(begin <= end)
{
int mid = begin + end / 2;
int midVal = array[mid];
count++;
// Base Case
if(target == midVal)
{
return mid;
}
if(target < midVal)
{
return binaryRec(array, target, begin, mid - 1);
}
if(target > midVal)
{
return binaryRec(array, target, mid + 1, end);
}
}
return -1;//Alternate Base Case - not found
}
public static int[] generateArrayOfLength(int length)
{
int[] arr = new int[length];
for(int i = 0; i < length; i++)
{
arr[i] = (int)(Math.random() * 100);
}
Arrays.sort(arr);
return arr;
}
private static int binaryMax(int length)
{
return (int)Math.log(length) / Math.log(2) + 1;
}
}
r/codeHS_Solutions • u/Caregiver-Feisty • Apr 28 '22
I am trying to write this code but I keep getting a Type Error for my getX values. The code should basically be single player pong.
var ball; var dx = -4; var dy = 4; var rect; var horizontalRect; var verticalRect; var score; var scoreText; var x; var y; var colided; var rect; var rectWidth = 80; var rectHeight = 15; var rectOff = 10; var paused = false;
function start(){ rect = new Rectangle(rectWidth,rectWidth); rect.setPosition(getWidth()/2 - 40, getHeight() - 30); add(rect);
mouseMoveMethod(t);
mouseClickMethod(pause);
setTimer(draw, 20);}
function draw() { checkElement();
if (!paused){
checkWalls();
ball.move(dx,dy);
}}
function pause(e){ paused = !paused; }
function checkElement(){ var elmT = getElementAt(ball.getX(), ball.getY() - 15); var elmB = getElementAt(ball.getX(), ball.getY() + 15); var elmL = getElementAt(ball.getX() - 15, ball.getY()); var elmR = getElementAt(ball.getX() + 15, ball.getY());
if (elmT != null){
dy = -dy
if (elmT.getColor() != Color.black){
remove(elmT);
}
}
if (elmB != null){
dy = -dy
if (elmB.getColor() != Color.black){
remove(elmB);
}
}
if (elmL != null){
dy = -dy
if (elmL.getColor() != Color.black){
remove(elmB);
}
}
if (elmR != null){
dy = -dy
if (elmR.getColor() != Color.black){
remove(elmR);
}
}}
function t(e){ rect.setPosition(e.getY() - 40, getHeight() - 20);
}
function forCircle(radius,x,y){ ball = new Circle(20); ball.setPosition(100,100); add(ball);
setTimer(drawCircle, 20);}
// ball bounces on first contact, moving in a zig zag pattern, unintended, good start function rectBounce(){ if(ball.getX() >= (rect.getX() - ball.getRadius() )){ colided = false; } if(colided) { setTimer(drawBounce, 20) } }
function drawBounce(){ dx = -dy; }
function drawCircle(){ checkWalls(); ball.move(dx,dy); }
function checkWalls(){ if (ball.getX() + ball.getRadius() > getWidth()){ dx = -dx; } if (ball.getX() - ball.getRadius() < 0){ dx = -dx; } if (ball.getY() + ball.getRadius() > getHeight()){ ball.setPosition(getWidth() / 2, getHeight() / 2); }
if (ball.getX() + ball.getRadius() > getWidth()){
var txt = new Text ("You lose","45pt Arial");
txt.setPosition(getWidth()/2 - txt.getWidth()/2, 200);
txt.setColor(Color.blue);
add(txt);
}}
r/codeHS_Solutions • u/looolmoski • Mar 08 '22
For the people who need this, I also posted part 3 of this. I posted part 3 and this one as well cuz I couldn't find any resources to help me out. So I figured I'll help my fellow students who need this. Because I, at one point, was desperate. You can find part 3 over here:
This is the code for part 4 below:
import random
words = ["grasswayz", "phases", "paranoia", "felony", "trenches", "bukayo"]
secret_word = random.choice(words)
dashes = ""
arr = []
for i in range(len(secret_word)):
dashes += '-'
arr.append('-')
guesses_left = 10
def get_guess():
while True:
print(''.join(arr))
print(str(guesses_left) + " incorrect guesses left.")
guess = input("Guess: ")
if len(guess) > 1:
print("Your guess must have exactly one character!")
elif guess not in "abcdefghijklmnopqrstuvwxyz":
print("Your guess must be a lowercase letter!")
else:
return guess
while guesses_left > 0 and '-' in arr:
a = get_guess()
for i in range(len(secret_word)):
if secret_word[i] == a:
arr[i] = a
if a not in secret_word:
print("That letter is not in the word!")
guesses_left -= 1
else:
print("That letter is in the word!")
if '-' not in arr:
print("Congrats you win! The word was: "+ secret_word)
else:
print("You lose, The word was: " + secret_word)
def update_dashes():
passr/codeHS_Solutions • u/looolmoski • Mar 08 '22
secret_word = "grasswayz"
dashes = "---------"
arr = ['-','-','-','-','-','-','-','-','-']
guesses_left = 10
def get_guess():
while True:
print(''.join(arr))
print(str(guesses_left) + " incorrect guesses left.")
guess = input("Guess: ")
if len(guess) > 1:
print("Your guess must have exactly one character!")
elif guess not in "abcdefghijklmnopqrstuvwxyz":
print("Your guess must be a lowercase letter!")
else:
return guess
while guesses_left > 0 and '-' in arr:
a = get_guess()
for i in range(len(secret_word)):
if secret_word[i] == a:
arr[i] = a
if a not in secret_word:
print("That letter is not in the word!")
guesses_left -= 1
else:
print("That letter is in the word!")
if '-' not in arr:
print("Congrats you win! The word was: "+ secret_word)
else:
print("You lose, The word was: " + secret_word)
def update_dashes():
passr/codeHS_Solutions • u/OutsideHit-fitty-nin • Feb 19 '22
r/codeHS_Solutions • u/Appropriate-Turn-212 • Feb 17 '22
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"))
def printTitle(first, second):
setposition(0,170)
writeText("Punnett Square for " + first + " and " + second, "black", "center", 18)
def determineGenotype(first, second):
writeText(allele1[first], "blue", "right")
writeText(allele2[second], "red", "left")
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")
setposition(-130,30)
allele2= input("What is the second parent's alleles?: ")
writeText(allele2[0], "red")
setposition(-130,-70)
writeText(allele2[1], "red")
# Print title based on given alleles
printTitle(allele1, allele2)
x = -50
y = 30
for b in range(0, 2, 1):
for a in range(0, 2, 1):
setposition (x, y)
determineGenotype(a, b)
x = 50
y = -70
x = -50
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 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()
penup()
setposition(-50, 110)
writeText("#1", "blue")
setposition(50, 110)
writeText('#2', "blue")
setposition(-130, 30)
writeText("#3", "red")
setposition(-130, -60)
writeText("#4", "red")
r/codeHS_Solutions • u/Nexus_X__ • Feb 13 '22
text = input("Enter some text: ")
text_list = text.split()
dic = {}
def update_counts(count_dictionary, word):
if word in count_dictionary:
count_dictionary[word] = count_dictionary[word] + 1
else:
count_dictionary[word] = 1
for word in text_list:
update_counts(dic, word)
print(dic)
r/codeHS_Solutions • u/Nexus_X__ • Feb 13 '22
def swap_lists(first, second):
for i in range(len(first)):
first[i], second[i] = second[i], first[i]
list_one = [1, 2, 3]
list_two = [4, 5, 6]
print("Before swap")
print("list_one: " + str(list_one))
print("list_two: " + str(list_two))
swap_lists(list_one, list_two)
print("After swap")
print("list_one: " + str(list_one))
print("list_two: " + str(list_two))
r/codeHS_Solutions • u/Nexus_X__ • Feb 13 '22
text = input("Enter some text: ")
text_list = text.split()
dic = {}
for word in text_list:
if word in dic:
dic[word] = dic[word] + 1
else:
dic[word] = 1
print(dic)
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
first = input("First name: ")
last = input("Last Name: ")
print("Full name: " + first + " " + last)
first, last = last, first
print("Citation: " + first + ", " +last)