list
= [ ‘xyz',
123, 1.23, ‘RAM',
17.5 ]
tinylist =
[123, ‘RAM']
print(list)
# Prints complete list
print(list[0])
# Prints first element of the list
print(list[1:3])
# Prints elements starting from 2nd till 3rd
print(list[2:])
# Prints elements starting from 3rd element
print(tinylist * 2)
# Prints list two times
print(list
+ tinylist) #
Prints concatenated lists
list.append(“Manish”)
#Applicable
print(“list[3:]
= ", list[3:])
tuple
= (‘xyz',
123, 1.23, ‘RAM', 17.5 )
tinytuple = (123,
‘RAM‘)
print(tuple)
# Prints complete list
print(tuple[0])
# Prints first element of the list
print(tuple[1:3])
# Prints elements starting from 2nd till 3rd
print(tuple[2:])
# Prints elements starting from 3rd element
print(tinytuple * 2)
# Prints list two times
print
(tuple + tinytuple) #
Prints concatenated lists
tuple.append(‘Manish’)
# Not
Applicable
dict = {}
dict['one']
= "This is one"
dict[2] =
"This is two"
tinydict =
{'name': ‘RAM','code:8989:,
'dept': ‘IT'}
print(dict['one'])
# Prints value for 'one' key
print(dict[2])
# Prints value for 2 key
print(tinydict) #
Prints complete dictionary
print(tinydict.keys()) #
Prints all the keys
print(tinydict.values()) #
Prints all the values
No comments:
Post a Comment