wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Unit 4 Advanced AP CSP

Total questions: 10

Worksheet time: 10mins

Name
Class
Date
1.
1. Which of the following scenarios would require the use of a function?
a)
A. Storing a user's name
b)
B. Evaluating an arithmetic expression
c)
C. Repeating a set of instructions for different inputs
d)
D. Comparing two values
2.
2. How would you modify the value of an existing variable named "age" to 25?
a)

A. age == 25

b)

B. age = 25

c)

C. 25 += age

d)

D. age(25)

3.
3. Which of the following is not a comparison operator?
a)

A. !=

b)

B. ==

c)

C. <=

d)

D. &&

4.
4. In a conditional statement, which type of value determines which code block is executed?
a)
A. Integer
b)
B. String
c)
C. Boolean
d)
D. Float
5.
5. If a function is designed to calculate the square of a number, what would be the result of the function call for the value 5?
a)
A. 10
b)
B. 25
c)
C. 30
d)
D. 35
6.

6. How would you code the NOT logical operator to reverse the truth value of the expression (a > b)?

a)

A. !(a > b)

b)

B. (a > b) NOT

c)

C. (a > b) !=

d)

D. NOT (a > b)

7.
7. Analyze the following expression: (x > 10) AND (y < 20). What type of value does this expression return?
a)
A. Integer
b)
B. Float
c)
C. String
d)
D. Boolean
8.
8. When should you use a function call instead of directly writing the code?
a)
A. When the code needs to be executed only once
b)
B. When the code is simple and short
c)
C. When the same code is used repeatedly with different inputs
d)
D. When the code doesn't return a value
9.
9. Evaluate the following expression: (3 < 5) OR (7 > 10). What is the result?
a)
A. True
b)
B. False
c)
C. 1
d)
D. 0
10.
10. Given a function that takes two numbers as input and returns their sum, how would you call this function with the values 4 and 6?
a)
A. sum(4, 6)
b)
B. add(4 + 6)
c)
C. sum[4, 6]
d)
D. add{4, 6}