The main topic of this lesson
- Python Operation Insider Principle
- String and Operation Combat
- Binary operation in combat
- List listing and Operation combat
- Tuple tuple and operational combat
- Dict Dictionary and Operation combat
- Set set and Operation combat
Python Operation Insider Principle
String and Operation Combat
Import copyfruits = [' Apple ', ' banana ', [7,3,5,2], ' straweberry ', ' orange ']copy_fruit = copy.copy (fruits) Deep_fruit = Copy.deepcopy (fruits) # Copyfruits2 = Fruits.copy () fruits[0] = "APPLE" # changed to a big write won't affect the original list fruits[2][1] = 4444444444444444FRUITS2[2][2] = "HAHA" # Python implicitly only COPY the first print ("Fruits list:", fruits) print ("Fruits2 list:", FRUITS2) p Rint ("Copy_fruit list:", copy_fruit) print ("Deep_fruit list:", Deep_fruit)
Binary operation in combat
List listing and Operation combat
List class:
- Write a list containing the names of all the members of the group
- Insert two members ' names into the middle of the position
- List of people who took out the 第3-8
- Delete the 7th person
- Delete the 2 2 people who were just joined at once
- Add the name of the group to the group. Note
# Write a list containing the names of all members of this group student = [' Janice ', ' Peter ', ' Mary ', ' Alex ', ' Jason ', ' Bonnie ', ' Coco ', ' Ben ', ' Matthew ', ' Roy ']# Insert the name of the two pro group member in the middle position student.insert (5, ' Tmp1_david ') Student.insert (6, ' tmp2_kenny ') new_student = student[2:8]# Remove the list of 第3-8 people student.remove ("Bonnie") # Delete 8th person del student[5:7]# put the 2 Pro 2 people just joined to delete the first time student[0] = ' Captain:janice ' # Add the name of the leader to the leader note New_student2 = student[::2]# Take one every other
Tuple tuple and operational combat
Dict Dictionary and Operation combat
Dict4 = {' Name ': ' Zara ', ' age ': 7}for K in Dict4: print (K,dict4[k]) # Name zara# age 7
Set set and Operation combat
Demand:
-After starting the program, let the user enter the payroll and then print the list of items
-Allows users to purchase items based on their product number
-After the user selects the product, checks whether the balance is enough, enough on the direct debit, not enough to remind
-Can exit at any time, when you exit, print purchased goods and balances
Requirements for business:
-The purchase process is an advantage, and you are allowed to choose how many items to buy,
-Allow multiple user to log in, continue to purchase after the next log on the last remaining
-Allow the user to view the previous purchase record (the recording is to display the product to buy time)
-a list of items to display, such as:
First menu:
-Home Electricity
-Clothes
-Hand Machine
-Car Category
Choose one and then enter the second menu:
-BMW X3 33333
-Audi Q5 333335
-Pasate 3333336
-Tesla Model_3 43890
-Tesla Model S 88888
-When a product is purchased, if there are repeated items, do not print more than one line, but on a line to show
ID p_name num Total_price
1 Teslamodels 2 4567897654
2 Coffee 2 60
3 Bike 1 700
Python Automation 2nd Lesson