2--09 Calling Function Knowledge Points 5.15

Simulate 10086 rubbing query function
print('——————10086 query function——————\n')
print('input 1, check current balance\n''input
2, check current remaining flow\n'
'Enter 3 to query the current remaining calls\n''Enter
0 to exit the self-service query system!')
def query():
while True:
x = input("Please enter") # Get input content
if x == '1' :
print('Current balance is: 999 yuan')
elif x == '2':
print('Current remaining traffic is: 5G')
elif x == '3':
print('Current remaining call is: 189 minutes' )
elif x == '0':
print('Exit the self-service query system!')
break
else:
print("Please enter 1-3")
query()

Output the game character of "Glory of the King"

List of tank heroes

Tanks = ['Su Lie','Liu Bang','Zhong Kui','Zhang Fei','Niu Mo','Cheng Yaojin','Bai Qi','Liu Chan','Zhuang Zhou','Xiang Yu', 'Lianpo','Giant Spirit God','Anlu Mountain','Pig Bajie']

List of Warrior Heroes

warriors = ['Crazy Tie','Pei Lunhu','Armor','Sun Wukong','Nezha','Yang Jian','Orange Youjing','Arthur','Athena','Xiahou Dun', 'Guan Yu','Lu Bu','Han Xin','Old Master','Dharma','Dianwei','Cao Cao',
'Zhong Wuyan','Mozi','Zhao Yun','Xingtian', ' Long Qi']

List of assassin heroes

Assassins = ['Bai Li Xuan Ce','Pang Tong','Hua Mulan','Ake (Jing Ke)','Shiranui Dance','Li Bai','Na Ke Lulu','Lan Ling King', ' Luna','Han Xin','Miyamoto Musashi','Gai Nie','Hong Fu']

List of Mage Heroes

Masters = ['Yang Yuhuan','Yixing','Nuwa','Zhou Yu','Guiguzi','Miyue','Grant General Moxie','Emperor Taiyi','Da Qiao','Zhuge Liang' ,'Diao Chan','Zhang Liang','Angela','Shiranui Dance','Jiang Ziya','Wu Zetian',
'Wang Zhaojun','Zhen Ji','Bian Que','Gao Jianli','Ying Zheng','Da Ji','Little Joe']

List of shooter heroes

Shooters = ['Gongsunli','Baili keeps the promise','Houyi','Liu Bei','Huang Zhong','Marco Polo','Genghis Khan','Yuji','Li Yuanfang','Ilin' ,'Di Renjie','Luban No.7','Sun Shangxiang']

Support hero list

auxiliarys = ['Ming Shiyin','Mengqi','Sun Bin','Taiyi Real Person','Cai Wenji']

Output prompt text

def show(list):
for i in list:
print(i, end='')
print('"Glory of the King" game character:')
print('tank:’)
show(Tanks)
print(’\nwarrior:’)
show(warriors)
print(’\nassassin:’)
show(Assassins)
print(’\nMage:’)
show(Masters)
print(’\nShooter:’)
show(Shooters)
print(’\nAuxiliary:’)
show(auxiliarys)

Simulate the energy production process of Alipay Ant Forest
print('\nPlease enter the energy source to query the energy! Please enter 0\n' to exit the program)
print('The energy source is as follows:\n\
n''Life payment, walking donation, shared bicycle , Offline payment, online ticket purchase\n')
def query():
while True:
x = input("Please enter") # Get the content entered by the console
# Line feed
if x =='Life payment': # Judgment input The energy source
print('180g') # print the corresponding energy
elif x =='walking donation':
print('200g')
elif x =='shared bicycle':
print('80g')
elif x =='line Pay down':
print('5g')
elif x =='Internet ticket purchase':
print('80g')
elif x == '0':
print('Exited!')
break
query()

Calculate the calorie consumption value based on the number of steps
def query():
step = input('Please enter the number of steps you walked on that day!')
#Get the number of steps entered by the console
# Calculate calories, and the calorie consumption is different due to different walking speeds , The calculation result here is only for testing.
calorie = int(step) * 28 # Calculate 28 calories in one step
print('Today's total calories burned:', calorie, "(ie", calorie / 1000, "kcal)") # Print calories consumed
query()

Enter the operation page from the landing page
State transition diagram

Guess you like

Origin blog.csdn.net/With__Hope/article/details/90319786