What is the result of cmp(3, 1)?
What is the output of the following?
x = 123
for i in x:
print(i)
What is the output of the following?
d = {0: 'a', 1: 'b', 2: 'c'}
for x in d.keys():
print(d[x])
The ______ symbol along with the name of the decorator function can be placed above the definition of the function to be decorated works as an alternate way for decorating a function.
Following set of commands are executed in shell, what will be the output?
1.>>>str="hello"
2.>>>str[:2]
3.>>>
What is the result of the expression shown below if x=56.236?
print("%.2f"%x)
The output of the line of code shown below is:
not(10<20) and not(10>30)
What is the output of the following?
x = 'abcd'
for i in range(len(x)):
i.upper()
print (x)
What arithmetic operators cannot be used with strings ?
What is the output of the following code ?
class Name:
def __init__(self, firstName, mi, lastName):
self.firstName = firstName
self.mi = mi
self.lastName = lastName
firstName = "John"
name = Name(firstName, 'F', "Smith")
firstName = "Peter"
name.lastName = "Pan"
print(name.firstName, name.lastName)
Suppose i is 5 and j is 4, i + j is same as
What is the output of the following?
print("abcdef".center(0))
What is the value of this expression:
bin(10-2)+bin(12^4)
To check whether string s1 contains another string s2, use
What is the output of the following?
for i in '':
print (i)
Suppose x is 345.3546, what is format(x, “10.3f”) (_ indicates space)
The output of executing string.ascii_letters can also be achieved by:
The expression Int(x) implies that the variable x is converted to integer. State whether true or false.
Given a function that does not return any value, What value is thrown by default when executed in shell.
What is the output of the following?
x = "abcdef"
i = "a"
while i in x:
print('i', end = " ")
What is the output of the code shown below?
'{0:.2f}'.format(1.234)
Which one of the following have the highest precedence in the expression?
What is the output of the following?
d = {0: 'a', 1: 'b', 2: 'c'}
for x in d.values():
print(x)
What is the output of “hello”+1+2+3 ?
Consider the snippet of code shown below and predict the output.
X=”san-foundry”
print(“%56s”,X)
What is the output of the code shown below?
t = '%(a)s, %(b)s, %(c)s'
t % dict(a='hello', b='world', c='universe')
Which among the following list of operators has the highest precedence?
+, -, **, %, /, <<, >>, |
Mathematical operations can be performed on a string. State whether true or false.
The output of the code shown below is:
s='{0}, {1}, and {2}'
s.format('hello', 'good', 'morning')
Which of the following expressions is an example of type conversion?
What is the output of the code shown below?
D=dict(p='san', q='foundry')
'{p}{q}'.format(**D)
What is the output of the following?
d = {0: 'a', 1: 'b', 2: 'c'}
for x, y in d:
print(x, y)
Which of the following expressions results in an error?
What is the output of the following?
a = [0, 1, 2, 3]
for a[-1] in a:
print(a[-1])
Which of the following is not a complex number?
Which of the following is true for variable names in Python?
What is the output of the following expression if the value of x is 34?
print(“%f”%x)
Fill in the blanks:
The formatting method {1:<10} represents the ___________ positional argument, _________ justified in a 10 character wide field.