1本文需要加载的模块是:random
2给出0到10之间的随机整数:import randoma = random.randint(0,10)print(a)
3给出9到10之间的随机实数:import randoma = random.uniform(9,10)print(a)
4从9、19、29、39、……、99之间,随机选取一个实数:import randoma = random.randrange(9, 100, 10)print(a)
5从列表[5,6,7,8,9]里面,随机选取一个数:import randoma = random.choice([5,6,7,8,9])print(a)
6从一个字符串里面,随机选取一个字符:import randoma = random.choice("从一个字符串里面,随机选取一个字符!")print(a)
7随机打乱列表里面的字符顺序:import randoma = ["p","q","r","s","t","p","q","r","s","t","p","q","r","s","t",]random.shuffle(a)print(a)
8从列表里面随机选取9个数字:import randoma = range(3,100,2)b = random.sample(a, 9)print(b)