Python Automation 2nd Lesson

Source: Internet
Author: User
Tags set set

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.