


Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!



The following code should draw a circle on the screen. def draw_circle(x, y, radius): circle = Circle(radius) circle.set_position(x, y) To add the circle to the canvas, you need to use the add(circle) command What is the output of the following program: (Assume the user enters 'Florence' then 'Fernandez'.) first_name = input("What is your first name? ") last_name = input("What is your last name? ") whole_name = first_name + last_name; print (whole_name) FlorenceFernandez Which of the following choices is a properly formed Python variable name, meaning it is both legal in the Python language and considered good style? user_age If you wanted to use the following code to draw a circle to the canvas with the radius, and x and y coordinates given by the user, how would you ask for this information? circle = Circle(radius) circle.set_position(x, y) x = int(input("What is the x coordinate? ")) y = int(input("What is the y coordinate? ")) radius = int(input("What is the radius of the circle? ")) If you were given the following variables: distance = 2 time = 30 What line of code would print the speed in km/hr if the distance is given in km and the time is given in minutes? (Speed = distance/time) print(distance/(time/60))
What is printed to the screen when the following program is run? num = 13 % 3 print(num) 1 What is printed to the screen if the user enters '5' when the following program is run? user_num = int(input("Enter your favorite number: ")) calculated_num = user_num * user_num + user_num print(calculated_num) 30 What does the following program do? radius = int(input("What is the radius of the circle? ")) circle = Circle(radius) circle.set_position(radius, radius) add(circle) Draw a circle on the canvas that is radius distance in the x and y direction from the top left corner If a user enters a diameter value in the variable diameter, how would we use this to draw the correct sized circle? circle = Circle(diameter / 2) A store has 20 apples in its inventory. How can you store this information in a Python variable? num_apples = 20 You want to read input from the user to know how many apples they would like to buy. Which statement should you use to read in a number from the user? apples_to_buy = int(input("How many apples would you like? ")) You are splitting up all of your apples equally between 3 people. Which statement below will calculate how many apples will be left over? left_over = num_apples % 3 In a graphics canvas with a size of WIDTH and a height of HEIGHT, what are the coordinates of the bottom right corner of the window? WIDTH, HEIGHT In a graphics canvas with a size of WIDTH and a height of HEIGHT, what are the coordinates of the center of the window? WIDTH / 2, HEIGHT / 2 In the following code: size = 20 x = 100 y = 200 ball = Circle(size) ball.set_position(x, y)
On the AP exam, INPUT() is used to accept a value from the user, and DISPLAY() is used to display a value. Values that are displayed are NOT started on a new line, but a space is added after the value. Consider the code segment below. DISPLAY ("What is your name?") name โ INPUT () DISPLAY ("Hello") DISPLAY (name) What is your name? Rowan Hello Rowan On the AP exam, the โ operator is used for variable assignment. For example, a โ 10 assigns the value 10 to the variable a. The value stored in a variable will always be the most recent value assigned. Consider the following code segment. a โ 12 b โ 3 c โ 27 a โ b b โ c c โ a What value is stored in variable c? 3