赞
踩
def sum_num(x, y):
sumN = 0
for i in range(x,y+1):
sumN += i
return sumN
print(sum_num(1, 3)) >>>>>>>>>>>6
def nop(x):
pass
def sum_num(x, y):
if not isinstance((x, y), (int, float)):
raise TypeError('参数错误')
sumN = 0
for i in range(x,y+1):
sumN += i
return sumN
print(sum_num(9, '78')) >>>>>>>>>>>TypeError: 参数错误
import math
def move(x, y, step, angle=0):
nx = x + step * math.cos(angle)
ny = y + step * math.sin(angle)
return nx, ny
t = move(0, 0, math.pi/4, 1.414)
print(t) >>>>>>>>>>>(4.122643568127262, 7.775763385488835)
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。