摘要:
类的组合用法 1 class Turtle: 2 def __init__(self, x): 3 self.num = x 4 5 6 class Fish: 7 def __init__(self, y): 8 self.num = y 9 10 11 class Pool: 12 def __ 阅读全文
摘要:
最大约数的计算 1 def cd(x): 2 """求一个正整数的除自身外的最大约数""" 3 count = x // 2 4 if not(x >= 3): 5 print('请代入一个大于2的正整数!') 6 else: 7 while count-1: 8 if x % count == 0 阅读全文
摘要:
检测城市、国家的输出情况,添加可灵活判断关键字参数的情况,city_func.py如下: 1 def city_country(city, country, population=0): 2 """返回一个形如'Santiago, Chile' 3 或者'Santiago, Chile -popul 阅读全文