最新回答 / x慕杨人1437
若程序中有汉字必须要有编码:#coding=utf-8。,慕课版本的编译器比较旧了,在# Enter a code下面再加一个#coding=utf-8。试过了没有问题
2021-12-30
最新回答 / 高飞的鱼
是的,我的结果也是不同的。python3.9输出结果不太一样,估计更新了某些功能。Python 3.9.7 (v3.9.7:1016ef3790, Aug 30 2021, 16:39:15) [Clang 6.0 (clang-600.0.57)] on darwinType "help", "copyright", "credits" or "license()" for more information.>>> s = set(['Alice', 'Bob', 'Candy', '...
2021-12-23
L = [[1,2,3],[5,3,2],[7,3,2]]
i = 0
j = 0
S = [0,0,0]
while i <= 2:
S[i]=2*(L[i][j]*L[i][j+1]+L[i][j]*L[i][j+2]+L[i][j+1]*L[i][j+2])
i = i + 1
print(S)
i = 0
j = 0
S = [0,0,0]
while i <= 2:
S[i]=2*(L[i][j]*L[i][j+1]+L[i][j]*L[i][j+2]+L[i][j+1]*L[i][j+2])
i = i + 1
print(S)
2021-12-18
L = [75, 92, 59, 68, 99]
sum = 0
for ch in L:
sum += ch
print(sum)
sum = 0
for ch in L:
sum += ch
print(sum)
2021-12-17
# coding: utf-8
score = 18
if score < 18:
if score >= 6:
print("青年")
else:
if score >= 3:
print("小孩子")
elif score == 18:
print("成年")
else:
print("大人")
score = 18
if score < 18:
if score >= 6:
print("青年")
else:
if score >= 3:
print("小孩子")
elif score == 18:
print("成年")
else:
print("大人")
2021-12-17
已采纳回答 / 慕后端5596440
题目要求计算0~1000以内的和num从零开始作为每次要加的数字,每次遍历加1,即0,1,2,3,...,1000sum从零开始作为最终累加的和,在当前遍历基础上加上一次的num数值反向去解释能看明白的话,多练练,下次遇到就知道解题需要什么变量了
2021-12-16
最新回答 / 沐风eqwe
python 是不用定义变量的,因为python是动态语言。你只要先告诉程序说有sum 和 num 这个东西。后期给sum 和num里面装数字,装字符串都可以。
2021-12-16