Exercise 1:
# L1 = [11,22,33]
# L2 = [22,33,44]
# A. Get a list of elements of the same content
# B. Gets a list of elements in L1 that are not in the L2
# C. Gets a list of elements in L2 that are not in the L1
# d. Get elements with different contents in L1 and L2
# L1 = [11,22,33]# L2 = [22,33,44]# for i in L2:# If I not in L1:# Print (i)# for i in L1:#< /c18> If I not in L2:# Print (i)
View Code
Exercise 2:
12345678 are combined into a 2-digit number, two-bit values are not repeatable
# Count =0 # For I in range (1, 9): # For v in range (1, 9):# If I!=v:# count + = 1# # count = count-8# print (count)
View Code
Exercise 3:
99 Multiplication Table
# For i in range (1,10): # string = ""#for J in Range (1,i+1):# string +=str (j) + "*" +str (i ) + "=" +str (i*j) + "\ T"# Print (string)
Method 1
# For i in range (1,10): # For J in Range (1,i+1):# Print (str (j) + "*" +str (i) + "=" +str (i*j) + "\ T", end= "") # print ("\ n", end= "")# default end=\n# print (' Alex ', end= ' 11 ') # print (' Alex ', ' Haifeng ', ' Gangniang ', sep= ' one ')
Method 2
Exercise 4:
[1,2,3,4] This number two combinations how many kinds of not the same, the number is not repeated
# li = [1,2,3,4] # l =len (LI) # For i in range (0,L-1): # For v in Range (i+1,l):# print (li[i],li[v])
View Code
Exercise 5:
Automatic calculation scheme
Hundred Money to buy chickens
Rooster 5 Dollars 1 only, hen a three-piece money, Chicken a penny three. now I have bought 100 chickens with 100 cents,
Ask these 100 chickens, rooster, hen, chicken How many are each?
for in range (1,100//5): is in range (1,100//3): for in range (1,100): if and 5*x + 3*y + Z/3 = =: print
(x, Y, z)
View Code
Exercise 6:
Exercise 7:
Exercise 8:
Exercise 9:
Python Development Basics 04-list, tuple, dictionary operation exercise