0% found this document useful (0 votes)
9 views

What Does The Lower Method Do in Python

python

Uploaded by

Abhishek Botikar
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views

What Does The Lower Method Do in Python

python

Uploaded by

Abhishek Botikar
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

What does the lower() method do in Python?

a) Converts the entire string to lowercase


b) Converts the entire string to uppercase
c) Converts the first character of the string to lowercase
d) Converts the first character of the string to uppercase

Which method can be used to capitalize the first character of each word in a string?
a) upper()
b) title()
c) capitalize()
d) swapcase()

What does the title() method do?


a) Converts the first character of the string to uppercase
b) Converts the entire string to uppercase
c) Capitalizes the first character of each word in the string
d) Converts the entire string to lowercase

How is indexing typically done in Python strings?


a) Using curly braces {}.
b) Using square brackets [].
c) Using parentheses ().
d) Using angle brackets <>.

What does the slicing operation do in Python strings?


a) Extracts a substring from the original string.
b) Reverses the original string.
c) Converts all characters to uppercase.
d) Counts the occurrences of a substring.

Which method is used to split a string into a list of substrings based on a specified delimiter?
a) split()
b) join()
c) replace()
d) index()

What does the count() method do?


a) Counts the number of occurrences of a substring in the string.
b) Returns the index of the first occurrence of a substring.
c) Replaces occurrences of a substring with another substring.
d) Removes leading and trailing whitespace from the string.

Which method returns the index of the first occurrence of a substring in a string?
a) find()
b) index()
c) count()
d) capitalize()

What does the isalnum() method return for a string containing only alphanumeric characters?
a) True
b) False
c) None
d) Error

Which method checks if all characters in a string are digits?


a) isdigit()
b) isalpha()
c) isalnum()
d) islower()

What does the strip() method do by default?


a) Removes all whitespace characters from the beginning and end of the string.
b) Removes specified characters from the beginning and end of the string.
c) Converts the string to uppercase.
d) Converts the string to lowercase.

Which method can be used to replace occurrences of a substring in a string with another
substring?
a) replace()
b) split()
c) find()
d) index()
What does the splitlines() method do?
a) Splits the string into lines based on newline characters.
b) Splits the string into lines based on whitespace.
c) Splits the string into words based on whitespace.
d) Splits the string into characters.

Which method can be used to determine the length of a string?


a) len()
b) length()
c) size()
d) count()

Which loop construct in Python is typically used for iterating over characters in a string?
a) for loop
b) while loop
c) do-while loop
d) foreach loop

What is the output of len("Python is fun")?


a) 10
b) 11
c) 12
d) 13

What is the result of "hello".upper()?


a) "HELLO"
b) "Hello"
c) "hello"
d) "hELLO"

What is the index of the first occurrence of "world" in the string "Hello world"?
a) 0
b) 1
c) 5
d) 6

What is the output of "apple".isalpha()?


a) True
b) False
c) Error
d) None

What is the output of "12345".isdigit()?


a) True
b) False
c) Error
d) None

You might also like