摘要:
习题1 写函数,检查获取传入列表或者元组对象的所有奇数位索引对应的元素,并将其作为新列表返回给调用者. def check_elements(obj): if isinstance(obj, (tuple, list)): list1 = [] for index in range(1, len(o 阅读全文
摘要:
题目1:用while循环,输出1,2,3,4,5,6,8,9,10的数字! 实例1 # 方法一 i = 1 while i <= 10: if i != 7: print(i, end='-') i += 1 print() # 方法二 i = 1 while i <= 10: if i == 7: 阅读全文
摘要:
开始练习前要知道的是:比较运算符、逻辑运算符之间的优先级 结果是:比较运算符>not>and>or 一些小知识点: not False 结果为:True a and b 只要a,b中有一个值为False,结果为False 只有a,b同为True,结果才为True a or b 只要a,b中有一个值为 阅读全文