Following is an example of ___________________ sv = “csiplearninghub.comâ€
1.List
2.String
3.Dictionary
4.None of the above
Python allows _____________ operations on string data type.
1.Concatenation
2.Membership
3.Slicing
4.Slicing
str[5 : 11] will return ___________ character
1.5
2.6
3.11
4.None of the above
What is the index value of ‘i’ in string “Learningâ€
1.5
2.3
3.6
4.7
What type of error is returned by the following : str = "Learning" print(str[10])
1.Error in Index
2.Index out of range in string
3.IndexError
4.None of the above
What we call the following:
1.Escape Sequence
2.Special Character
3.Don’t have any common term
4.Keyword
Which operator is used for string concatenation?
1.*
2.//
3.+
4.-
Write the output of the following : >>> str1 = 'Hello World! Hello Hello' >>> str1.count('Hello')
1.1
2.2
3.3
4.4
Write the output of the following code : a = '''A B C''' print(a)
1.ABC
2.A BC
3. A B C
4.Error
Write the output of the following code : a="Learn" while(a): print(a)
1.L e a r n
2.Error
3.Infinite Loop
4.Learn
Write the output of the following code : for i in "STR": print(i)
1. S TR
2.STR
3.S T R
4.S T R
Write the output of the following. s = “hello 123†print(s.islower())
1.False
2.True
3.Error
4.None of the above
Write the output of the following: print('aisabisacisadisae'.split('isa',3))
1.[‘a’, ‘b’, ‘c’, ‘disae’]
2.[‘a’, ‘b’, ‘cisadisae’]
3. [‘a’, ‘b’, ‘c’, ‘d’, ‘e’]
4.None of the above
>>> “Hey!â€.endswith(‘!’) will return ______
1.True
2.False
3.Error
4.None of the above
A _____________ can be created by enclosing one or more characters in single, double or triple quote
1. String
2.List
3.Tuple
4.Dictionary
Characters in a string can be _________ enclosed in quotes.
1.Digits
2.white space
3.letter
4.All the above
Content of string can not be changed, it means that string is
1.mutable
2.immutable
3.reversible
4.None of the above
Each individual character in a string can be accessed using a technique called _____
1.Indexing
2.Replication
3.Concatenation
4.None of the above
find( ) function returns ___________ if the substring is not present in the given string
1.0
2.1
3.-1
4.Error
Following code will return ? s = “Hello†print(s.count(‘l’,2,5))
1.2
2.3
3.1
4.None of the above
How many operators are used in the following statement? 7 + 4 * 8 // 2 ** 2 - 6 / 1
1.5
2.6
3.7
4.8
If no delimiter is given in split( ) function then words are separated by ____
1.space
2.colon
3.semi colon
4.None of the above
If we give index value out of the range then we get an ___
1.ValueError
2. SyntaxError
3. IndexError
4.Error
Index value in String should be of type ________________
1.Float
2.Integer
3.String
4.Boolean
index( ) function returns _______________ if the substring is not present in the given string
1.0
2.1
3.-1
4.Error
Name a function which is same as find() but raises an exception if the substring is not present in the given string.
1. index( )
2.endswith( )
3. startswith( )
4.count( )
Name the function which is used to find length of string.
1.length( )
2.len( )
3. strlen( )
4.slen( )
partition( ) function of string in python return the result in the form of ____
1.String
2.List
3.Tuple
4.Dictionary
partition() function divides the main string into ________ substring.
1.1
2.2
3.3
4.4
print(“aNd&*â€.swapcase()) will display _
1.AnD*&
2.AnD&*
3. aNd&*
4.Error
Slice operation can also take a third parameter that specifies the _____
1. Starting index
2.Ending index
3.Step Size
4.None of the above
split( ) function returns the _______________of words delimited by the specified substring.
1.List
2.Tuple
3.Dictionary
4.None of the above
str[11 : 5] will return _________
1.empty string
2.complete string
3. string of six characters
4.None of the above
The index of the first character ____________ on the string is 0
1. from left
2.from right
3.from middle
4.None of the above
We can access each character of a string or traverse a string using ___
1.for loop only
2.while loop only
3.both of the above
4.conditional statement
What index value is returned by the following code? s = “Hello†print(s.find(‘l’))
1.2
2.3
3.4
4.-2
What type of error is returned by statement : >>> str[1.5]
1.SyntaxError
2.ValueError
3.. IndexErro
4.. TypeError
Which character will have same index value when you access elements from the beginning and from the end(ignore the negative sign) in the following string. s = “Welcome to my blogâ€
1.‘t’
2.‘ ‘
3. ‘o’
4. ‘t’
Which function in the following statement will execute first? print("amit".lower().upper())
1. print( )
2. lower( )
3. upper( )
4.None of the above
Which function in the following statement will execute last? print("amit".lower().upper())
1.print( )
2.lower( )
3.upper( )
4.None of the above
Which of the following function can take maximum three arguments/parameters?
1.find( )
2.index( )
3.count( )
4.All the above
Which of the following function removes only leading spaces from the string?
1.strip( )
2.lstrip( )
3. rstrip( )
4.Lstrip( )
Which of the following function return the integer value?
1.lower( )
2. upper( )
3.islower( )
4.find( )
Which of the following function returns the ASCII/Unicode value character?
1.asc( )
2.ord( )
3.asci( )
4. ascii( )
Which of the following function returns the index value of first occurrence of substring occurring in the given string.
1. index( )
2.. find( )
3.Both of the above
4.None of the above
Which of the following function returns the string with first letter of every word in the string in uppercase and rest in lowercase?
1.swapcase( )
2.upper( )
3.title( )
4.capitalize( )
Which of the following function returns True if the string is non-empty and has all uppercase alphabets.
1. islower( )
2. islower( )
3.Islower( )
4. islower( )
Which of the following is a mapping data type?
1.String
2.List
3.Tuple
4.Dictionary
Which of the following is correct slicing operation to extract every kth character from the string str1 starting from n and ending at m-1.
1.str1[: : k]
2.str1[n : m+1 : k]
3.str1[n : m : k ]
4.str1[m : n : k ]
Which of the following is not a String built in functions?
1. partition( )
2.isupper( )
3.lower( )
4.swapcases( )
Which of the following is not an inbuilt function of string?
1.length( )
2.find( )
3. endswith( )
4.split( )
Which of the following statement is correct in accessing each element of string?a) a="Learning" while(i): print(i) b) a="Learning" for i in a: print(i)
1. a only
2.b only
3.both a and b
4.None of the above
Which of the following statements will also return the same result as given statement? print(“Computer†+ “Computerâ€)
1.print(“Computer†, †“, “Computerâ€)
2.print(“Computerâ€,â€Computerâ€)
3.print(“Computer†**2)
4.print(“Computer†* 2)
Which of the following will return reverse string str1?
1.str1[ : : -1]
2.str1[: : 1]
3.str1[: -1 : -1 ]
4.None of the above
Which of the function returns Boolean value?
1. find( )
2.index( )
3.endwith( )
4.endswith( )
Which operator is used with integers as well as with strings?
1./
2.//
3.**
4.*
Write the output of the following : >>> str1 = 'Hello World! Hello Hello' >>> str1.count('Hello',12,25)
1.1
2.2
3.3
4.4
Write the output of the following : >>> str1 = ‘HelloWorld!!’ >>> str1.isalnum()
1.False
2.True
3.Error
4.None of the above
Write the output of the following : print("Absbcbcgdbc".count("b",4))
1.1
2.2
3.3
4.4
Write the output of the following : print("Absbcbcgdbc".find("b",5))
1.1
2.2
3.5
4.6
Write the output of the following code : a= "Welcome to blog" print(a)
1.Welcome to blog
2.Welcome to blog
3.Welcome to blog
4.Error
Write the output of the following code : a= "Welcome to "my" blog" print(a)
1.Welcome to “my†blog
2.Welcome to â€my†blog
3.Error
4.None of the above
Write the output of the following code : for i in (1,2,3): print("@" * i)
1.Error
2.@@@@@@
3.@ @@ @@@
4.@ @ @ @ @ @
Write the output of the following code : s= "str" s1 = "string" print(s1 in s)
1.True
2.False
3.Error
4.None of the above
Write the output of the following code : s= "str" Write the output of the following code : for i in range(65,70): print(chr(i))
1.Error
2.TypeError
3.A B C D E
4.ABCDE
Write the output of the following code : s= "str" Write the output of the following code : for i in range(65,70): print(chr(i))
1.Error
2.TypeError
3.A B C D E
4.ABCDE
Write the output of the following code : s="blog" for i in range(-1,-len(s),-1): print(s[i],end="$")
1.g$o$l$b$
2.g$o$l$
3.Error
4.None of the above
Write the output of the following code : str = "Welcome" l=len(str) print(l)
1.6
2.7
3.8
4.Error
Write the output of the following code : str = "Welcome" str[2] = 'a' print(str)
1. Weacome
2.Error
3. aWelcome
4.Welcomea
Write the output of the following. >>> str1 = ‘Hello World! Hello >>> str1.index(‘Hee’)
1.0
2.1
3.Error
4.None of the above
Write the output of the following. >>> str1 = ‘Hello World!’ >>> str1.endswith(‘World!’)
1.True
2.False
3.yes
4.Error
Write the output of the following. a = "Blog" a ='a' print(a)
1.Bloga
2.aBlog
3.Blog
4.a
Write the output of the following. print(‘#’.join(“12345â€))
1.#12345
2.#12345#
3.1#2#3#4#5
4.1#2#3#4#5#
Write the output of the following. str = “python†print(str[2+1])
1. t
2.h
3.th
4.Error
Write the output of the following: >>> len(" python".lstrip()) #2 spaces are given before "python"
1.5
2.6
3.7
4.8
Write the output of the following: >>> str1 = 'hello ??' >>> str1.islower( )
1.NO
2.True
3.false
4.Error
Write the output of the following: >>> str1 = 'Hello World!' >>> str1.replace('o' , '*')
1.Hello World!’
2. ‘Hell* W*rld!’
3.‘Hello W*rld!’
4.Error
Write the output of the following: >>> str1 = 'hello WORLD!' >>> str1.title()
1. HELLO world
2.Hello World
3.Hello world
4.HeLlO WoRlD
Write the output of the following: >>> str1 = 'India is a Great is Country' >>> str1.partition('is')
1.(‘India ‘, ‘is’, ‘ a Great is Country’)
2.(‘India ‘, ‘is’, ‘a Great’, ‘is’, ‘Country’)
3.(‘India ‘, ‘is’, ‘ a Great Country’)
4.Error
Write the output of the following: >>> str1 = 'String MCQ' >>> str1.startswith('Str')
1.True
2.False
3.yes
4.No
Write the output of the following: "@".join("python")
1.p@y@t@h@o@n’
2.‘p@y@t@h@o@n@’
3.@p@y@t@h@o@n@’
4.‘@
Write the output of the following: "python".join("@")
1.‘p@y@t@h@o@n’
2.p@y@t@h@o@n@’
3.‘@p@y@t@h@o@n@’
4.@’
Write the output of the following: 2 + '3'
1. 2 3
2.23
3.SyntaxError
4.TypeError
Write the output of the following: a="We to my b ok" print(a)
1.We to my b ok
2.We to myb ok
3.Weto my b ok
4.None of the above
Write the output of the following: for i in range(len("python"),12,2): print("python"[i-6])
1.p t o
2.p y t h o n
3.y h n
4.p y t h
Write the output of the following: print('aisabisacisadisae'.split('isa'))
1.[‘a’, ‘b’, ‘c’, ‘disae’]
2.[‘a’, ‘b’, ‘cisadisae’]
3.[‘a’, ‘b’, ‘c’, ‘d’, ‘e’]
4.None of the above
Write the output of the following: print("Welcome-Python".isalnum())
1.True
2.False
3.yes
4.No
Write the output of the following: print(“A#B#C#D#Eâ€.replace(“#â€,â€?â€))
1.A#B#C#D#E
2.A?B?C?D?E
3.Can not replace as Strings are immutable
4.Error
Write the output of the following: print(“A#B#C#D#Eâ€.split(“#â€,2))
1.[‘A’, ‘B’, ‘C#D#E’]
2.[‘A#’, ‘B#’, ‘C#D#E’]
3. [‘A’, ‘B’, ‘C’ , ‘D’ , ‘E’]
4.Error
Write the output of the following: print(“I love my Countryâ€.find(“oâ€,4))
1.3
2.12
3.11
4.3,11
Write the output of the following: print(len("\\\///"))
1.9
2.Error
3.3
4.6
Write the output of the following: print(str("WelcomePython".isalnum()).upper())
1.TRUE
2.True
3.FLAS
4.Error
Write the output of the following: s = †Hello†print(s.find(‘a’))
1. 0
2.-1
3.1
4.Error
Write the output of the following: str = "Amit is a is a" s = str.partition('is') print(s[1])
1. is a
2.a
3.is
4.i
_________ method is used to access some part of a string or substring.>>> str1 = ‘Hello World!’ >>> ‘W’ in str1
1.Slicer
2.Slicing
3.Membership
4.None of the above