while练习

  1. 题目:企业发放的奖金根据利润提成。利润(I)低于或等于10万元时,奖金可提10%;利润高于10万元,低于20万元时,低于10万元的部分按10%提成,高于10万元的部分,可提成7.5%;20万到40万之间时,高于20万元的部分,可提成5%;高于40万元的部分,可提成3%。从键盘输入当月利润,求应发放奖金总数?
  2. 快递运费首重6元,超过则加收3元/kg(首重为1kg,不满则按1kg计算),要求输入货物重量,计算运费
  3. 输入税前工资数,计算出应交的个人所得税(不考虑税费减免政策)
  4. 一个球从100米高度自由落下,每次落地后弹回原来高度的一半,求它在第10次落地时,离地多高,共经过多少米?
  5. 有一个分数数列,1/2,2/3,4/4,8/5,16/6...,求前10项的和
  6. 猴子吃桃问题:猴子第一天摘下若干个桃子,当即吃了一半,第二天早上又将剩下的桃子吃掉一半。以后每天早上都吃前一天剩下的一半。到第10天早上想再吃时,见只剩下一个桃子了。求第一天共摘多少个桃子
#第一题分析:
#1.定义变量I存储利润数据
I = int(input("请输入当月利润:"))
if I <= 100000:
    print("应发奖金:",I * 0.1)
elif 100000 < I <= 200000:
    print("应发奖金:",100000 * 0.1 + (I - 100000) * 0.075)
elif 200000 <= I <=400000:
    print("应发奖金:",100000 * 0.1 + 100000 * 0.075 + (I - 200000) * 0.05)
else:
    print("应发奖金:", 100000 * 0.1 + 100000 * 0.075 + 200000 * 0.05 + (I - 400000) * 0.03)
 
#第二题分析:
#1.定义货物重量:变量
weight = float(input("请输入重量:"))
#2.判断运费计算方式
if weight <= 1:
    freight = 6
    print(freight)
else:
    freight = 6 + (weight - 1) * 3
    print(freight)
 
#第三题分析:
#1.定义税前工资:
salary = int(input("请输入工资:"))
#2.应纳税的工资=税前工资-5000-五险一金:
#五险一金:
Five_one_gold = salary * 0.22
#应纳税工资:
should_tax_salary = salary - 5000 - Five_one_gold
#判断个人所得税计算方式:
if salary > 5000:
    if should_tax_salary <= 3000:
        Personal_income_taxes = should_tax_salary * 0.03 - 0
        print("个人所得税:{}元".format(Personal_income_taxes))
    elif 3000 < should_tax_salary <= 12000:
        Personal_income_taxes = should_tax_salary * 0.1 - 210
        print("个人所得税:{}元".format(Personal_income_taxes))
    elif 12000 < should_tax_salary <= 25000:
        Personal_income_taxes = should_tax_salary * 0.2 - 1410
        print("个人所得税:{}元".format(Personal_income_taxes))
    elif 25000 < should_tax_salary <= 35000:
        Personal_income_taxes = should_tax_salary * 0.25 - 2660
        print("个人所得税:{}元".format(Personal_income_taxes))
    elif 35000 < should_tax_salary <= 55000:
        Personal_income_taxes = should_tax_salary * 0.3 - 4410
        print("个人所得税:{}元".format(Personal_income_taxes))
    elif 55000 < should_tax_salary <= 80000:
        Personal_income_taxes = should_tax_salary * 0.35 - 7160
        print("个人所得税:{}元".format(Personal_income_taxes))
    elif should_tax_salary > 80000:
        Personal_income_taxes = should_tax_salary * 0.45 - 15160
        print("个人所得税:{}元".format(Personal_income_taxes))
else:
    Personal_income_taxes = 0
    print("个人所得税:{}元".format(Personal_income_taxes))
 
#第四题分析:
#1.每次落地回弹一半,第一次落地后每次回弹2次
count = 1
height = 100
sum = 0
while count <= 10:
    if count == 1 or count == 10:
        sum += height
    else:
        sum += height * 2
 
    height = height / 2
 
 
    count += 1
print(height)
print(sum)
 
#第五题分析:
#1.找出分数数列的规律:
i = 1
sum = 0
a = 1#分子
b = 2#分母
while i <= 10:
    sum = sum + a / b
    a = a * 2
    b = b + 1
 
    i += 1
print(sum)
 
#第六题分析:
i = 9
a = 1
while i > 0:
    a = 2 * a
    i -= 1
print(a)
posted @ 2019-09-11 15:22  B站-水论文的程序猿  阅读(276)  评论(0编辑  收藏  举报