Python Output-Based Questions - Set 2 (List,
Tuple, Dictionary, Set, String Slicing)
x = [1, 2, 3]
Q1 print(x[1:])
x = [1, 2, 3]
Q2 print(x[:2])
x = [1, 2, 3]
Q3 print(x[-3:])
x = [1, 2, 3]
Q4 print(x[::3])
x = [1, 2, 3]
Q5 print(x[::-2])
x = [1, 2, 3]
Q6 print(x[1:3:2])
x = [1, 2, 3]
y = x
[Link](4)
Q7 print(y)
x = [1, 2, 3]
y = [Link]()
[Link](4)
Q8 print(y)
x = [1, 2, 3]
Q9 print([Link](2))
x = [1, 2, 3, 2]
Q10 print([Link](2))
t = (1, 2, 3, 4)
Q11 print(t[::2])
t = (1, 2, 3)
Q12 print(min(t))
t = (1, 2, 3)
Q13 print(max(t))
t = (1, 2, 3)
Q14 print(sum(t))
t = (1, 2, 3)
Q15 print([Link](3))
t = (1, 2, 3, 2)
Q16 print([Link](2))
t = tuple('abc')
Q17 print(t)
t = (1, 2) + (3, 4)
Q18 print(t)
t = (1, 2)*3
Q19 print(t)
t = (1, [2, 3])
t[1].append(4)
Q20 print(t)
d = {1: 'a', 2: 'b'}
Q21 print(d[1])
d = {1: 'a', 2: 'b'}
Q22 print(2 in d)
d = {1: 'a', 2: 'b'}
Q23 print('a' in [Link]())
d = {1: 'a', 2: 'b'}
Q24 print(list([Link]()))
d = dict(a=1, b=2)
Q25 print(d)
d = {}
d['x'] = 10
Q26 print(d)
d = {'x': 1, 'y': 2}
Q27 print([Link]())
d = {'x': 1, 'y': 2}
[Link]()
Q28 print(d)
d = {'x': 1, 'y': 2}
Q29 print([Link]())
d = {'x': 1, 'y': 2}
Q30 print([Link]())
s = {1, 2, 3}
Q31 print(max(s))
s = {1, 2, 3}
Q32 print(min(s))
s = {1, 2, 3}
Q33 print(sum(s))
s = {1, 2, 3} ^ {3, 4, 5}
Q34 print(s)
s = {1, 2, 3}
[Link](2)
Q35 print(s)
s = {1, 2, 3}
[Link](5)
Q36 print(s)
s = {1, 2, 3}
[Link]({4, 5})
Q37 print(s)
s = {1, 2, 3}
[Link]()
Q38 print(s)
s = {i for i in range(5)}
Q39 print(s)
s = {1, 2, 3}
Q40 print(len(s) == 3)
s = 'abcdef'
Q41 print(s[2:5])
s = 'abcdef'
Q42 print(s[-4:-1])
s = 'abcdef'
Q43 print(s[1:5:2])
s = 'abcdef'
Q44 print(s[::-3])
s = 'abcdef'
Q45 print(s[::])
s = 'abcdef'
Q46 print(s[:])
s = 'abcdef'
Q47 print('cd' in s)
s = 'abcdef'
Q48 print([Link]('a', 'z'))
s = 'abcdef'
Q49 print([Link]('d'))
s = 'abcdef'
Q50 print([Link]('c'))