import math
def test():
for i in range(1,100):
if i % 2 == 0:
countbeyond = math.pow(1.0+1/i+1)
else:
countfront = math.pow(1.0-1/i+1)
return countfront+countbeyond
import random
count = []
j = random.randint(1,6)
for n in range (1,100):
count.append(j)
if j == 1:
print("骰子1掷了{}次".format(count[j]))
if j == 2:
print("骰子2掷了{}次".format(count[j]))
if j == 3:
print("骰子3掷了{}次".format(count[j]))
if j == 4:
print("骰子4掷了{}次".format(count[j]))
if j == 5:
print("骰子5掷了{}次".format(count[j]))
if j == 6:
print("骰子6掷了{}次".format(count[j]))
import random
import math
ls = list(range(100))
shuffle(ls)
for i in range (1,9):
if i % 3 == 0:
print("\n")
print(ls)
ls = []
def func(a,b):
ls = []
ls.append(b)
return a+b
请问一下,这几个分别有哪些错误?
1.所有格式化都有问题;
2.math.pow 是两个参数
import math def test(): for i in range(1,100): if i % 2 == 0: countbeyond = math.pow(1.0+1/i+1,1) else: countfront = math.pow(1.0-1/i+11,3) return countfront+countbeyond print(test())
试题2:
1. count[j] 超过下标
试题3:
1. shuffle(ls) 未定义