wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

TechSmart Unit 1 Review

Total questions: 32

Worksheet time: 2hrs 36mins

Name
Class
Date
1.

After this code executes, what is the value of the variable name?


name = input("What is your name? ")

name = "Frank Duvall"

a)

What is your name?

b)

Frank Duvall

c)

Name

d)

Whatever the user inputs

2.

A statement is...

a)

A line of code that performs some action

b)

A line of code that ends with a period

c)

A line of code that begins with a # mark

d)

A way to make your code more fashionable

3.

What does the print( ) command do?

a)

It causes text output to appear in the console

b)

It gets text input from the user

c)

It turns on the printer

d)

It adds the symbols ( ) to the end of a line

4.

int( ) is an example of what type of command?

a)

Concatenation ("catting")

b)

Output

c)

Typecast

d)

Interior

5.

What is a variable?

a)

A type of string literal

b)

A container that holds information

c)

The place where output appears

d)

The difference between two values

6.

In the following line of code, ID the string literal. (There is only one.)


superhero = "Captain America"

print(superhero)

a)

superhero

b)

print

c)

Captain America

d)

"Captain America"

7.

Which of the following data types can be assigned to variables?

a)

String

b)

Integer

c)

Float

d)

All of these

e)

None of these

8.

What is the data type of the value 11.46?

a)

String

b)

Integer

c)

Float

d)

Increment

9.

Given the following code, if the user enters 25 as input, what is the final output?


var = input("Please enter a value: ")

total = int(var) + 15

print(total)

a)

25

b)

15

c)

10

d)

40

10.

What command creates text output in Python?

a)

input("What is your name? ")

b)

name = input("What is your name? ")

c)

print(name)

d)

int(name)

11.

What type conversion (typecasting) should be used for the input below?


pets = input("Enter the number of pets you have: ")

a)

str(pets)

b)

float(pets)

c)

int(pets)

d)

num(pets)

12.

What type conversion (typecast) should be used for the variable total in line 2 below?


pets = 2 + 2

print("The total is: " + pets)

a)

str(pets)

b)

float(pets)

c)

int(pets)

d)

num(pets)

13.

Given the following code, choose the output that would appear in the console.


food1 = "Chicken "

food2 = "Soup"

print(var1 + var2)

a)

Chicken Soup

b)

Chicken

c)

Soup

d)

"Chicken Soup"

14.

Given the following code, choose the output that would appear in the console.


num = "Eleven"

num = "Twelve"

print(num)

a)

"Eleven"

b)

Twelve

c)

Eleven

d)

"Twelve"

15.

Given the following code, choose the output that would appear in the console.


var = "Yo, "

var += "Adrian!"

print(var)

a)

Yo,

b)

Adrian!

c)

"Yo, Adrian!"

d)

Yo, Adrian!

16.

Identify the literals in the following code. (There are 2.)


design = "^%^" + var + " #@#"

a)

"^%^"

b)

" #@#"

c)

Both

d)

Neither

17.

Change line 2 of this code so that the dog's name is printed after the word Here (on the same line).


dog = input("Enter your dog's name: ")

print("Here, ")

a)

print("Here, " dog)

b)

print("Here, " + dog)

c)

print("Here, dog")

d)

print("Here, " + "dog")

18.

Correct the syntax error in the code below so it prints Buy a yearbook.


print "Buy a yearbook."

a)

print("Buy a yearbook.")

b)

print + "Buy a yearbook."

c)

print ("Buy a yearbook.")

d)

print(Buy a yearbook.)

19.

Correct the syntax error in the code below so it prints Buy a yearbook.


print(Buy a yearbook.)

a)

print("Buy a yearbook.")

b)

print + "Buy a yearbook."

c)

print ("Buy a yearbook.")

d)

print(Buy a yearbook.)

20.

Add a str() typecast to the code below to prevent an error.

num = 42

print("The number is: " + num)

a)

prin(str("The number is: " + num))

b)

print("The number is: " + str("num"))

c)

print("The number is: " + str(num)

d)

print("The number is: " + str(num))

21.

Add an operator to the code below to prevent an error.


var input("Enter a value: ")

print(var)

a)

var=input("Enter a value: ")

b)

var = input("Enter a value: ")

c)

var + input("Enter a value: ")

d)

var-input("Enter a value: ")

22.

Which of the following is NOT a useful quality of error messages?

a)

They let us know the computer didn't understand something

b)

They force a program to run until the end, instead of quitting early

c)

They give a hint about where the error is

d)

They give a hint about what the error is

23.

Why are variables useful?

a)

Unknown values can be stored in them

b)

The same value can be used in multiple places

c)

Complicated calculations can be broken into pieces

d)

All of these

24.

Rewrite this line of code to use the increment operator.


num = num + 10

a)

num = num += 10

b)

num = num =+ 10

c)

num = num -= 10

d)

num = num =- 10

25.

What symbol is used for the assignment operator?

a)

+

b)

-

c)

=

d)

*

26.

In the code below, which uses the concatenation (catting) operator and NOT the addition operator.


money = input("How much is your phone worth? ")

value = 100 + int(money)

print("Your phone is now worth $" + str(value))

a)

value = 100 + int(money)

b)

print("Your phone is now worth $" + str(value))

27.

What is the final value stored in num?

num = "18" + "18"

a)

36

b)

"36"

c)

1818

d)

There's not enough information to be sure

28.

Which of the following is an expression, but not a statement?


(Hint: Expressions produce values, statements DO something.)

a)

50 + 50

b)

x = 50

c)

x += 50

d)

print("50")

29.

What value is the result of this expression?


55 % 5

a)

11

b)

5

c)

275

d)

60

30.

Which line would be ignored by the computer?


"""

Code Stuff

"""


# Code Stuff

a)

Both

b)

Neither

c)

"""

Code Stuff

"""

d)

# Code Stuff

31.

What data type is the result of the following expression?


11 / 3

a)

String

b)

Integer

c)

Float

d)

Input

32.

What data type is the result of the following expression?


input("What is your favorite animal? ")

a)

String

b)

Integer

c)

Float

d)

Input