# Comparison and Reflection on the solutions to the silly questions of python

1. topic:

The bonus paid by the enterprise is based on the profit commission. If the profit (I) is less than or equal to 100000 yuan, the bonus can be increased by 10%.

If the profit is higher than RMB 100000 and lower than RMB 200000, the part lower than RMB 100000 will be charged at 10%, and the part higher than RMB 100000 will be charged at 7.5%.

When the price is between 200000 and 400000, the part higher than 200000 yuan can be charged 5%; when the price is between 400000 and 600000, the part higher than 400000 yuan can be charged 3%.

1.5% for the part higher than RMB 600000 when it is between RMB 600000 and RMB 1000000, and 1% for the part higher than RMB 1000000

Input the profit I of the current month from the keyboard to find the total amount of bonus to be paid?

``` 1 profit = int(input("Your profit:"))
2 if profit <= 100000:
3     bonus = profit*0.1
4 elif profit <= 200000:
5     bonus = 100000*0.1+(profit-100000)*0.075
6 elif profit <= 400000:
7     bonus = 100000*0.1+100000*0.075+(profit-200000)*0.05
8 elif profit <= 600000:
9     bonus = 100000*0.1+100000*0.075+200000*0.05+(profit-400000)*0.03
10 elif profit <= 1000000:
11     bonus = 100000*0.1+100000*0.075+200000*0.05+200000*0.03+(profit-600000)*0.015
12 elif profit >= 1000000:
13     bonus = 100000*0.1+100000*0.075+200000*0.05+200000*0.03+400000*0.015+(1000000-profit)*0.01

``` 1 i = int(input('Net profit:'))
2 arr = [1000000,600000,400000,200000,100000,0]
3 rat = [0.01,0.015,0.03,0.05,0.075,0.1]
4 r = 0
5 for idx in range(0,6):
6     if i>arr[idx]:
7         r+=(i-arr[idx])*rat[idx]
8         print (i-arr[idx])*rat[idx]
9         i=arr[idx]
10 print r```

Reflection: when element calculation occurs many times, don't use if else. You can use list and for loop traversal to solve it.

2. topic:

Enter three integers x,y,z. please output them from small to large.

```1 count1 = int(input("Enter the first number:"))
2 count2 = int(input("Enter the second number:"))
3 count3 = int(input("Enter the third number:"))
4 list = [count1,count2,count3]
5 list.sort()
6 print(list)```

```1 l = []
2 for i in range(3):
3     x = int(input('integer:\n'))
4     l.append(x)
5 l.sort()
6 print l```

Reflection: when users enter multiple items, they can use list and for loop to traverse.

3. topic:

Write function, check to get all the odd index elements of the incoming list or tuple object, and return them to the caller as a new list.

```1 def my_indexes(content):
2     '''Output parameter odd index value'''
3     new_list = []
4     for i in range(0,len(content)):
5         if i%2 == 1:
6             new_list.append(content[i])
7     return new_list
8 val = my_indexes([0,1,2,3,4,5,6,7])
9 print(val)```

```1 def my_indexes(content):