Python练习题
Amae
这个作者很懒,什么都没留下…
展开
-
Python:生成手机号码数
题目:编写一个函数,该函数接受10个整数(0到9之间)的数组,该函数以电话号码的形式返回这些数字的字符串。create_phone_number([1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) # => returns "(123) 456-7890"解答:方案一def create_phone_number(list): #your code here return f"({list[0]}{list[1]}{list[2]})"+" " + f.原创 2021-05-09 23:45:40 · 891 阅读 · 0 评论 -
Python练习题 :随机生成一批数
1、题目:指定生成一批数的个数,并可以指定数的范围"""1、随机整数生成器可以指定一批生成的个数、可以指定数值的范围、可以调整每批数字的个数"""import randomclass Random_integer: def __init__(self,count,integer_start= 1,integer_stop= 100): self.count = count self.integer_start = integer_start原创 2021-04-29 06:55:22 · 269 阅读 · 0 评论