Search Header Logo

Unit 6 Review

Authored by Julia McGreal

Computers

9th - 12th Grade

Used 15+ times

Unit 6 Review
AI

AI Actions

Add similar questions

Adjust reading levels

Convert to real-world scenario

Translate activity

More...

    Content View

    Student View

11 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

45 sec • 1 pt

Which of the following is the correct way to declare a function in Python?

print_hello: print("hello")
function print_hello(): print ("hello")
print_hello(): print("hello")
def print_hello(): print("hello")

2.

MULTIPLE CHOICE QUESTION

45 sec • 1 pt

Which of the following code samples correctly passes the number 10 as an argument to the function print_number?

print_number(10)
print_number(), print 10
10(print_number)
print print_number, print 10

3.

MULTIPLE CHOICE QUESTION

45 sec • 1 pt

Consider this code snippet. x = 10, def add_nums(): y = 2, z = x + y, print(z) Which of the following additional functions could be safely added to this code, without causing an error?

def subtract_nums(): z = x - y, print(z)
def subtract_nums():, z = z - x, print(z)
def subtract_nums():, y = 5, z = x - y, print(z)
def subtract_nums(): z = y, z = x - y, print(z)

4.

MULTIPLE CHOICE QUESTION

45 sec • 1 pt

Which of the following functions successfully returns the number 10?

def my_function(): 10
def my_function(10): return
def my_function(): return 10
def my_function(): print(10)

5.

MULTIPLE CHOICE QUESTION

45 sec • 1 pt

What type of error occurs when a program is expecting an integer value and the user enters a string?

NumberError
ValueError
InputError
ZeroDivisionError

6.

MULTIPLE CHOICE QUESTION

45 sec • 1 pt

Why do programmers use try and except statements when their code might throw an exception?

So that the programmer can disregard the exception and do what he/she wants anyways
Because Python requires it
To handle exceptions gracefully and either handle the error or print out a useful error message.
Exceptions only are thrown when there are try and except statements. Otherwise, the program will just fail and the programmer will have no idea why it failed.

7.

MULTIPLE CHOICE QUESTION

45 sec • 5 pts

Which of the programs below will print the following output?

I would like a green balloon.

def balloon_choice(color): print("I would like a " + color + " balloon.") balloon_choice("green")

def balloon_choice(color): print("I would like a " + color + " balloon.")

def balloon_choice(): print("I would like a " + color + " balloon.") balloon_choice("green")

def balloon_choice(): print("I would like a green balloon.") balloon_choice("green")

Access all questions and much more by creating a free account

Create resources

Host any resource

Get auto-graded reports

Google

Continue with Google

Email

Continue with Email

Classlink

Continue with Classlink

Clever

Continue with Clever

or continue with

Microsoft

Microsoft

Apple

Apple

Others

Others

Already have an account?