I Hate CBT's

View Original

Sporting Goods Shop Codehs

Question: 3.3.4: Your Name and Hobby

Answer: # This program should print out your

name, and a hobby you have

Sample output:

#

My name is Jeremy

I like to juggle

#

print(“My name is Daniel”)

print(“I like to play video games”)

Question: 3.4.6: Apples and Oranges

Answer: # Enter your code here

num_apples = 20

print(“Number of apples: “ + str(num_apples))

num_oranges=15

print(“Number of oranges: “ + str(num_oranges))

num_apples=20

print(“Number of apples: “ + str(num_apples))

num_oranges=0

print(“Number of oranges: “ + str(num_oranges))

Question: # Place your code here

name = input(“What is your name?”)

droids= int(input(“How many droids would you like to meet?”))

wookies= int(input(“How many wookies would you like to meet?”))

print(“Hi “+ name + “, you want to meet “ + str(droids) + “ droids and “ + str(wookies) + “ Wookies.”)

Answer: 3.5.4: Obi-Wan Says

Question: # Enter your code here

COSTOFFRISBEES = 15

amount = int(input(“How many Frisbees would you like to buy?”))

cost= (COSTOFFRISBEES * amount)

print(“The cost for “ + str(amount) + “ frisbees is $” + str(cost) + “ dollars.”)

Answer: 3.6.7: Sporting Goods Shop

Question: # Enter your code here

miles= float(input(“How many miles did you run?”))

minutes= float(input(“How many minutes did it take you?”))

MINUTESPERHOUR = 60

mPH = MINUTESPERHOUR * miles / minutes

print(“Speed in MPH: “ + str(mPH))

Answer: 3.6.8: Running Speed

Question: # Code Segment One - Data Type - Numbers

num_result = 24 + 24

print(num_result)

Code Segment Two - Data Type - Strings

Change both numbers to strings and run code

Change only one number to a string and run code. What happens?

string_result = str(24) + str(24)

print(string_result)

Answer: 3.6.9: 24 vs. “24”

Question: 3.7.8 French Flag

Answer: # Create a Blue rectangle on left

width= get_width() / 3

height= get_height()

blue_rect= Rectangle(width, height)

bluerect.setcolor(Color.blue)

bluerect.setposition(1,1)

add(blue_rect)

Create a Red rectangle on right

width = get_width() /3

height = get_height()

red_rect= Rectangle(width, height)

redrect.setcolor(Color.red)

redrect.setposition(250 ,1)

add(red_rect)

Question: 3.7.9 Snowman

Answer:

Question: 3.8.5 Click for Rectangles

Answer: RECT_HEIGHT = 50

RECT_WIDTH = 30

def draw_rectangle(x, y):

rectangle = Rectangle(50, 30)

rectangle.set_position(x, y)

add(rectangle)

addmouseclickhandler(drawrectangle)

Question: https://drive.google.com/drive/folders/1pN_SDmC0Wi51NytrGNC2IBOI5FeIcopC?usp=sharing

Answer: Link for google drive containing pictures of the code.