
Python end assesment-2

Quiz
•
Computers
•
University
•
Medium
Narendra Varma
Used 2+ times
FREE Resource
15 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
1.What is the purpose of a function in Python?
To declare variables
To repeat a block of code
To perform a specific task
To import modules
2.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Which keyword is used to define a function in python?
func
define
def
int main(int a,intb)
3.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
3)What will be the output of the following Python code
import random
def generate_random_numbers():
numbers = [random.randint(1, 10) for in range(5)]
return numbers
try:
print(generaterandom_numbers())
except Exception as e:
print("Error:", e)
finally: print("Finally block executed"
Note:The above mentioned try-catch block is not in generate_random_numbers function.It was outside of it.
A list of 5 random numbers between 1 and 10
Error: 'random' module not found
Error: Invalid input to randint() function
Finally block executed
4.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
4.What is recursion?
A loop structure
A function that calls itself
An error in python
A module in python
5.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
5.What is an anonymous function in Python?
A function that doesnt have a name
A built-in python function
A function with multiple parameters
A function with single line of code
6.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Which of the following is NOT a built-in exception in Python
FileNotFoundError
TypeError
ZeroDivisionError
CustomError
7.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the purpose of the finally block in exception handling?
To execute regardless of whether an exception occurs or not
To catch exceptions
TO define custom exceptions
TO raise exceptions
Create a free account and access millions of resources
Similar Resources on Wayground
20 questions
Introduction To Python

Quiz
•
University
20 questions
Python for beginners

Quiz
•
University
15 questions
Python End of Topic Quiz

Quiz
•
8th Grade - University
20 questions
Grade 7 Python Programming Quiz

Quiz
•
7th Grade - University
10 questions
Python Basics

Quiz
•
University
10 questions
Python

Quiz
•
University
15 questions
Python Programming

Quiz
•
5th Grade - University
10 questions
Python Unit 3

Quiz
•
University
Popular Resources on Wayground
11 questions
Hallway & Bathroom Expectations

Quiz
•
6th - 8th Grade
20 questions
PBIS-HGMS

Quiz
•
6th - 8th Grade
10 questions
"LAST STOP ON MARKET STREET" Vocabulary Quiz

Quiz
•
3rd Grade
19 questions
Fractions to Decimals and Decimals to Fractions

Quiz
•
6th Grade
16 questions
Logic and Venn Diagrams

Quiz
•
12th Grade
15 questions
Compare and Order Decimals

Quiz
•
4th - 5th Grade
20 questions
Simplifying Fractions

Quiz
•
6th Grade
20 questions
Multiplication facts 1-12

Quiz
•
2nd - 3rd Grade