Docsity

CODEHS UNIT 3 PROGRAMMING WITH PYTHON (PYTHON) UPDATED ACTUAL QUESTIONS WITH CORRECT ANSWE, Exams of Programming Paradigms

Toggle sidebar
bg1
CODEHS UNIT 3 PROGRAMMING WITH PYTHON
(PYTHON) UPDATED ACTUAL QUESTIONS WITH
CORRECT ANSWERS
Question 1.
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 2.
3.7.8 French Flag
ANSWER
# Create a Blue rectangle on left
width= get_width() / 3
height= get_height()
blue_rect= Rectangle(width, height)
blue_rect.set_color(Color.blue)
blue_rect.set_position(1,1)
add(blue_rect)
# Create a Red rectangle on right
width = get_width() /3
height = get_height()
red_rect= Rectangle(width, height)
red_rect.set_color(Color.red)
red_rect.set_position(250 ,1)
add(red_rect)
i.
ii.
iii.
iv.
v.
vi.
vii.
viii.
ix.
i.
ii.
iii.
iv.
v.
vi.
vii.
viii.
ix.
x.
xi.
xii.
xiii.
xiv.
1 / 4
pf3
pf4

Partial preview of the text

Download CODEHS UNIT 3 PROGRAMMING WITH PYTHON (PYTHON) UPDATED ACTUAL QUESTIONS WITH CORRECT ANSWE and more Exams Programming Paradigms in PDF only on Docsity!

CODEHS UNIT 3 PROGRAMMING WITH PYTHON

(PYTHON) UPDATED ACTUAL QUESTIONS WITH

CORRECT ANSWERS

Question 1.

3.4.6: Apples and Oranges

ANSWER

Enter your code here

num_apples = 20 print("Number of apples: " + str(num_apples)) num_oranges= print("Number of oranges: " + str(num_oranges)) num_apples= print("Number of apples: " + str(num_apples)) num_oranges= print("Number of oranges: " + str(num_oranges))

Question 2.

3.7.8 French Flag

ANSWER

Create a Blue rectangle on left

width= get_width() / 3 height= get_height() blue_rect= Rectangle(width, height) blue_rect.set_color(Color.blue) blue_rect.set_position(1,1) add(blue_rect)

Create a Red rectangle on right

width = get_width() / height = get_height() red_rect= Rectangle(width, height) red_rect.set_color(Color.red) red_rect.set_position(250 ,1) add(red_rect)

i. ii. iii. iv. v. vi. vii. viii. ix.

i. ii. iii. iv. v. vi. vii. viii. ix. x. xi. xii. xiii. xiv.

Question 3.

3.6.7: Sporting Goods Shop

ANSWER

Enter your code here

COST_OF_FRISBEES = 15 amount = int(input("How many Frisbees would you like to buy?")) cost= (COST_OF_FRISBEES * amount) print("The cost for " + str(amount) + " frisbees is $" + str(cost) + " dollars.")

Question 4.

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 5.

3.6.9: 24 vs. "24"

ANSWER

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)

i. ii. iii. iv. v.

i. ii. iii. iv. v. vi. vii. viii. ix.

center_x = get_width() / 2 bottom_ball = Circle(BOTTOM_RADIUS / 2) bottom_ball.set_position(center_x, get_height() * 2/3) bottom_ball.set_color(Color.grey) add(bottom_ball) middle_ball = Circle(MID_RADIUS / 2) middle_ball.set_position(center_x, get_height() /2) middle_ball.set_color(Color.grey) add(middle_ball) top_ball = Circle(TOP_RADIUS / 2) top_ball.set_position(center_x, get_height() / 2.45) top_ball.set_color(Color.grey) add(top_ball)

Question 10.

3.6.8: Running Speed

ANSWER

Enter your code here

miles= float(input("How many miles did you run?")) minutes= float(input("How many minutes did it take you?")) MINUTES_PER_HOUR = 60 mPH = MINUTES_PER_HOUR * miles / minutes print("Speed in MPH: " + str(mPH))

vi. vii. viii. ix. x. xi. xii. xiii. xiv. xv. xvi. xvii. xviii.

i. ii. iii. iv. v. vi.