Python String Quiz (original) (raw)
What is the output of the following program?
Python `
a = 2 b = '3.77' c = -8 s = '{0:.4f} {0:3d} {2} {1}'.format(a, b, c) print(s)
`
What are strings in Python?
- Arrays of bytes representing Unicode characters
- Arrays of integers representing characters
- Arrays of floats representing characters
What does the string method .join() do in Python?
- Splits a string into a list
- Concatenates a list of strings into one string
- Returns the index of a substring in the string
Which method can be used to handle strings with both single and double quotes simultaneously in Python?
How can you print a string without resolving escape sequences in Python?
- By using the repr() function
- By using the eval() function
- By using the str() function
- By using the format() function
What is the primary reason that updating or deleting characters from a string in Python is not allowed?
- Strings are mutable data types
- Python strings are immutable data types
- Python doesn't support character-level operations on strings
- Python string operations are not efficient
What is the purpose of the find() function in Python strings?
- It returns the position of the last occurrence of a substring within a string.
- It returns true if the string begins with a specified prefix.
- It returns the position of the first occurrence of a substring within a string.
- It returns true if all the letters in the string are lowercased.
What does the startswith() function in Python do?
- It returns true if all the letters in the string are uppercased.
- It returns true if the string starts with a specified prefix.
- It returns true if the string ends with a specified suffix.
- It returns true if all the letters in the string are lowercased
What does the title() method do in Python strings?
- It converts the first letter of every word to uppercase and others to lowercase.
- It swaps the cases of all letters in the string.
- It converts all letters to uppercase.
- It converts all letters to lowercase.
What is the time complexity of the find() function in Python?
There are 16 questions to complete.
Take a part in the ongoing discussion