Search Header Logo
Foun.CompSci_Final Exam review - Fall

Foun.CompSci_Final Exam review - Fall

Assessment

Presentation

Computers

8th - 10th Grade

Medium

Created by

Kathleen Ma

Used 9+ times

FREE Resource

1 Slide • 48 Questions

1

COMPSCI_Final Exam review - Fall

by Kathleen Ma

2

Multiple Choice

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

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

name = "William Shatner"

1

What is your name?

2

William Shatner

3

Name

4

Whatever the user inputs

3

Multiple Choice

if color == "green":

print("Sounds good! We'll make the car green!")

elif color == "yellow":

print("Sounds good! We'll make the car yellow!")

else:

print("Sounds good! We'll make the car gray by default!")

1

comparitor

2

conditional

3

switch-route

4

boolean

4

Multiple Choice

A statement is...

1

A line of code that performs some action

2

A line of code that ends with a period

3

A line of code that begins with a # mark

4

A way to make your code more fashionable

5

Multiple Choice

x = 0

y = 1

if x == y:

x = 1

else:

x = 0

1

1

2

Syntax Error

3

01

4

0

6

Multiple Choice

What does the print( ) command do?

1

It causes text output to appear in the console

2

It gets text input from the user

3

It turns on the printer

4

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

7

Multiple Choice

x = 0

y = 10

if x < y:

x = y

1

10

2

100

3

0

4

Logic Error

8

Multiple Choice

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

1

Concatenation ("catting")

2

Output

3

Typecast

4

Interior

9

Fill in the Blanks

Type answer...

10

Multiple Choice

What is a variable?

1

A type of string literal

2

A container that holds information

3

The place where output appears

4

The difference between two values

11

Multiple Choice

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


superhero = "Captain America"

print(superhero)

1

superhero

2

print

3

Captain America

4

"Captain America"

12

Multiple Choice

Which of the following is NOT true about conditions?

1

They are boolean expressions

2

They always produce the value True or False

3

You can only have one condition per conditional

4

They come between the keyword and colon in a conditional clause

13

Multiple Choice

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

1

String

2

Integer

3

Float

4

All of these

5

None of these

14

Multiple Choice

Question image

In the code below, what line of code that is not part of the conditional.

1

elif choice == "winter":

2

if choice == "summer":

3

location = "outside"

4

temp = 60

15

Multiple Choice

What is the data type of the value 11.46?

1

String

2

Integer

3

Float

4

Increment

16

Multiple Choice

Question image

What value is in the variable y after this code runs?

1

10

2

100

3

5

4

1000

17

Multiple Choice

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)

1

25

2

15

3

10

4

40

18

Multiple Choice

What symbol is used in Python to divide with no remainder? (floor division operator)

1

//

2

**

3

%%

4

++

19

Multiple Choice

What command creates text output in Python?

1

input("What is your name? ")

2

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

3

print(name)

4

int(name)

20

Multiple Choice

How do you put an if-statement inside another if-statement (nesting)?

1

Surround the inner conditional with ( ) symbols

2

Use two conditions in a row in the second clause

3

Use two `if` keywords in a row in the second clause

4

Indent the second conditional underneath the first one

21

Multiple Choice

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


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

1

str(pets)

2

float(pets)

3

int(pets)

4

num(pets)

22

Multiple Choice

The % symbol or modulo operator is used to...

1

Raise a number to a power

2

Get the square root of a number

3

Get the remainder after division

4

Get whole number division by throwing away the remainder

23

Multiple Choice

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


pets = 2 + 2

print("The total is: " + pets)

1

str(pets)

2

float(pets)

3

int(pets)

4

num(pets)

24

Multiple Choice

Which of the following chained comparison ranges includes the number 16?

1

10 < x < 16

2

10 < x < 20

3

16 < x < 20

4

All of the above

25

Multiple Choice

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


food1 = "Chicken "

food2 = "Soup"

print(var1 + var2)

1

