A.计算1!+2!+...+n!,!表示阶乘
B.计算1!+2!+...+(n+1)!,!表示阶乘
C.计算n!,!表示阶乘
D.计算(n+1)!,!表示阶乘
第1题
A、lst2.append(s1.pop()) [9, 7, 5, 3, 1]
B、lst2.append(s1.pop()) [1, 3, 5, 7, 9]
C、while not s1.isEmpty(): s2.push(s1.pop()) lst2.append(s2.pop()) while not s2.isEmpty(): s1.push(s2.pop())[1, 3, 5, 7, 9]
D、while not s1.isEmpty(): s2.push(s1.pop()) lst2.append(s2.pop()) while not s2.isEmpty(): s1.push(s2.pop()) [9, 7, 5, 3, 1]
E、lst2.append(s1.peek())死循环,无法运行
F、lst2.append(s1.peek())[9, 9, 9, 9, 9]
G、for i in range(s1.pop()): s2.push(i) lst2.append(s2.size()) [9, 16, 21, 24, 25]
H、for i in range(s1.pop()): s2.push(i) lst2.append(s2.size())[1, 4, 9, 16, 25]
第3题
A、a!=b and b!=c and c!=a f(4)
B、a!=b and b!=c and c!=a f(3)
C、a!=b and b!=c f(4)
D、a!=b and b!=c f(3)
第4题
A、compute([3, 3])
B、nums = [1, 2, 3]; compute(nums)
C、compute([3, 2, 1])
D、nums = (3, 3); compute(*nums)
第5题
A、求 0 到 n 的偶数和
B、将 n 转换为二进制数
C、求 0 到 n 的奇数和
D、将 n 转换为二进制数,然后再求逆序
第7题
已知列表fruits中顺序保存了某商店每日出售的水果品名,例如fruits = ['apple', 'banana', 'cherry','banana', 'peach', 'pear','peach', 'cherry' ],定义函数count计算每一种水果的出售次数,存入字典result中并将结果返回,针对本题数据,result的结果为:{'pear': 1, 'banana': 2, 'cherry': 2, 'peach': 2, 'apple': 1}。 我们可以用一般程序设计的方法去解决这个问题,例如: d = {} fruits_set = set(fruits) for item in fruits_set: d[item] = 0 for i in range(len(fruits)): if item == fruits[i]: d[item] += 1但是我们更希望大家用Python中特有的方法去解决问题,例如此问题可以改成: for item in fruits: B[item] =0 for item in fruits: B[item] += 1也可以利用Python中丰富的函数去解决这个问题,请在空白处填写相应的函数。 d = {} for item in fruits: d[item] = fruits._________(item)
为了保护您的账号安全,请在“上学吧”公众号进行验证,点击“官网服务”-“账号验证”后输入验证码“”完成验证,验证成功后方可继续查看答案!