wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Ch. 5 Exam Review

Total questions: 25

Worksheet time: 13mins

Name
Class
Date
1.

If you concatenate strings together with the plus sign (+), which of the following statements is true?

a)

No spaces will be added to separate the parts within the output string

b)

A space will be automatically added to separate each part within the output string

c)

Only the longer input string will appear in the output string

d)

The resulting string must be less than 128 characters in length

2.

When you use the print() statement to automatically concatenate multiple parameters together, which of the following statements is true?

a)

No spaces will be added to separate the parts within the output string

b)

A space will be automatically added to separate each part within the output string

c)

Only the first parameter will be present in the output string

d)

The resulting string must be less than 128 characters in length

3.

What is the output when the following statements are run? favoriteColor = "purple" print("My favorite color is", favoriteColor)

a)

purple

b)

My favorite color ispurple

c)

My favorite color is favoriteColor

d)

My favorite color is purple

4.

What is the output when the following statements are run? accountBalance = 112.5 print("My balance is: $", accountBalance)

a)

$ 112.5

b)

My balance is: $ accountBalance

c)

My balance is: $ 112.5

d)

You will see an error because you can't use a numeric parameter inside print()

5.

Which answer shows the output from the following print() statement? print("If you can dream it", "you can do it.", sep="#")

a)

If you can dream it#you can do it.

b)

If you can dream it, you can do it.

c)

If#you#can#dream#it#you#can#do#it.

d)

you can do it.#sep#If you can dream it

6.

How many lines of output will be shown from the following code? print("Line 1", end = " ") print("Line 2") print("Line 3", end = " ")

a)

1

b)

2

c)

3

d)

0

7.

Which of the following two statements about the print() function are true?

a)

print() with multiple parameters will automatically convert all values to strings and join them together with a space

b)

print() with a single string parameter will display the exact string that you pass in

c)

Both of these are true

d)

Neither of these is true

8.

What type of data does the input() function return?

a)

String

b)

Integer

c)

Floating point

d)

It depends on what the user types in

9.

Which of the following best describes the input() parameter?

a)

It contains a text prompt for the user to enter a value

b)

It contains the length of time the function will wait for an answer

c)

It contains the name of the variable that will hold the output

d)

It contains the number of values the user must enter

10.

If the user enters "18" in response to an input() question, what kind of data is returned?

a)

An integer containing 18

b)

A string containing "18"

c)

A floating point containing 18.0

d)

A "True" Boolean value showing success

11.

Which of the following statements will successfully prompt the user for input and store the result in the "answer" variable?

a)

input.answer("What is your quest?")

b)

answer("What is your quest?")

c)

answer = parse(What is your quest?)

d)

answer = input("What is your quest?")

12.

Which of the following statements will convert a string stored in "inputResults" to an integer variable called "age"?

a)

age = int(inputResults)

b)

age.int(inputResults)

c)

inputResults = parse(age)

d)

age = inputResults.parse()

13.

Which function would you use to convert a string value to a floating point value?

a)

int()

b)

parse()

c)

float()

d)

decimal()

14.

What will happen when the following statements run? value = "orange" result = int(value)

a)

You will see a ValueError message due to invalid int() input

b)

The result variable will contain 0

c)

The result variable will contain the length of the string stored in the value variable

d)

Both value and result variables will be set to 0

15.

How many input parameters are provided to the str.format() function?

a)

3 only

b)

1 only

c)

1 or more as needed to build your output string

d)

None

16.

How many additional str.format() parameters are expected if the format string parameter contains "Happy birthday {}, happy birthday to you"?

a)

1

b)

2

c)

3

d)

0

17.

What string value is stored in the answer variable after the following statement is run? answer = str.format("{2} {1} {0}", "with","great","power")

a)

power great with

b)

with great power

c)

great power with

d)

power power power

18.

How would you create a str.format() placeholder in the format string to ensure at least 20 characters minimum width for the first value?

a)

0{20}

b)

[20:0]

c)

{0:20}

d)

{:20.0}

19.

Which of the following placeholder expressions in a str.format() format string will limit (truncate) the width of an output value to 10 characters?

a)

{:5.10}

b)

[:10.5]

c)

{5:10}

d)

{5,10}

20.

What is the output from the following statement? print(str.format("Sale Price: ${:0,.}",1500))

a)

Sale Price: $ 1,500

b)

Sale Price: $ 1500

c)

Sale Price: $ 0

d)

Sale Price: $ ValueError

21.

Which vocabulary word means: To join two or more smaller strings into a single larger string value.

a)

Truncate

b)

Concatenation

c)

Alignment

d)

Event

22.

Which vocabulary word means: Data that is returned from a function back to the main program or from a program to the user.

a)

Output Data

b)

Truncate

c)

Input Data

d)

Event

23.

Which vocabulary word means: Data that is passed into a program or function that can be used to guide the program's behavior or output.

a)

Output Data

b)

Truncate

c)

Input Data

d)

Event

24.

Which vocabulary word means: A user action that occurs in a program.

a)

Output Data

b)

Truncate

c)

Input Data

d)

Event

25.

Which vocabulary word means: To clip or cut short a value or string after a certain number of characters or digits.

a)

Output Data

b)

Truncate

c)

Input Data

d)

Alignment