Open In App

Output of Python programs | Set 8

Prerequisite – Lists in Python 
Predict the output of the following Python programs.
 




list = [1, 2, 3, None, (1, 2, 3, 4, 5), ['Geeks', 'for', 'Geeks']]
print len(list)

6




list = ['python', 'learning', '@', 'Geeks', 'for', 'Geeks']
 
print list[::]         
print list[0:6:2]      
print list[ :6: ]      
print list[ :6:2]     
print list[ ::3]      
print list[ ::-2]    

['python', 'learning', '@', 'Geeks', 'for', 'Geeks']
['python', '@', 'for']
['python', 'learning', '@', 'Geeks', 'for', 'Geeks']
['python', '@', 'for']
['python', 'Geeks']
['Geeks', 'Geeks', 'learning']




d1 = [10, 20, 30, 40, 50]
d2 = [1, 2, 3, 4, 5]
print d1 - d1

No Output
TypeError: unsupported operand type(s) for -: 'list' and 'list'




list = ['a', 'b', 'c', 'd', 'e']
print list[10:]

[]




list = ['a', 'b', 'c']*-3
print list

[]

 


Article Tags :