Python comprehensive English II

Python comprehensive English II

1. Exercise 1

Title: seeking s = a + aa + aaa + aaaa + aa ... the value of a, where a is a number

a=input('请输入数字:')
count=int(input('几个数字相加:'))
ret=[]
for i in range(1,count+1):
    ret.append(int(a*i))
    print(ret[i-1])
print(sum(ret))

Output:
Here Insert Picture Description

2. English II

Title: determining the number of prime numbers between 101-200 and the outputs of all primes

l=[ ]
for i in range(101,200):
    for j in range(2,i-1):
        if i % j==0:
            break
    else:
        l.append(i)
print(l)
print('总数为:%d'%len(l))

Output:
Here Insert Picture Description

3. Practice three

Topic: Enterprise commission bonuses based on profits. When profit (I) is less than or equal to 10 million, 10% of the prize can be mentioned;
when profit than 10 million, less than 20 million, 10 million commission portion is less than 10%, higher than 100,000 yuan portion, may be 7.5% commission;
is between 200,000 to 400,000, more than 20 million portion, may be 5% commission;
when more than 40 million portion between 400,000 to 600,000, may be 3% commission ;
is between 600,000 to 1,000,000, more than 60 million portion may commission 1.5%;
above 100 million, more than one million yuan portion 1% commission;
keyboard input month profit I, should seek The total number of paid bonuses?

I = float(input("请输入当月利润,单位为万元:"))
if I <= 10:
    bns = I * 0.1
elif 10 < I <= 20:
    bns = 10 * 0.1 + (I-10) * 0.075
elif 20 < I <= 40:
    bns = 10 * 0.1 + 10 * 0.075 + (I-20) * 0.05
elif 40 < I <= 60:
    bns = 10 * 0.1+ 10 * 0.075 + 20 * 0.05 + (I-40) * 0.03
elif 60 < I <= 100:
    bns = 10 * 0.1+ 10 * 0.075 + 20 * 0.05 + 20 * 0.03 + (I-60) * 0.015
elif I > 100:
    bns = 10 * 0.1 + 10 * 0.075 + 20 * 0.05 + 20 * 0.03 + 40 * 0.015 + (I-100) * 0.015
print(bns,'万元')

Output:
Here Insert Picture DescriptionHere Insert Picture Description

Published 60 original articles · won praise 6 · views 1367

Guess you like

Origin blog.csdn.net/weixin_45775963/article/details/103636736