Python Junior

1 / 9

What are negative indexes in Python?

Select the correct answer

1

Negative indexes in Python allow counting from the end of a list.

2

Negative indexes in Python are used for error handling.

3

Negative indexes in Python start the count from zero.

4

Negative indexes in Python are only for string manipulation.

What is a docstring in Python, and why is it useful?

Select the correct answer

1

A docstring is a type of exception in Python.

2

A docstring is a variable name in Python.

3

A docstring is a comment used to document code in Python.

4

A docstring is a string literal used for documentation in Python.

Explain the pass statement in Python.

Select the correct answer

1

The pass statement raises an exception.

2

The pass statement pauses the execution of code.

3

The pass statement exits the current loop.

4

The pass statement is a no-op placeholder in Python.

How do you handle exceptions in Python?

Select the correct answer

1

Exceptions in Python are handled using try and catch blocks.

2

Exceptions in Python are handled using validate and except blocks.

3

Exceptions in Python are handled using error and catch blocks.

4

Exceptions in Python are handled using try and except blocks.

Is Python pass by reference or pass by value?

Select the correct answer

1

Python uses a mix of pass by reference and pass by value.

2

Python is pass by value.

3

Python is pass by reference.

4

Python is pass by object reference.

Explain mutable and immutable data types in Python?

Select the correct answer

1

Mutable types cannot be changed after creation, while immutable types can.

2

Only strings in Python are immutable.

3

Mutable types can be changed after creation, while immutable types cannot.

4

Both mutable and immutable types cannot be changed after creation.

What is PEP 8, and why is it important?

Select the correct answer

1

PEP 8 is a security standard in Python.

2

PEP 8 is the style guide for writing Python code.

3

PEP 8 is a performance enhancement proposal.

4

PEP 8 is a Python error prevention tool.

Is Python statically or dynamically typed?

Select the correct answer

1

Python is weakly typed.

2

Python is statically typed.

3

Python is dynamically typed.

4

Python uses type inference.

Is Python a compiled language or an interpreted language?

Select the correct answer

1

Python is an interpreted language.

2

Python is a compiled language.

3

Python is a scripting language only.

4

Python is a low-level programming language.