PythonDQ retweeted
PythonDQ retweeted
What is output of following Python Code?
num = 15
if num % 2 == 0:
print("Even")
else:
print("Odd")
a) Even
b) Odd
c) Error
d) No output
What is the output of the Python code?
x = 20
if x < 10:
print("Less than 10")
elif x < 20:
print("Less than 20")
elif x < 30:
print("Less than 30")
else:
print("30 or more")
a) Less than 10
b) Less than 20
c) Less than 30
d) 30 or more
What is output of the Python code?
y = 8
if y > 10:
print("y is greater than 10")
elif y < 10 and y > 5:
print("y is between 5 and 10")
else:
print("y is 5 or less")
a) y is greater than 10
b) y is between 5 and 10
c) y is 5 or less
d) Error
What is the output of the Python code?
x = 10
if x > 5:
print("x is greater than 5")
elif x == 10:
print("x is 10")
else:
print("x is less than or equal to 5")
a) x is greater than 5
b) x is 10
c) x is less than or equal to 5
d) No output
Output of following Python code?
my_dict = {'a': 1, 'b': 2, 'c': 3}
new_dict = {}
for key in my_dict:
new_dict[key] = my_dict[key] ** 2
print(new_dict)
a) {'a': 1, 'b': 4, 'c': 9}
b) {'a': 1, 'b': 2, 'c': 3}
c) {'a': 2, 'b': 3, 'c': 4}
d) {'a': 1, 'b': 2, 'c': 3, 'd': 4}
What will be the output of the following Python code and why?
dict = {'a': 1, 'b': 2, 'c': 3}
print(1 in dict)
a) True
b) False
c) None
d) Error
3
4
918
dict = {'a': 1, 'b': 2, 'c': 3}
for value in dict.values():
print(value, end=' ')
a) 1 2 3
b) a b c
c) {'a': 1, 'b': 2, 'c': 3}
d) None
What will be the output of the following Python code?
my_dict = {'a': 1, 'b': 2, 'c': 3}
for key in my_dict:
print(key, end=' ')
print()
a) a b c
b) 1 2 3
c) a: 1 b: 2 c: 3
d) a b c 1 2 3
What will be the output of the following Python code?
my_dict = {'a': 1, 'b': 2, 'c': 3}
for key, value in my_dict.items():
if value % 2 == 0:
print(key)
a) a
b) b
c) c
d) a, c
What will be the output of the following Python code?
s = {1, 2, 3, 4}
print(sum(s))
a) 10
b) 4
c) An error message
d) None of the above
What will be the output of the following Python code?
s = {1, 2, 3, 4}
for i in range(5):
if i in s:
continue
else:
print(i)
a) 0
b) 4
c) 0, 4
d) No output
6
7
1,219
In Python, which of the following set operations is equivalent to set1.difference(set2)?
a) set1 - set2
b) set1 | set2
c) set1 & set2
d) set1 ^ set2
What will be the output of the following Python code?
s1 = {1, 2, 3, 4, 5}
s2 = {4, 5, 6, 7, 8}
print(len(s1 | s2))
a) 5
b) 8
c) 10
d) 13
What will be the output of the following Python code?
s1 = {1, 2, 3, 4}
s2 = {3, 4, 5, 6}
print(s1.intersection(s2))
a) {1, 2}
b) {3, 4}
c) {5, 6}
d) Error





