程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

Python select structure Exercise

編輯:Python

1、 Input from keyboard 3 Number , For maximum

a = int(input(' Please enter the first number :'))
b = int(input(' Please enter the first number :'))
c = int(input(' Please enter the first number :'))
# The first one is 
if a > b:
a,b = b,a # The exchange value of two numbers 
if a > c:
a,b = b,c
if b > c:
b,c = c,b
print(' Maximum ',c)
# The second kind 
max = 0
if a > b:
max = a
if max > c:
print(max)
else:
print(c)
else:
max = b
if max > c:
print(max)
else:
print(c)

2、 Buy a lottery , If you win the lottery 500 ten thousand , I buy a car 、 Support project hope 、 Travel to Europe , Or I'll buy a sports lottery , Keep burning Gao Xiang . Write program description .

num = input(' Please enter an eight digit number :')
if num == '12345678':
print(' I won the prize , I buy a car 、 Support project hope 、 Travel to Europe ')
else:
print(' Keep burning Gao Xiang ')

3、 When members shop , Enjoy different discounts according to different points . Calculate the discount members get when shopping . Less than 2000 hit 9 fold ,2000-4000 hit 8 fold ,4000-8000 hit 7 fold , Greater than 8000 hit 6 fold

isVip = input(' Are you a member ?(y,Y)')
money = int(input(" Your shopping amount :"))
zk = 0
if isVip == 'y' or isVip == 'Y':
if money < 2000:
zk = 0.9
if money >= 2000 and money < 4000:
zk = 0.8
if money >= 4000 and money < 8000:
zk = 0.7
if money >= 8000:
zk = 0.6
else:
zk = 1
print(' The amount of payment is :',money * zk)

4、 Menu functions Welcome to xxx System 1 Sign in 2 register 3 sign out Please select :1 Sign in

print('{:*^20}'.format(' Welcome to the student management system '))
print('1. Sign in \t2. register \t3. sign out ')
a = int(input(' Please select :'))
count = input(' Please enter your account number :')
pwd = input(' Please input a password :')
if count == '123456' and pwd == '123':
print(' Login successful ')
else:
print(' Wrong account password ')

5、 The price of air tickets is subject to the peak season 、 The impact of the off-season , First class and economy class are also different . Suppose the original price of the ticket 5000 element , Please output the actual ticket price according to the travel month and the selected position .
peak season (4-10 month ) First class 10% off economy class 20 percent discount off season First class 50% off economy class 60% off The console output is as follows : Please enter your travel month :1-12 5 Please select first class (1) Or economy class (2)? 2
Your ticket price is :4000.0

month = int(input(' Please enter the month of your trip :'))
b = int(input(' Please enter first class (1) Or economy class (2):'))
price = 5000
zk = 0
if 4 <= month and month <= 10:
if b == 1:
zk = 0.9
else:
zk = 0.8
else:
if b == 1:
zk = 0.5
else:
zk = 0.4
print(f' Your ticket price :{price * zk}')

  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved