Search Header Logo

Python & Aptitude Quiz 1

Authored by Abhishek Singh

Engineering

University

Used 1+ times

Python & Aptitude Quiz 1
AI

AI Actions

Add similar questions

Adjust reading levels

Convert to real-world scenario

Translate activity

More...

    Content View

    Student View

35 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Media Image

1. What is the output of the given code?

[2, 3, 4]
[1, 2, 3, 4, 5]
[1, 2, 3]
[1, 2, 3, 4]

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

2. Which of the following is the correct way to open a file for writing in binary mode in Python?

open('filename', 'w')
open('filename', 'rb')
open('filename', 'a')
open('filename', 'wb')

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Media Image

3. What will be the output of `print(my_set)` after this code is executed?

{1, 2, 3, 4}
{1, 2, 3}
{2, 3, 4, 5}
{1, 2, 3, 4, 4}

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

4. What is a decorator in Python?

A decorator is a method for creating classes in Python.
A decorator is a built-in data type in Python.
A decorator is a type of variable in Python.
A decorator is a function that wraps another function to extend its behavior.

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

5. What does the `*args` syntax in a function definition allow you to do?

It allows a function to accept only keyword arguments.
It restricts the number of arguments a function can take.
It enables a function to return multiple values.
It allows a function to accept a variable number of positional arguments.

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

6. What is the primary difference between a list and a tuple?

The primary difference is that lists are mutable and tuples are immutable.
Lists are faster than tuples in all operations.
Tuples are used for storing data, while lists are used for functions.
Lists can contain only numbers, while tuples can contain any data type.

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

7. What is the purpose of the `yield` keyword in Python?

The `yield` keyword is used to return a value from a function immediately.
The `yield` keyword is for defining a class in Python.
The `yield` keyword is used to create a constant variable in Python.
The purpose of the `yield` keyword is to define a generator that can produce a sequence of values over time.

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?