python回歸之旅-用python學(xué)習(xí)數(shù)學(xué)---2023-002
首先使用win10下的anaconda,運行沒有問題。
import math
def f(x):
? ? return math.sqrt(x+3)-x+1
def g(x):
? ? return x*x-1
def h(x):
? ? return x*x+1/x+2
for x in [0.5,1,math.sqrt(2),math.sqrt(2)-1]:? ??
? ? print("f({:.3f})={:,.3f}".format(x,f(x)))
? ? print("g({:.3f})={:,.3f}".format(x,g(x)))
? ? print("h({:.3f})={:,.3f}".format(x,h(x)))
--------------------------------------------------------
貌似只是使用了math模塊,已經(jīng)有了。(所以問題不大)
import math
import matplotlib.pyplot as plt
from turtle import *?
forward(100)
shape('turtle')
-------------------------------------------------------
matplotlib 和 turtle模塊已經(jīng)安裝成功,沒有問題。
import math
import matplotlib.pyplot as plt
from turtle import *
??
shape('turtle')
def square():
? ? for i in range(4):
? ? ? ? forward(100)
? ? ? ? right(90)
? ? ? ??
? ? ? ??
def draw(x):
? ? for i in range(x):
? ? ? ? square()
? ? ? ? right(5)
draw(60)

函數(shù)調(diào)用,turtle簡單畫畫沒有問題。