Day 40 learning python built-in module random BASEDIR

# Module comes random:. Scenario module random codes 
# Import Random
# random.random RET = () # 0-1 to the floating
# ret = random.randint (1,6) # than 1 and a random an integer less than or equal 6
# RET = random.randrange (1,10)
# the random.choice RET = ([11,22,33]) displays a random number #
# ret = random.uniform (0,9) # a random decimal greater than 0 and less than 9
# Print (RET)
#

# example: codes, alphanumeric combinations
# ideas: generating a random code 6: letters + numbers. Lowercase letters is a digital 65
Import Random
DEF code ():
RET = "" # null characters defined
for i in range (5): # generates random numbers
NUM = the random.randint (0,9)
ALF = CHR (Random .randint (65,122)) # generates random letters a through Z, this is problematic because there are other characters in between 65 to 122, in addition to the letter
S = STR (the random.choice ([NUM, ALF]))
RET = S +
return RET
Print (code ())

Guess you like

Origin www.cnblogs.com/jianchixuexu/p/11620340.html