25, there are the following variables, please implement the required functions
Tu= ("Alex", [11,22,{"K1": ' V1 ', "K2": ["Age", "name"], "K3":(11,22,33)},44])
A. Characteristics of Ganso: tuples have all the attributes of a list, but the elements of a tuple cannot be modified
B. Can you tell me if the first element in the TU variable, "Alex", could be modified? : Cannot be modified.
C. What is the value of "K2" in the TU variable? Is it possible to be modified? If you can, add an element, "Seven", to the
List, you can modify
Tu= ("Alex", [11,22,{"K1": ' V1 ', "K2": ["Age", "name"], "K3":(11,22,33)},44])
tu[1][2][' K2 '].append (' Seven ')
Print (TU)
D. What is the value of "K3" in the TU variable? Is it possible to be modified? If you can, add an element, "Seven", to the
Tuples, cannot be modified
26. Dictionaries
dic={' K1 ': "v1", "K2": "V2", "K3": [11,22,33]}
A. Please loop out all the keys:
dic={' K1 ': "v1", "K2": "V2", "K3": [11,22,33]}
For I in Dic.keys ():
Print (i)
B. Please loop out all the value
dic={' K1 ': "v1", "K2": "V2", "K3": [11,22,33]}
For I in Dic.values ():
Print (i)
C. Please loop out all the keys and value
dic={' K1 ': "v1", "K2": "V2", "K3": [11,22,33]}
For i,v in Dic.items ():
Print (I,V)
D. Add a key-value pair in the dictionary, "K4": "V4", and output the added dictionary
dic={' K1 ': "v1", "K2": "V2", "K3": [11,22,33]}
dic[' K4 ']= ' v4 '
Print (DIC)
E. In the modified dictionary, the value of "K1" corresponds to "Alex", Output the modified dictionary
dic={' K1 ': "v1", "K2": "V2", "K3": [11,22,33]}
dic[' K1 ']= ' Alex '
Print (DIC)
F. Please append an element 44 to the value of the K3, and output the modified dictionary
dic={' K1 ': "v1", "K2": "V2", "K3": [11,22,33]}
dic[' K3 '].append (44)
Print (DIC)
G. Insert element 18 in the 1th position of the K3 corresponding value, output the modified dictionary
dic={' K1 ': "v1", "K2": "V2", "K3": [11,22,33]}
dic[' K3 '].insert (0,18)
Print (DIC)
27. Conversion
A. Converting a string s= "Alex" to a list
S= "Alex"
Li=list (s)
Print (LI)
B. Convert the string s= "Alex" to Cheng Yuanju
S= "Alex"
Li=tuple (s)
Print (LI)
B. Convert the list li=["Alex", "seven"] to Narimoto Group
li=["Alex", "seven"]
Tu=tuple (LI)
Print (TU)
C. Convert the tu= (' Alex ', ' seven ') to a list
tu= (' Alex ', ' seven ')
Li=list (TU)
Print (LI)
D. Convert the list li=["Alex", "seven"] to a dictionary and the dictionary key is incremented backwards by 10
Old boy Python basic knowledge exercises (I.)