Instructions

  • 1. Your final score will reflect your grasp of the concepts—approach each question with precision.
  • 2. Thoroughly review each solution before proceeding to ensure full understanding.
  • 3. Final results will be available after submission to provide insights into areas for further improvement.
  • 4. Maintain academic integrity—plagiarism undermines learning and professional growth.
  • 5. Once submitted, responses are final, so ensure you’re confident in your answers.
  • 6. These challenges are designed to test practical knowledge; apply your skills as you would in real-world scenarios.

All Problems

Question

Action

What will be the result of list(range(5))[1:4]?

View

What is the output of [x**2 for x in range(3)]?

View

What does list[-1] do?

View

What will [1, 2, 3][:-1] return?

View

How can you flatten [[1, 2], [3, 4]] using a list comprehension?

View

What is the output of [x for x in range(5) if x % 2 == 0]?

View

What does list[::2] return for list = [1, 2, 3, 4, 5]?

View

What happens if you access an index out of range in a list?

View

Which of the following creates a shallow copy of a list?

View

How can you convert a list of integers into strings?

View

What will be the result of list(range(5))[1:4]?

[1, 2, 3]
[0, 1, 2]
[2, 3, 4]
[1, 2]

What is the output of [x**2 for x in range(3)]?

[0, 1, 4]
[1, 2, 3]
[0, 1, 2]
[1, 4, 9]

What does list[-1] do?

Returns the first element
Returns the last element
Throws an IndexError
Removes the last element

What will [1, 2, 3][:-1] return?

[1, 2, 3]
[1, 2]
[2, 3]
[]

How can you flatten [[1, 2], [3, 4]] using a list comprehension?

[x for sublist in lst for x in sublist]
[sublist for x in lst]
flatten(lst)
[x for x in lst]

What is the output of [x for x in range(5) if x % 2 == 0]?

[0, 1, 2, 3, 4]
[0, 2, 4]
[2, 4]
[1, 3]

What does list[::2] return for list = [1, 2, 3, 4, 5]?

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

What happens if you access an index out of range in a list?

Returns None
Raises IndexError
Returns False
Appends None to the list

Which of the following creates a shallow copy of a list?

list.copy()
list = list[:]
list = list()
Both a and b

How can you convert a list of integers into strings?

str(list)
[str(x) for x in list]
map(int, list)
list(int)