Chicken Soup

2

Chicken

3

Soup

4

"Chicken Soup"

26

Multiple Choice

What library is needed in order to use the square root (sqrt) function?

1

math

2

randint

3

random

4

square

27

Multiple Choice

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


num = "Eleven"

num = "Twelve"

print(num)

1

"Eleven"

2

Twelve

3

Eleven

4

"Twelve"

28

Multiple Choice

What library is needed in order to get random numbers?

1

math

2

randint

3

random

4

number_generator

29

Multiple Choice

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


var = "Yo, "

var += "Adrian!"

print(var)

1

Yo,

2

Adrian!

3

"Yo, Adrian!"

4

Yo, Adrian!

30

Multiple Choice

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


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

1

"^%^"

2

" #@#"

3

Both

4

Neither

31

Multiple Choice

Documentation on a built-in library such as math or random will tell us...

1

What functions are in the library

2

What arguments a library function needs

3

What a library function does

4

All of the above

32

Multiple Choice

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, ")

1

print("Here, " dog)

2

print("Here, " + dog)

3

print("Here, dog")

4

print("Here, " + "dog")

33

Multiple Choice

In coding, AI is usually short for...

1

All Incidents

2

Added Investigation

3

Artificial Intelligence

4

Artificial Interrogation

34

Multiple Choice

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


print "Buy a yearbook."

1

print("Buy a yearbook.")

2

print + "Buy a yearbook."

3

print = (Buy a yearbook.")

4

print(Buy a yearbook.)

35

Multiple Choice

Which of the following is NOT a logical operator?

1

and

2

or

3

not

4

equal

36

Multiple Choice

Choose the expression that best represents the sentence: "I plan to go out to the park if the weather is nice and there is no baseball or soccer practice going on."

1

good_weather and baseball and soccer

2

good_weather or (baseball and soccer)

3

not (good_weather or baseball or soccer)

4

good_weather and not baseball or soccer

37

Multiple Choice

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

num = 42

print("The number is: " + num)

1

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

2

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

3

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

4

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

38

Multiple Choice

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


var input("Enter a value: ")

print(var)

1

var=input("Enter a value: ")

2

var = input("Enter a value: ")

3

var + input("Enter a value: ")

4

var-input("Enter a value: ")

39

Multiple Choice

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

1

They let us know the computer didn't understand something

2

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

3

They give a hint about where the error is

4

They give a hint about what the error is

40

Multiple Choice

Why are variables useful?

1

Unknown values can be stored in them

2

The same value can be used in multiple places

3

Complicated calculations can be broken into pieces

4

All of these

41

Multiple Choice

Rewrite this line of code to use the increment operator.


num = num + 10

1

num = num += 10

2

num = num =+ 10

3

num = num -= 10

4

num = num =- 10

42

Multiple Choice

What symbol is used for the assignment operator?

1

+

2

-

3

=

4

*

43

Multiple Choice

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))

1

value = 100 + int(money)

2

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

3
4

44

Multiple Choice

What is the final value stored in num?

num = "18" + "18"

1

36

2

"36"

3

1818

4

There's not enough information to be sure

45

Multiple Choice

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


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

1

50 + 50

2

x = 50

3

x += 50

4

print("50")

46

Multiple Choice

What value is the result of this expression?


55 % 5

1

11

2

5

3

275

4

60

47

Multiple Choice

Which line would be ignored by the computer?


"""

Code Stuff

"""


# Code Stuff

1

Both

2

Neither

3

"""

Code Stuff

"""

4

# Code Stuff

48

Multiple Choice

What data type is the result of the following expression?


11 / 3

1

String

2

Integer

3

Float

4

Input

49

Multiple Choice

What data type is the result of the following expression?


input("What is your favorite animal? ")

1

String

2

Integer

3

Float

4

Input

COMPSCI_Final Exam review - Fall

by Kathleen Ma

Show answer

Auto Play

Slide 1 / 49

SLIDE