subject : There are four numbers :1,2,3,4, How many three digits that are different from each other and have no duplicate numbers can be formed ? How much is each ? for i in range(1, 5): for j in
range(1, 5): for k in range(1, 5): if(i != k) and (i != j) and (j != k):
print(i, j, k)
analysis : Because it's three digits , I.e. single bit , Ten , Hundredth . So we can use three cycles , Judge whether the numbers are the same at the innermost layer .
subject : Enter a year, month and day , Judge which day of the year this day is ? year = int(input('year:\n')) month =
int(input('month:\n')) day = int(input('day:\n')) months = (0, 31, 59, 90, 120,
151, 181, 212, 243, 273, 304, 334) if 0 < month <= 12: sum = months[month - 1]
else: print('data error') sum += day leap = 0 if (year % 400 == 0) or ((year %
4 == 0) and (year % 100 != 0)): leap = 1 if (leap == 1) and (month > 2): sum +=
1 print('it is the %dth day.' % sum)
analysis : First enter the month, year and day , You need to pay attention here ,month The whole needs to be pushed forward . The last two if Statement to determine whether it is a leap year and whether it is after February , If it is , The number of days needs to be increased by one day . 

subject : Enter three integers x,y,z, Please output these three numbers from small to large .
l = [] for i in range(3): x = int(input('integer:')) l.append(x) l.sort()
print(l)
analysis : For this kind of number sorting problem , You can put it in the list , utilize python of sort() Function to sort in ascending order , utilize python of reverse() Sort in descending order .

be careful :sort() and sorted() Differences between ,sort() The function sorts the list in place , Changed the original sequence , And no value is returned , and sorted() The function does not change the original sequence ,
Returns a sorted list , See the following code for details .
a = [2, 4, 6, 4, 3, 5] a.sort() print(a) # [2, 3, 4, 4, 5, 6] b = a.sort()
print(b) # None c = sorted(a) print(c) # [2, 3, 4, 4, 5, 6] subject : output 9*9 Multiplication formula table .
for i in range(1, 10): print() for j in range(1, i + 1): print("%d*%d=%d" % (i,
j, i * j), end=" ")
analysis :

① first print() without , The final output results are all displayed in one line .

② stay python in %d Content belonging to string formatted output , It represents an integer . 

③print() In function end The default parameter is \n, Line feed . Without this , The display results are as follows , That is, the multiplication formula is printed every time , Just change lines .

Change it to a space , We can get the result format we want . 
subject : Pause output for one second , And format the current time . import time print(time.strftime('%Y-%m-%d %H:%M:%S',
time.localtime(time.time()))) # Pause for one second time.sleep(1)
print(time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time()))) #
2022-05-01 12:06:56 # 2022-05-01 12:06:57
analysis :time.strftime(format[,t]) Can convert localtime() Time to return by format The string specified by the parameter .

%Y Represents a four digit year ,%y Indicates a two digit year ;%m Represents the month ;%d Indicates the day of the month ;%H express 24 Hours in hour system ,%I express 12 Hours in hour system ;%M
Represents the number of minutes ;%S Second representation .
subject : Enter a line of characters , Count the English letters respectively , Space , Number of numbers and other characters . s = input(' Please enter a string :\n') letters = 0
space = 0 digit = 0 others = 0 for c in s: if c.isalpha(): letters += 1 elif
c.isspace(): space += 1 elif c.isdigit(): digit += 1 else: others += 1 print
('char = %d,space = %d,digit = %d,others = %d' % (letters, space, digit,
others))
analysis : It mainly uses the existing functions to judge whether it is an English letter , Space , number .
subject : seek 1+2!+3!+...+20! And . n = 0 s = 0 t = 1 for n in range(1, 21): t *= n s += t
print('1! + 2! + 3! + ... + 20! = %d' % s)
analysis : The above code can be used to find the sum of factorials , Easy to understand .
subject : One 5 digit , Determine whether it is a palindrome number . Namely 12321 Is the palindrome number , One bit is the same as ten thousand bit , Ten is the same as thousands . a = int(input(" Please enter a number :\n")) x
= str(a) flag = True for i in range(len(x) // 2): if x[i] != x[-i - 1]: flag =
False break if flag: print("%d Is a palindrome number !" % a) else: print("%d Not a palindrome number !" % a)
The above is a general method to judge whether the number of odd numbers is palindrome number . 

Technology
©2019-2020 Toolsou All rights reserved,
C++ of string of compare usage MySQL Basics Commonly used sentence ( Add / delete / modify query )C Language of a Gobang game implementation QT5.9 Use of learning notes QSqlQuery Method of Qt Getting Started tutorial 【 Basic controls 】QCalendarWidget calendar control java Polymorphic array of web Front end signature plug-in _signature_pad Plug in implements electronic signature function centos7 install RabbitMqspringboot use redis Experiment 4 Automated test tools - software test