Python end assesment-2

Python end assesment-2

University

15 Qs

quiz-placeholder

Similar activities

Introduction to Python

Introduction to Python

University

20 Qs

MCAC0019 Quiz (Based on MODULES & PACKAGES)

MCAC0019 Quiz (Based on MODULES & PACKAGES)

University

15 Qs

BPP UNIT-1,2 AID

BPP UNIT-1,2 AID

University

20 Qs

UNIT 1 PYTHON

UNIT 1 PYTHON

University

20 Qs

quiz dasar python

quiz dasar python

1st Grade - University

20 Qs

Quiz1_7A

Quiz1_7A

2nd Grade - Professional Development

20 Qs

Chapter 1 Python

Chapter 1 Python

8th Grade - University

12 Qs

Basic Python

Basic Python

University

20 Qs

Python end assesment-2

Python end assesment-2

Assessment

Quiz

Computers

University

Medium

Created by

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

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?