-
输入三个整数x,y,z,请把这三个数由小到大输出。 1.程序分析:我们想办法把最小的数放到x上,先将x与y进行比较,如果x>y则将x与y的值进行交换, 然后再用x与z进行比较,如果x>z则将x与z的值进行交换,这样能使x最小。
- 企业发放的奖金根据利润提成。利润(I)低于或等于10万元时,奖金可提10%;利润高 于10万元,低于20万元时,低于10万元的部分按10%提成,高于10万元的部分,可可提 成7.5%;20万到40万之间时,高于20万元的部分,可提成5%;40万到60万之间时高于 40万元的部分,可提成3%;60万到100万之间时,高于60万元的部分,可提成1.5%,高于 100万元时,超过100万元的部分按1%提成,从键盘输入当月利润I,求应发放奖金总数?
1,比较大小
list1 = []
for i in range(3):
n = input('Please input number:')
list1.append(n)
list1.sort()
print list1
print '你输入的3个数从小到大排序为:%s,%s,%s' %(list1[0],list1[1],list1[2])
2,绩效
profit = input('Please input profix:')
if profit >=100:
reward = 10 0.075 + 20 0.03 + 60 0.001
elif profit >=60:
reward = 10 0.075 + 20 0.03 + (profit - 60) 0.1 + 10 0.05 + (profit - 40) 0.1 + 10 0.05
elif profit >=10:
reward = 10 0.075
else:
reward = profit * 0.1
print '你的奖金为%s' %(reward)
补充:
profit = input('Please input profix:')
with open('config','r') as f:
L1 = float((f.readline().strip()))
L2 = float((f.readline().strip()))
L3 = float((f.readline().strip()))
L4 = float((f.readline().strip()))
L5 = float((f.readline().strip()))
if profit >=100:
reward = 10 L2 + 20 L3 + 60 L5
elif profit >=60:
reward = 10 L2 + 20 L4 + (profit - 60) * L5
elif profit >=40:
reward = 10 L2 + 20 L4
elif profit >=20:
reward = 10 L2 + (profit - 20) * L3
elif profit >=10:
reward = 10 L2
else:
reward = profit * L1
print '你的奖金为%s' %(reward)
config:
0.1
0.075
0.05
0.03
0.015
0.001
2017-12-25 13:04 2 条评论 评分
回复 西红柿鸡蛋面 • 2017-12-26 10:00
第二题
思考:如果奖金的百分比,会经常变动,你的这段代码该怎么写维护起来更方便?
回复 jxcia • 2017-12-26 16:37
profit = input('Please input profix:')
with open('config','r') as f:
L1 = float((f.readline().strip()))
L2 = float((f.readline().strip()))
L3 = float((f.readline().strip()))
L4 = float((f.readline().strip()))
L5 = float((f.readline().strip()))
if profit >=100:
reward = 10 L1 + 10 L2 + 20 L3 + 40 L3 + 60 L4 + (profit - 100) L5
elif profit >=60:
reward = 10 L1 + 10 L2 + 20 L3 + 40 L4 + (profit - 60) * L5
elif profit >=40:
reward = 10 L1 + 10 L2 + 20 L3 + (profit - 40) L4
elif profit >=20:
reward = 10 L1 + 10 L2 + (profit - 20) * L3
elif profit >=10:
reward = 10 L1 + (profit - 10) L2
else:
reward = profit * L1
print '你的奖金为%s' %(reward)
评论一下...
0agh353272297
1、输入三个整数x,y,z,请把这三个数由小到大输出。
#!/usr/bin/env python
x = input("请输入数值x:")
y = input("请输入数值y:")
z = input("请输入数值z:")
tmp = 0
if x > y:
tmp = x
x = y
y = tmp
if x > z:
tmp = x
x = z
z = tmp
print("x = %d, y = %d, z = %d" % (x, y, z))
2、企业发放的奖金根据利润提成。
#!/usr/bin/env python
-- coding: utf-8 --
@Time : 2017-12-25 10:37
@Author : anChow
@File : test.py
i = input("请输入当月利润:")
if i >= 100000 and i <= 2000000:
if i >= 100000:
j = i * 0.1
else:
j = i * 0.75
elif i >= 2000000 and i <= 400000:
j = i * 0.5
elif i >= 400000 and i <= 600000:
j = i * 0.3
elif i > 600000 and i <= 1000000:
j = i * 1.5
elif i > 1000000:
j = i * 1
print("i = %d, j = %d" % (i, j))
2017-12-25 17:35 1 条评论 评分
回复 西红柿鸡蛋面 • 2017-12-25 20:44
第一题的,y和z没有做比较呀
第二题的每个阶段的提成数是不一样的
评论一下...
0灵度泪 - 卖痛风药的
#1.##############################
d = 0
x = int(input("第一个数字:"))
y = int(input("第二个数字:"))
z = int(input("第三个数字:"))
if x > y: # 做xy的比较;如果x>y,则x和y换值
x,y = y,x
if x > z: # 做xz的比较;如果x>z,则x和z换值
x,z = z,x
if y > z: # 做yz的比较;如果y>z,则y和z换值
y,z = z,y
print (x, y, z)
#2.#########################
s = float(input("请输入利润:"))
n = 0
if s <= 100000:
print (s*0.1)
if 100000 < s <= 200000:
n = s - 100000
print ("奖金总数是:",10000 + (n * 0.075))
if 200000 < s <= 400000:
n = s - 200000
print ("奖金总数是:",17500 + (n * 0.05))
if 400000 < s <= 600000:
n = s - 400000
print("奖金总数是:",27500 + (n * 0.03))
if 600000 < s <= 1000000:
n = s - 600000
print ("奖金总数是:",33500 + (n * 0.015))
if s > 1000000:
n = s - 1000000
print ("奖金总数是:",39500 + (n * 0.01))
2017-12-25 19:59 1 条评论 评分
回复 西红柿鸡蛋面 • 2017-12-26 09:49
第一题
思考:交换两个变量的值,写了3行代码,有没有更简洁的方式?
第二题
思考:如果奖金的百分比,会经常变动,你的这段代码该怎么写维护起来更方便?
评论一下...
0LINUX_A - 不要在最能吃苦的年龄选择安逸!
-- coding: utf-8 --
@Time : 2017/12/25 21:48
@Author : Zhdya
@Email : zhdya@zhdya.cn
@File : test_1225.py
@Software: PyCharm
x = int(raw_input("pls input a number: "))
y = int(raw_input("pls input a number: "))
z = int(raw_input("pls input a number: "))
aa = [x,y,z]
list(aa)
aa.sort()
print aa 第一种
aa = [x,y,z]
list(aa)
for i in range(len(aa)):
for j in range(i+1):
if aa < aa[j]:
# 实现连个变量的互换
aa,aa[j] = aa[j],aa
print aa 第二种
aa = [x,y,z]
list(aa)
if x > y:
temp = x
x = y
y = temp
if y > z:
temp = y
y = z
z = temp
if x > y:
temp = x
x = y
y = temp
elif y > z:
temp = z
z = y
y = temp
if x > y:
temp = x
x = y
y = temp
print x,y,z 第三种
2.-------------------------------------------------
企业发放的奖金根据利润提成。
利润(I)低于或等于10万元时,奖金可提10%;
利润高 于10万元,低于20万元时,低于10万元的部分按10%提成,高于10万元的部分,可可提 成7.5%;
20万到40万之间时,高于20万元的部分,可提成5%;
40万到60万之间时高于 40万元的部分,可提成3%;
60万到100万之间时,高于60万元的部分,可提成1.5%;
高于 100万元时,超过100万元的部分按1%提成;
从键盘输入当月利润I,求应发放奖金总数?
i = int(raw_input("pls input the profit: "))
if i <= 100000:
print "the bonus is: %s" % (i * 0.1)
elif i >= 10000 and i<= 200000:
print "the bonus is: %s" % (100000 * 0.1 + (i - 100000) * 0.075)
elif i >= 200000 and i<= 400000:
print "the bonus is: %s" % (100000 * 0.1 + 100000 * 0.075 + (i - 200000) * 0.05)
elif i >= 400000 and i<= 600000:
print "the bonus is: %s" % (100000 * 0.1 + 100000 * 0.075 + 200000 * 0.05 + (i - 400000) * 0.03)
elif i >= 600000 and i<= 1000000:
print "the bonus is: %s" % (100000 * 0.1 + 100000 * 0.075 + 200000 * 0.05 + 200000 * 0.015 + (i - 600000) * 0.015)
else :
print "the bonus is: %s" % (100000 * 0.1 + 100000 * 0.075 + 200000 * 0.05 + 200000 * 0.015 + 400000 *0.015 + (i - 1000000) * 0.01)
2017-12-25 23:32 1 条评论 评分
回复 西红柿鸡蛋面 • 2017-12-26 09:50
第一题写了这么多方式,非常棒
思考:交换两个变量的值,写了3行代码,有没有更简洁的方式?
第二题
思考:如果奖金的百分比,会经常变动,你的这段代码该怎么写维护起来更方便?
评论一下...
0ymk
-- coding: utf-8 --
Author :Gogh
@Time :2017/12/28 23:04
@Email :361910002@qq.comX5X
i = int(input('净利润:'))
arr = [1000000, 600000, 400000, 200000, 100000, 0]
rat = [0.01, 0.015, 0.03, 0.05, 0.075, 0.1]
r = 0
for idx in range(0, 6):
if i > arr[idx]:
r += (i - arr[idx]) * rat[idx]
i = arr[idx]
print('应发奖金为: %s元' % r)
转载于:https://blog.51cto.com/goldstar52/2136291