Python Functions and Exceptions Review

Python Functions and Exceptions Review

Assessment

Flashcard

Computers

9th - 12th Grade

Hard

Created by

Quizizz Content

FREE Resource

Student preview

quiz-placeholder

15 questions

Show all answers

1.

FLASHCARD QUESTION

Front

Which of the following is the correct way to declare a function in Python? Options: print_hello: print("hello"), function print_hello(): print ("hello"), print_hello(): print("hello"), def print_hello(): print("hello").

Back

def print_hello(): print("hello")

2.

FLASHCARD QUESTION

Front

Which of the following code samples correctly passes the number 10 as an argument to the function print_number? Options: print_number(10), print_number() print 10, 10(print_number), print print_number print 10

Back

print_number(10)

3.

FLASHCARD QUESTION

Front

Consider this code snippet. Which of the following additional functions could be safely added below this code, without causing an error?

Back

Media Image

4.

FLASHCARD QUESTION

Front

Which of the following functions successfully returns the number 10?

Back

Media Image

5.

FLASHCARD QUESTION

Front

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

Back

ValueError

6.

FLASHCARD QUESTION

Front

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

Back

To handle exceptions gracefully and either handle the error or print out a useful error message.

7.

FLASHCARD QUESTION

Front

Which of the programs below will print the following output?
I would like a green balloon.

Back

Media Image

Create a free account and access millions of resources

Create resources
Host any resource
Get auto-graded reports
or continue with
Microsoft
Apple
Others
By signing up, you agree to our Terms of Service & Privacy Policy
Already have an account?