Unit 3 AP Practice

Pataasin ang iyong marka sa homework at exams ngayon gamit ang Quizwiz!

Consider the following code segment. a ← 1 b ← a a ← 2 What value is stored in variable b?

1

What will the following code segment evaluate to? a ← 10 b ← 5 c ← 2 expression = (a - b) * c DISPLAY(expression)

10

Which of the following operations will output a value of 5?

11 % 6

What does the following Python program print? x = 9 + 6 / 3 * 2 - 1 print(x)

12

On the AP exam, the ← operator is used for variable assignment. For example, a ← 10 assigns the value 10 to the variable a. Consider the following code segment. a ← 10 b ← 5 c ← a + b What is stored in variable c?

15

On the AP Exam, the modulus operator is denoted by MOD. The MOD operator has the same precedence as the * and / operators. What will c evaluate to in the following code segment? a ← 17 b ← 5 c ← a MOD b

2

What will the following code segment evaluate to? a ← 9 b ← 5 c ← 4 expression = a + b * c DISPLAY(expression)

29

What will the following code segment evaluate to? a ← 10 b ← 5 c ← 2 expression = a / b * c DISPLAY(expression)

4

What is a callback function?

A function passed to an event handler that is called every time a certain event happens

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 do contain a space following the value printed. What is displayed as a result if the user inputs "P" to the program? DISPLAY ("Enter a character. ") symbol ← INPUT () DISPLAY (":") DISPLAY ("c") DISPLAY (symbol)

Enter a character. P : c P

What does the following Python program print? x = "I am" y = 6 z = "feet tall" print(x) print(y) print(z)

I am 6 feet tall

In the following code, we create a circle and add it to the screen. What is the meaning of the x and y variables? x = 20 y = 20 circ = Circle(30) circ.set_position(x, y)

The position of the center of the circle.

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 do contain a space following the value printed. What will display after running the following code? a ← "Welcome!" DISPLAY (a) b ← "‎¡Hola!" DISPLAY (b) a ← b b ← "Bonjour!" DISPLAY (a) DISPLAY (b)

Welcome! ‎¡Hola! ‎¡Hola! Bonjour!

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 do contain a space following the value printed. Consider the code segment below. DISPLAY ("What is your name?") name ← INPUT () DISPLAY ("Hello") DISPLAY (name) What is displayed as a result if the user inputs "Karel" to the program?

What is your name? Karel Hello Karel

Suppose we've written a function draw_circle that we want to call every time the mouse is clicked. How can we do this?

add_mouse_click_handler(draw_circle)

What are the coordinates of the top right corner of the screen?

get_width(), 0

What function do you need to call to ask the user of the program to enter text?

input

To ask the user of the program for a number, which function should you use?

input inside of a int( ) function

What is the proper keyword to print to the screen?

print

Which of the following print statements is written correctly?

print("Hello World")

What type is the following variable? x = "Hi there"

string

hellohellohello

var = "hello" print(var) print(var) print(var)

Which of the following Python programs will not run?

x = 4 y = "hi" print(x + y)


Kaugnay na mga set ng pag-aaral

Basic Overview of GSM Communications

View Set

9.) Introduction to Body Cavities

View Set

exam 4 fundamentals practice questions

View Set