1. How to generate random numbers in Python
1> Generating Random decimals
Random.random () is a random decimal between 0-1, excluding 1
Random.uniform parameters can also be specified in the range, such as 1-2, excluding 2
2> generating random integers
Random.randint ()
Random.randrange ()
3> randomly takes an element in a sequence
Random.choice ()
4> randomly takes several elements in a sequence, which need to be determined by the parameters
Random.sample ()
5>.random.shuffle (a) #把一个序列打乱
2. Reverse string output
1> using slices
2> can also be operated as follows
3> can also be implemented using functions
3, judge whether a string is a palindrome string
A palindrome string is the same from the post-reading and backward-reading: EG:ABCDCBA
4, randomly generate 100 numbers, and then write to the file
Analysis:1> Open a new file, ready to write
2> randomly generates a number (integer or decimal) and writes that number to the file
3> cycle 2nd, until 100 random number generation is completed
5, given dict={' a ': 3, ' B ': 5, ' C ': 2, ' d ': 9, ' E ': 6}, sorted by its key value
Sorting nested lists can be done in this way
6, to a=[1,3,2,2,1,5,5,3] inside the elements go heavy, there are several ways, and write out
Python face question