0% found this document useful (0 votes)
80 views3 pages

Python Output-Based Questions Guide

The document contains a series of Python output-based questions focusing on data structures such as lists, tuples, dictionaries, sets, and string slicing. Each question includes a code snippet followed by a print statement to demonstrate the output of the code. The questions cover various operations and methods applicable to these data structures.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
80 views3 pages

Python Output-Based Questions Guide

The document contains a series of Python output-based questions focusing on data structures such as lists, tuples, dictionaries, sets, and string slicing. Each question includes a code snippet followed by a print statement to demonstrate the output of the code. The questions cover various operations and methods applicable to these data structures.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Python Output-Based Questions (List, Tuple,

Dictionary, Set, String Slicing)


x = [1, 2, 3]
Q1 print(x[1])

x = [10, 20, 30]


[Link](40)
Q2 print(x)

x = [1, 2, 3]
x[1] = 99
Q3 print(x)

x = [1, 2, [3, 4]]


Q4 print(x[2][1])

x = [1, 2, 3]
Q5 print(x*2)

x = [10, 20, 30, 40]


Q6 print(x[-2])

x = [1, 2, 3]
Q7 print(len(x))

x = [1, 2, 3]
Q8 print(sum(x))

x = ['a', 'b', 'c']


Q9 print(x[::-1])

x = [5, 2, 9]
[Link]()
Q10 print(x)

t = (1, 2, 3)
Q11 print(t[0])

t = (1, 2, 3)
Q12 print(len(t))

t = (1, 2, 3)
Q13 print(t[::-1])

t = (1, 2, 3)
Q14 print(2 in t)

t = (1, [2, 3], 4)


t[1][0] = 99
Q15 print(t)

t = (10, 20, 30)


Q16 print(t*2)

t = (1,)
Q17 print(type(t))

t = tuple([1, 2, 3])
Q18 print(t)

t = (1, 2, 3, 4)
Q19 print(t[1:3])
t = ('a', 'b', 'c')
Q20 print('b' in t)

d = {'a': 1, 'b': 2}
Q21 print(d['a'])

d = {'x': 10, 'y': 20}


d['z'] = 30
Q22 print(d)

d = {'p': 5, 'q': 6}
Q23 print(len(d))

d = {'m': 1, 'n': 2}
Q24 print('m' in d)

d = {'a': 1, 'b': 2}
Q25 print([Link]('c', 99))

d = {'a': 1, 'b': 2}
[Link]('a')
Q26 print(d)

d = dict([(1, 'one'), (2, 'two')])


Q27 print(d)

d = {'name': 'John', 'age': 25}


Q28 print(list([Link]()))

d = {'name': 'John', 'age': 25}


Q29 print(list([Link]()))

d = {'x': 10, 'y': 20}


[Link]({'x': 99})
Q30 print(d)

s = {1, 2, 3}
Q31 print(len(s))

s = {1, 2, 2, 3}
Q32 print(s)

s = {1, 2, 3}
[Link](4)
Q33 print(s)

s = {1, 2, 3}
[Link](2)
Q34 print(s)

s = {1, 2, 3} | {3, 4, 5}
Q35 print(s)

s = {1, 2, 3} & {2, 3, 4}


Q36 print(s)

s = {1, 2, 3} - {2}
Q37 print(s)

s = {1, 2, 3}
Q38 print(2 in s)

s = set([1, 2, 3])
Q39 print(s)
s = frozenset([1, 2, 3])
Q40 print(type(s))

s = 'Python'
Q41 print(s[0])

s = 'Python'
Q42 print(s[-1])

s = 'Python'
Q43 print(s[::2])

s = 'Python'
Q44 print(s[::-1])

s = 'Python'
Q45 print(s[1:4])

s = 'Python'
Q46 print(len(s))

s = 'Python'
Q47 print('y' in s)

s = 'Python'
Q48 print([Link]())

s = 'Python'
Q49 print([Link]())

s = 'Python Programming'
Q50 print([Link]())

You might also like