输入三个整数x,y,z,请把这三个数由小到大输出。 1.程序分析:咱们想办法把最小的数放到x上,先将x与y进行比较,若是x>y则将x与y的值进行交换, 而后再用x与z进行比较,若是x>z则将x与z的值进行交换,这样能使x最小。python
1,比较大小app
list1 = []ide
for i in range(3):code
n = input('Please input number:') list1.append(n)
list1.sort()排序
print list1ip
print '你输入的3个数从小到大排序为:%s,%s,%s' %(list1[0],list1[1],list1[2])
2,绩效utf-8
profit = input('Please input profix:')ci
if profit >=100:input
reward = 10 0.075 + 20 0.03 + 60 0.001
elif profit >=60:it
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
一、输入三个整数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))
二、企业发放的奖金根据利润提成。
#!/usr/bin/env python
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 - 不要在最能吃苦的年龄选择安逸!
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 第三种
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
i = int(input('净利润:'))arr = [1000000, 600000, 400000, 200000, 100000, 0]rat = [0.01, 0.015, 0.03, 0.05, 0.075, 0.1]r = 0for idx in range(0, 6):if i > arr[idx]:r += (i - arr[idx]) * rat[idx]i = arr[idx]print('应发奖金为: %s元' % r)