Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

[AP CSP] Programming: Conditionals

Total questions: 10

Worksheet time: 20mins

Name
Class
Date
1.

When the code is ran, an error occurs due to line 4. What type of error exists in line 4?

a)

Syntax Error

b)

Type Error

c)

Indentation Error

d)

Concatenation Error

2.

Given the following set of code, what would be the output?

a)

you earned nothing :/

b)

You earned 5 points!

c)

You earned 10 points!

d)

You earned 15 points!

e)

Syntax Error

3.

There's syntax error in lines 2 and 4. What is the proper correction?

a)

use the == comparing operater

b)

use parenthesis around the condition

c)

use .lower() function for line 1

d)

using str() function for the conditions

4.

Given the code, what would be the output if the inputs were 8 and 60?

a)

You can not ride the roller coaster

b)

You can ride the roller coaster

c)

Syntax Error

d)

None

5.

Given the following code, which line(s) of code would be skipped if the initial input for tentacles was "n" ?

a)

Lines 3-7

b)

Lines 2-7

c)

Line 2

d)

Line 5 & 7

6.

When this code is ran with the input: y, 64, what is the resulting output?

a)

Your price is $20, Your price is $15

b)

Your price is $20

c)

Your price is $15

d)

Your price is $12.5, Your price is 12.50

7.

For the given code, which line(s) of code would be read if the inputs were: n, 65 ?

a)

Your price is $7.50

b)

Your price is $15

c)

Your price is $12.50

d)

Your price is $20

8.

There's a syntax error for this program code. What line is it one?

a)

Line 14

b)

Line 1

c)

Line 17

d)

Line 2

9.

The code utilizes the randint() fuction. What line of code should be at the top to be able to use the randint() in line 2?

a)

from random import randint

b)

import randint from random

c)

import randint

d)

import random

10.

What is the error in this code?

a)

the input for age should be casted into an integer

b)

the else condition should be an elif

c)

there should quotations around the "8" and "60

d)

There should be a str() function used in line 2.