# Python Basic Exercises

Here are some simple exercises I have written while learning Python. The answers to these exercises may not be completely correct for my own reference only!

### [Title 1]

Print a graphic like this

*****

***

*

***

*****

# for i in range(-2,3): # for z in range(3-abs(i)): # print(' ',end='') # for j in range(2*abs(i)+1): # print('*',end='') # print(' ')

### [Title 2]

Enter three integers and output them once from small to large and from large to small, respectively

# x=5 # y=1 # z=9 # m=[x,y,z] # m.sort(reverse=True)#reverse=Ture is to sort list s from large to small # print(m) # m.sort() # print(m)

### [Title 3]

Enter the day of the month and year to determine the day of the year

# x = int(input('Please enter year:')) # y = int(input('Please enter month:')) # z = int(input('please enter date:')) # sum=0 # mouth=[0,31,59,90,120,151,181,212,243,273,304,334] # if y>0 and y<=12: # sum=sum+mouth[y-1] # if z>0 and z<=31: # sum=sum+z # if x%4==0 and x%100!=0 or x%400==0: # sum=sum+1 # print(sum)

### [Title IV]

An integer, which is a complete square number after adding 100, and 168 is a complete square number. What is the number, please?

# import math # while b<=100000: # c=b+100 # d=int((math.sqrt(c))) # f=b+268 # e=int((math.sqrt(f))) # if c==d**2 and f==e**2: # print(b) # b+=1

### [Title 5]

The bonus awarded by the enterprise shall be based on profit.If the profit (I) is less than or equal to 100,000 yuan, the bonus may be increased by 10%; the profit is high When RMB 100,000 is less than RMB 200,000, the part less than RMB 100,000 will be deducted by 10%, and the part higher than RMB 100,000 will be deducted. 7.5%; between 200,000 and 400,000, 5% of the higher than 200,000 yuan can be deducted; between 400,000 and 600,000, it is higher than The part of 400,000 yuan may be credited 3%; between 600,000 and 1,000,000 yuan, the part above 600,000 yuan may be credited 1.5%, which is higher than When 1 million yuan is added, the part exceeding 1 million yuan is deducted by 1%. Enter profit I for the month from the keyboard and ask for the total bonus?

# bonus1 = 100000 * 0.1 # bonus2 = bonus1 + 100000 * 0.500075 # bonus4 = bonus2 + 200000 * 0.5 # bonus6 = bonus4 + 200000 * 0.3 # bonus10 = bonus6 + 400000 * 0.15 # # i = int(input('input gain:\n')) # if i <= 100000: # bonus = i * 0.1 # elif i <= 200000: # bonus = bonus1 + (i - 100000) * 0.075 # elif i <= 400000: # bonus = bonus2 + (i - 200000) * 0.05 # elif i <= 600000: # bonus = bonus4 + (i - 400000) * 0.03 # elif i <= 1000000: # bonus = bonus6 + (i - 600000) * 0.015 # else: # bonus = bonus10 + (i - 1000000) * 0.01 # print ('bonus = ',bonus)