1. There are four numbers here , namely ：1,2,3,4, How many distinct three digit numbers can be formed without repeating numbers ? Please list them , And separated by spaces .

Thinking of problem solving ： Filter out the cases with the same number in three digits , And ignore them .
list1=[] count=0 for a in range(1,5): for b in range (1,5): for c in
range(1,5): if a!=b and b!=c and a!=c: d=100*a+10*b+c count+=1 list1.append(d)
print(' There are altogether %d Three digits ' % count) for i in list1: print(i,end=' ')

2. The bonus paid by the enterprise is based on the profit . profit (I) Below or equal to 10 Ten thousand yuan per hour , Bonus can be withdrawn 10%; Profit is higher than 10 Ten thousand yuan , lower than 20 Ten thousand yuan per hour , lower than 10 Part of RMB 10000 10% Commission , higher than 10 Ten thousand yuan , Cocoa Commission 7.5%;20 Wan to 40 Between ten thousand , lower than 20 Part of RMB 10000 7.5% Commission , higher than 20 Ten thousand yuan , Commission 5%;40 Wan to 60 Between ten thousand , lower than 40 Part of RMB 10000 5% Commission , higher than 40 Ten thousand yuan , Commission 3%;60 Wan to 100 Between ten thousand , lower than 60 Part of RMB 10000 3% Commission , higher than 60 Ten thousand yuan , Commission 1.5%, higher than 100 Ten thousand yuan per hour , lower than 100 Part of RMB 10000 1.5% Commission , exceed 100 Part of RMB 10000 1% Commission , Input current month profit from keyboard I, Total amount of bonus to be paid ?

Thinking of problem solving ： use if Statement to determine each condition interval .
lirun=int(input(' Please enter your profit :')) if lirun <= 100000: p=lirun*0.1 if lirun >100000
and lirun <=200000: p=10000*0.1+(lirun - 100000)*0.075 if lirun >200000 and
lirun <=400000: p=200000*0.075+(lirun - 200000)*0.05 if lirun >400000 and lirun
<=600000: p=400000*0.05+(lirun - 400000)*0.03 if lirun >600000 and lirun
<=1000000: p=600000*0.03+(lirun - 600000)*0.015 if lirun >1000000:
p=1000000*0.015+(lirun-1000000)*0.01 print(p)
3. An integer , It adds 100 And then it's a perfect square , Plus 168 It's another perfect square , When the number is less than 1000000 In the case of , What is the number ?

Thinking of problem solving ： If a square number is perfect , Then the root of the number is an integer .
import math for i in range(1,1000000): if
math.sqrt(i+100)==int(math.sqrt(i+100)) and
math.sqrt(i+268)==int(math.sqrt(i+268)): print(i)
4. Write a program , Find all that can be 7 Divide but not 5 The number of multiples of ,2000 to 3200 between （ All included ）. The numbers obtained should be printed on one line in comma separated order .

Solutions ： use if Statement as judgment , Pay attention to the output format .
list1=[] for i in range(2000,3201): if i%7==0 and i%5!=0: list1.append(i) for
i in list1: print(i, end=',')# Or use print(','.join(l)) , Used to use a string with S The symbols connect
5. Write a program , The factorial of a given number can be calculated . Suppose you provide the following input to the program ：8, The output should be ：40320

Thinking of problem solving ： Can define function and use recursion , Or use for loop .
a=int(input(' Please enter a number :')) b=1 for i in range(1,a+1): b=b*i print(b)
6. Use the given integer n, Write programs to generate include （i：i * i） This is 1 and n Integer between （ Including both ）.
Then the program should print the dictionary . Suppose you provide the following input to the program ：8, Output results ：{1: 1, 2: 4, 3: 9, 4: 16, 5: 25, 6: 36, 7: 49,
8: 64}

Thinking of problem solving ： Define a dictionary , use for loop .
n=int(input(' Please enter a number ：')) d=dict() for i in range(1,n+1): d[i]=i*i print(d)
7. Enter a string of numbers , Comma as separator , Convert it to list and tuple input ：34,67,55,33,12,98   output : ['34', '67', '55', '33',
'12', '98']   ('34', '67', '55', '33', '12', '98')

Thinking of problem solving ： Pay attention to the string separation method .
value=input(' Please enter a string of numbers :') a=value.split(',') print(a) b=tuple(a) print(b)
8. Define a class that contains at least two methods ：getString： Get string from console input printString： Print strings in uppercase .

Thinking of problem solving ： Pay attention to the format of the definition class .
class A(): def getString(self): self.x =input(' Please enter a string :') def
printString(self): print(self.x.upper()) a=A() a.getString() a.printString()
9. Write a program , The value is calculated and printed according to the given formula ：Q = [（2 * C * D）/
H] Below the square root of C and H Fixed value of ：C yes 50.H yes 30.D It's a variable , The values should be entered into the program in comma separated order . input ：100,150,180, output ：18,22,24

Thinking of problem solving ： Import math function , Pay attention to the input and output format .
import math c=50 h=30 d=input(' Please enter ：') list1=d.split(',') m=list1[-1] for i in
list1: i=int(i) q=int(math.sqrt((2*c*i)/h)) if i !=int(m): print(q,end=',')
else: print(q,end='')
10. Write a program ,X,Y As input , And generate a X That's ok ,N Two dimensional array of columns . Number of array i Line and section j The element value in the column should be i * j.

Thinking of problem solving ： Pay attention to the definition of two-dimensional array .
input_str = input() dimensions = [int(x) for x in input_str.split(',')] rowNum
= dimensions colNum = dimensions multilist = [[0 for col in
range(colNum)] for row in range(rowNum)]# Define an empty two-dimensional array for row in range(rowNum):
for col in range(colNum): multilist[row][col] = row * col print(multilist)

Technology
Daily Recommendation
views 1