What will be the output of the following Python expression?
print(4.00/(2.0+2.0))
What will be the value of X in the following Python expression?
x = 2+9*((3*12)-8)/10
x=24//6%3, 24//4//2 print(x)
Which among the following list of operators has the highest precedence?
+, -, **, %, /, <<, >>, |
What will be the value of the following Python expression?
print(float(4+int(2.39)%2))
print(4+2**5//10)
What will be the output of the following Python code snippet?
>>bool(‘False’) >>bool()
not(3>4) not(1&1)
not(10<20) and not(10>30)
What will be the output of the following Python code?
print('{a}{b}{a}'.format(a='hello', b='world'))
x = ['ab', 'cd'] for i in x: i.upper() print(x)
x = ['ab', 'cd'] for i in x: x.append(i.upper()) print(x)
i = 1 while True: if i%3 == 0: break print(i) i + = 1
i = 1 while True: if i%7 == 0: break print(i) i += 1
i = 1 while True: if i%2 == 0: break print(i) i += 2
i = 2 while True: if i%3 == 0: break print(i) i += 2
i = 1 while False: if i%2 == 0: break print(i) i += 2
i = 0 while i < 5: print(i) i += 1 if i == 3: break else: print(0)
i = 0 while i < 3: print(i) i += 1 else: print(0)
x = "abcdef" while i in x: print(i, end=" ")
x = "abcdef" i = "i" while i in x: print(i, end=" ")
x = "abcdef" i = "a" while i in x: print(i, end = " ")
x = "abcdef" i = "a" while i in x: print('i', end = " ")
x = "abcdef" i = "a" while i in x: x = x[:-1] print(i, end = " ")
x = "abcdef" i = "a" while i in x[:-1]: print(i, end = " ")
x = "abcdef" i = "a" while i in x: x = x[1:] print(i, end = " ")
x = 'abcd' for i in x: print(i) x.upper()
x = 'abcd' for i in range(x): print(i)
x = 'abcd' for i in range(len(x)): print(i)
x = 'abcd' for i in range(len(x)): print(i.upper())
x = 'abcd' for i in range(len(x)): i.upper() print (x)
x = 'abcd' for i in range(len(x)): x[i].upper() print (x)
x = 'abcd' for i in range(len(x)): x = 'a' print(x)
x = 'abcd' for i in range(len(x)): print(x) x = 'a'
d = {0: 'a', 1: 'b', 2: 'c'} for i in d: print(i)
d = {0: 'a', 1: 'b', 2: 'c'} for x, y in d.items(): print(x, y)
d = {0: 'a', 1: 'b', 2: 'c'} for x in d.keys(): print(d[x])
d = {0: 'a', 1: 'b', 2: 'c'} for x in d.values(): print(x)
d = {0: 'a', 1: 'b', 2: 'c'} for x in d.values(): print(d[x])
d = {0, 1, 2} for x in d.values(): print(x)
d = {0, 1, 2} for x in d: print(x)
d = {0, 1, 2} for x in d: print(d.add(x))
for i in range(0): print(i)
for i in range(2.0): print(i)
for i in range(int(2.0)): print(i)
for i in [1, 2, 3, 4][::-1]: print (i)
for i in ''.join(reversed(list('abcd'))): print (i)
for i in 'abcd'[::-1]: print (i)
x = 2 for i in range(x): x += 1 print (x)
x = 2 for i in range(x): x -= 2 print (x)
for i in range(10): if i == 5: break else: print(i) else: print("Here")
for i in range(5): if i == 5: break else: print(i) else: print("Here")
x = (i for i in range(3)) for i in x: print(i)
string = "my name is x" for i in string: print (i, end=", ")
string = "my name is x" for i in string.split(): print (i, end=", ")
a = [0, 1, 2, 3] for a[-1] in a: print(a[-1])
a = [0, 1, 2, 3] for a[0] in a: print(a[0])
What will be the output of the following Python statement?
>>>"a"+"bc"
>>>"abcd"[2:]
>>>print('new' 'line')
>>>str1="helloworld"
>>>str1[::-1]
>>>example = "snow world"
>>>example[3] = 's'
>>>print example
>>>max("what are you")
>>>example = "helle"
>>>example.find("e")
example = "helle" print(example.rfind("e"))
>>>example="helloworld" >>>example[::-1].startswith("d")
>>>chr(ord('A'))
>>>print(chr(ord('b')+1))
print("abc DEF".capitalize())
print("abcdef".center())
print("abcdef".center(7, '1'))
print("abcdef".center(10, '12'))
print("xyyzxyzxzxyy".count('yy'))
print("xyyzxyzxzxyy".count('yy', 1))