Actually don't have to write some basic things, these things can be referred to
Http://www.runoob.com/python3/python3-tutorial.html
This web site to learn
Here I'll share a piece of code for you,
One, demand
1. Establish a management system, ' fruit management '
2. Can query, add, change price, delete, exit.
3. Follow your number to proceed accordingly.
Here's my Code.
Two, the code
# coding = Utf-8
name = ' Fruit Management '
1. Check Fruit
2. Add fruit
3. Price change
4. Delete fruit
0. Exit Please select the operation: "
Sys_sg = {} # all Fruits
While TRUE:SYS_SR = input (name)
if Sys_sr = = ' 0 ':
Break # Exit Loop
Elif sys_sr not in [' 1 ', ' 2 ', ' 3 ', ' 4 ', ' 0 ']:
Print (' {0} selected operation does not exist '. Format (SYS_SR))
elif Sys_sr = = ' 2 ':
Sys_xx = input (' Please enter fruit information (id,name,cnt,price,sale_top): \ n ')
Sys_xx = Sys_xx.split (', ')
If Len (sys_xx)! = 5:
Print (' Input information is incomplete, please try again! ‘)
Continue
Sys_zd = {' name ': sys_xx[1], ' cnt ': Int (sys_xx[2]), ' Price ': float (sys_xx[3]), ' Sale_top ': float (sys_xx[4])}
Sys_sg[sys_xx[0]] = Sys_zd
Print (' Add success! ')
Elif Sys_sr in [' 1 ', ' 3 ', ' 4 ']:
sys_id = input (' Enter fruit number: ')
Sys_zd = Sys_sg.get (sys_id)
If Sys_zd is None:
Print (' {0} does not have this effect '. Format (sys_id))
elif Sys_sr = = ' 1 ':
Print (SYS_ZD)
elif Sys_sr = = ' 3 ':
Sys_price = input (' Please enter the latest price of fruit: ')
sys_zd[' price ' = float (sys_price) # change the latest prices
Print (' Price changed successfully! ')
elif Sys_sr = = ' 4 ':
Sys_sg.pop (sys_id)
Print (' Delete succeeded! ')
Print (' Exiting program ... ')
Three, explain
English proficiency is limited, probably can only be written in this way, if you can optimize, please the big guy can express their views.
Python self-study log-Basic (2)