Choose a topic to test your knowledge and improve your Python skills
What will be the output of the following Python code? x = (i for i in range(3)) for i in x: print(i)
What will be the output of the following Python code? x = (i for i in range(3)) for i in x: print(i) for i in x: print(i)
What will be the output of the following Python code? string = "my name is x" for i in string: print (i, end=", ")
What will be the output of the following Python code? string = "my name is x" for i in string.split(): print (i, end=", ")
What will be the output of the following Python code snippet? a = [0, 1, 2, 3] for a[-1] in a: print(a[-1])
What will be the output of the following Python code snippet? a = [0, 1, 2, 3] for a[0] in a: print(a[0])
What will be the output of the following Python code snippet? a = [0, 1, 2, 3] i = -2 for i not in a: print(i) i += 1
What will be the output of the following Python code snippet? string = "my name is x" for i in ' '.join(string.split()): print (i, end=", ")
What will be the output of the following Python code? for i in range(10): if i == 5: break else: print(i) else: print("Here")
What will be the output of the following Python statement? >>>"a"+"bc"
What will be the output of the following Python statement? >>>"abcd"[2:]
The output of executing string.ascii_letters can also be achieved by:
What will be the output of the following Python code? >>> str1 = 'hello' >>> str2 = ',' >>> str3 = 'world' >>> str1[-1:]
What arithmetic operators cannot be used with strings?
What will be the output of the following Python code? >>>print (r" hello")
What will be the output of the following Python statement? >>>print('new' 'line')
What will be the output of the following Python code? >>>str1="helloworld" >>>str1[::-1]
What will be the output of the following Python code? print(0xA + 0xB + 0xC)
What will be the output of the following Python code? >>>example = "snow world" >>>print("%s" % example[4:7])
What will be the output of the following Python code? >>>example = "snow world" >>>example[3] = 's' >>>print example
What will be the output of the following Python code? >>>max("what are you")
Given a string example=”hello” what is the output of example.count(‘l’)?
What will be the output of the following Python code? >>>example = "helle" >>>example.find("e")
What will be the output of the following Python code? >>>example = "helle" >>>example.rfind("e")
What will be the output of the following Python code? >>>example="helloworld" >>>example[::-1].startswith("d")
To concatenate two strings to a third what statements are applicable?
What will be the output of the following Python statement? >>>chr(ord('A'))
What will be the output of the following Python statement? >>>print(chr(ord('b')+1))
Which of the following statement prints helloexample est.txt?
Suppose s is “ World ”, what is s.strip()?
The format function, when applied on a string returns ______
What will be the output of the “hello” +1+2+3?
What will be the output of the following Python code? >>>print("D", end = ' ') >>>print("C", end = ' ') >>>print("B", end = ' ') >>>print("A", end = ' ')
What will be the output of the following Python statement?(python 3.xx) >>>print(format("Welcome", "10s"), end = '#') >>>print(format(111, "4d"), end = '#') >>>print(format(924.656, "3.2f"))
What will be displayed by print(ord(‘b’) – ord(‘a’))?
Say s=”hello” what will be the return value of type(s)?
What is “Hello”.replace(“l”, “e”)?
To retrieve the character at index 3 from string s=”Hello” what command do we execute (multiple answers allowed)?
To return the length of string s what command do we execute?
If a class defines the __str__(self) method, for an object obj for the class, you can use which command to invoke the __str__ method.
To check whether string s1 contains another string s2, use ____
Suppose i is 5 and j is 4, i + j is same as ________
What function do you use to read a string?
Suppose x is 345.3546, what is format(x, “10.3f”) (_ indicates space).
What will be the output of the following Python code? print("abc DEF".capitalize())
What will be the output of the following Python code? print("abc. DEF".capitalize())
What will be the output of the following Python code? print("abcdef".center())
What will be the output of the following Python code? print("abcdef".center(0))
What will be the output of the following Python code? print('*', "abcdef".center(7), '*')
What will be the output of the following Python code? print('*', "abcdef".center(7), '*', sep='')