Python String Quiz

Last Updated :
Discuss
Comments

Question 1

Which of the following is true about lists in Python?

  • A

    Lists are dynamic sized arrays

  • B

    Lists store references at items contiguous locations

  • C

    A list can contain elements of different types.

  • D

    All of the above

Question 2

What are strings in Python?
 

  • A

    Arrays of bytes representing Unicode characters

  • B

    Arrays of integers representing characters

  • C

    Single characters only

  • D

    Arrays of floats representing characters

Question 3

What does the string method .join() do in Python?
 

  • A

    Splits a string into a list

  • B

    Concatenates a list of strings into one string

  • C

    Reverses a string

  • D

    Returns the index of a substring in the string

Question 4

Which method can be used to handle strings with both single and double quotes simultaneously in Python?
 

  • A

    Using triple quotes

  • B

    Using backslash ()

  • C

    Using parentheses

  • D

    Using single quotes only

Question 5

How can you print a string without resolving escape sequences in Python?
 

  • A

    By using the repr() function

  • B

    By using the eval() function

  • C

    By using the str() function

  • D

    By using the format() function

Question 6

What is the primary reason that updating or deleting characters from a string in Python is not allowed?
 

  • A

    Strings are mutable data types

  • B

    Python strings are immutable data types

  • C

    Python doesn't support character-level operations on strings

  • D

    Python string operations are not efficient

Question 7

What is the purpose of the find() function in Python strings?
 

  • A

    It returns the position of the last occurrence of a substring within a string.

  • B

    It returns true if the string begins with a specified prefix.

  • C

    It returns the position of the first occurrence of a substring within a string.

  • D

    It returns true if all the letters in the string are lowercased.

Question 8

What does the startswith() function in Python do?
 

  • A

    It returns true if all the letters in the string are uppercased.

  • B

    It returns true if the string starts with a specified prefix.

  • C

    It returns true if the string ends with a specified suffix.

  • D

    It returns true if all the letters in the string are lowercased

Question 9

What does the title() method do in Python strings?
 

  • A

    It converts the first letter of every word to uppercase and others to lowercase.

  • B

    It swaps the cases of all letters in the string.

  • C

    It converts all letters to uppercase.

  • D

    It converts all letters to lowercase.

Question 10

What is the time complexity of the find() function in Python?
 

  • A

    O(log n)

  • B

    O(n^2)

  • C

    O(n)

  • D

    O(1)

There are 16 questions to complete.

Take a part in the ongoing discussion