Python Output-Based Questions - Set 3 (100
Questions)
x = [i**2 for i in range(5)]
Q1 print(x)
x = [1, 2, 3]
Q2 print(x[1:10])
x = [[1, 2], [3, 4]]
Q3 print(x[1][0])
x = [None]*3
Q4 print(x)
x = [1, 2, 3]
Q5 print([Link]())
x = [1, 2, 3]
Q6 print([Link](0))
x = [1, 2, 3]
Q7 print(id(x))
x = [1, 2]
y = [3, 4]
Q8 print(x+y)
x = [1, 2, 3]
Q9 print(min(x))
x = [1, 2, 3]
Q10 print(max(x))
x = [1, 2, 3]
Q11 print(sorted(x, reverse=True))
x = [1, 2, 3]
Q12 print(reversed(x) == x[::-1])
x = [1, 2, 3]
Q13 for i in x: print(i, end=' ')
x = ['a', 'b']
Q14 print(x*3)
x = [1, [2, 3]]
Q15 print(len(x))
x = [1, [2, 3]]
Q16 print(len(x[1]))
x = list('abc')
Q17 print(x)
x = [True, False, True]
Q18 print(all(x))
x = [True, False, True]
Q19 print(any(x))
x = []
Q20 print(bool(x))
t = (i for i in range(3))
Q21 print(tuple(t))
t = (1,)
Q22 print(t*5)
t = tuple(range(5))
Q23 print(t[::3])
t = (1, 2, 3)
a, b, c = t
Q24 print(b)
t = (1, 2, 3)
a, *b = t
Q25 print(b)
t = (1, 2, 3)
*a, b = t
Q26 print(a)
t = (1, (2, 3))
Q27 print(t[1][1])
t = tuple('python')
Q28 print(t[1:4])
t = (1, 2, 3)
Q29 print(sum(t))
t = (1, 2, 3)
Q30 print(any(t))
t = (0, 0, 0)
Q31 print(any(t))
t = (True, False)
Q32 print(all(t))
t = (1, 2, 3)
Q33 print(len(t))
t = (1, 2, 3)
Q34 print(type(t))
t = tuple()
Q35 print(len(t))
t = (1, 2, 3)
Q36 print(id(t))
t = (1, 2, 3)
Q37 print(hash(t))
t = (1, 'a', 3.5)
Q38 print(t)
t = ((1, 2), (3, 4))
Q39 print(max(t))
t = ((1, 2), (3, 4))
Q40 print(min(t))
d = {i: i**2 for i in range(3)}
Q41 print(d)
d = [Link](['a', 'b'], 0)
Q42 print(d)
d = {'a': 1}
Q43 print([Link]('b', 2))
d = {'a': 1, 'b': 2}
Q44 print([Link]('a'))
d = {'a': 1, 'b': 2}
Q45 print([Link]('c'))
d = {1: 'one', 2: 'two'}
Q46 print(list([Link]())[0])
d = {'x': 1, 'y': 2}
Q47 for k, v in [Link](): print(k, v)
d = {'x': 1, 'y': 2}
Q48 print(len(d))
d = {'x': 1}
Q49 print('x' in d)
d = {'x': 1}
Q50 print(1 in [Link]())
d = {'x': 1}
Q51 print(2 in [Link]())
d = {'a': 1, 'b': 2}
Q52 print({v: k for k, v in [Link]()})
d = {'a': 1, 'b': 2}
Q53 print(sorted(d))
d = {'a': 1, 'b': 2}
Q54 print(sorted([Link]()))
d = {'a': 1, 'b': 2}
Q55 print(sorted([Link]()))
d = {'a': [1, 2]}
d['a'].append(3)
Q56 print(d)
d = {'a': 1}
[Link]({'b': 2, 'c': 3})
Q57 print(d)
d = {'x': 1}
[Link]()
Q58 print(d)
d = dict(zip(['a', 'b'], [1, 2]))
Q59 print(d)
d = {'a': 1, 'b': 2}
Q60 print(list(d))
s = {i for i in range(5) if i%2==0}
Q61 print(s)
s = set('hello')
Q62 print(s)
s = {1, 2, 3}
Q63 print(all(s))
s = {0, 1, 2}
Q64 print(all(s))
s = {0, 0.0}
Q65 print(len(s))
s = {1, 2}
Q66 print(frozenset(s))
s = {1, 2, 3}
Q67 print(isinstance(s, set))
s = set()
Q68 print(type(s))
s = {1, 2, 3}
Q69 print(len(s))
s = {1, 2, 3}
Q70 print(sum(s))
s = {1, 2}
[Link](2)
Q71 print(s)
s = {1, 2}
[Link](3)
Q72 print(s)
s = {1, 2, 3} - {3}
Q73 print(s)
s = {1, 2} | {3}
Q74 print(s)
s = {1, 2} & {2, 3}
Q75 print(s)
s = {1, 2} ^ {2, 3}
Q76 print(s)
s = {1, 2, 3}
Q77 print(3 in s)
s = {1, 2, 3}
Q78 print(4 not in s)
s = {True, 1}
Q79 print(len(s))
s = {False, 0}
Q80 print(len(s))
s = 'python'
Q81 print([Link]())
s = 'python'
Q82 print([Link]())
s = 'python'
Q83 print([Link]())
s = 'python'
Q84 print([Link]('py'))
s = 'python'
Q85 print([Link]('on'))
s = 'python'
Q86 print(s[1:])
s = 'python'
Q87 print(s[:4])
s = 'python'
Q88 print(s[::3])
s = 'python'
Q89 print(s[::-2])
s = 'python'
Q90 print(len(s))
s = 'python'
Q91 print([Link]('th'))
s = 'python'
Q92 print([Link]('o'))
s = 'python'
Q93 print([Link]('o'))
s = 'python'
Q94 print([Link]('p', 'P'))
s = 'python'
Q95 print('-'.join(s))
s = 'python'
Q96 print([Link]('t'))
s = 'python'
Q97 print([Link]())
s = 'Python'
Q98 print([Link]())
s = '123'
Q99 print([Link]())
s = 'abc123'
Q100 print([Link]())