python 打印函数图像
效果图
代码,运行环境windows
import os; os.system("chcp 65001 & cls")
import math
import random
def plot(f):
print("="*89)
print("现在打印的是", f, "的函数图象")
w = int(40 / 2)
arrPos = [[x, round(f(x))] for x in range(-w, w+1)]
rangelist = [x[1] for x in arrPos]
for y in range(max(rangelist), min(rangelist)-1,-1):
print("".join([(
([x, y] in arrPos and y == 0 and "-*") or
[x, y] in arrPos and " *" or
x == 0 and y == 0 and "-|" or
x == 0 and " |" or
y == 0 and "--" or
" "
) for x in range(-w,w)]))
plot(lambda x:
((15**2) - x ** 2 >= 0) and math.sqrt((15**2) - x ** 2) * random.choice([1,-1])
)
input()
شركة مكافحة النمل الابيض بالاحساء
回复删除شركة مكافحة حشرات بالقصيم
شركة مكافحة النمل الابيض بالدمام