五月天青色头像情侣网名,国产亚洲av片在线观看18女人,黑人巨茎大战俄罗斯美女,扒下她的小内裤打屁股

歡迎光臨散文網(wǎng) 會員登陸 & 注冊

fx_2.0 python一/二次函數(shù)繪圖

2022-08-27 16:49 作者:ICE27182  | 我要投稿

在學python

畫圖好難


#2.0 !!!

#介紹

print('\n\n\n\nfx_2.0可以繪制二次函數(shù)圖像和一次函數(shù)圖像',end='')

print('''

2.0更新內容:

1 圖像由1.0版本旋轉90°與通常的坐標軸方向一致

2 改善了縮放機制 相對河里

3 改進輸入 可以防止輸入錯誤值如字符導致的異常

4 增加說明、注釋

5 解決了換行問題 而且圖像可以很大了

''',end='')


#輸入

def fxin(n):

? ? str(n)

? ? while True:

? ? ? ? try :

? ? ? ? ? ? a = float(input('%s=' % n))

? ? ? ? ? ? break

? ? ? ? except ValueError:

? ? ? ? ? ? print('請輸入數(shù)字')

? ? ? ?

? ? return(a)


while True:

? ? a,b,c,x_min,x_max,scale = fxin('a'),fxin('b'),fxin('c'),fxin('x min'),fxin('x max'),fxin('圖像縮放')


? ? #輸入內容

? ? print('\nf(x)=',end='')


? ? if a == 1:

? ? ? ? ? ? print('x2',end='')

? ? elif a == -1:

? ? ? ? ? ? print('-x2',end='')

? ? elif a != 0:

? ? ? ? ? ? print('%fx2' % a,end='')


? ? if b == 1 and a == 0:

? ? ? ? ? ? print('x',end='')

? ? elif b == 1 and a != 0:

? ? ? ? ? ? print('+x',end='')

? ? elif b == -1:

? ? ? ? ? ? print('-x',end='')

? ? elif b != 0:

? ? ? ? ? ? if b > 0 and a != 0:

? ? ? ? ? ? ? ? print('+%fx' % b,end='')

? ? ? ? ? ? if b > 0 and a == 0:

? ? ? ? ? ? ? ? print('%fx' % b,end='')

? ? ? ? ? ? if b <= 0:

? ? ? ? ? ? ? ? print('%fx' % b,end='')


? ? if a == 0 and b == 0:

? ? ? ? ? ? print(c)

? ? elif a != 0 or b != 0:

? ? ? ? ? ? if c > 0:

? ? ? ? ? ? ? ? print('+%f' % c)

? ? ? ? ? ? if c < 0:

? ? ? ? ? ? ? ? print(c)

? ? ? ? ? ? if c == 0:

? ? ? ? ? ? ? ? print('')


? ? #確認

? ? while True:

? ? ? ? yrq = input('輸入y確認\n輸入r重新輸入\n輸入q退出\n')

? ? ? ? if yrq == 'y' or yrq == 'r':

? ? ? ? ? ? break

? ? ? ? elif yrq == 'q':

? ? ? ? ? ? exit()

? ? ? ? else:

? ? ? ? ? ? print('\n僅限輸入 y 或 r 或 q')

? ? if yrq == 'y':

? ? ? ? ?del yrq

? ? ? ? ?break ?


#計算函數(shù)值

def f_x(x_min,x_max,a,b,c,scale):

? ? '''計算函數(shù)值 列表A=B A排序B也會跟著 沒辦法 就干脆定義一個函數(shù)罷:('''

? ? fx = []

? ? while x_min <= x_max :

? ? ? ? fx.append(int(round((a*x_min**2+b*x_min+c)*scale,0)))

? ? ? ? x_min+=(1/scale)

? ? return fx


fx = f_x(x_min,x_max,a,b,c,scale) ?#我愛咋咋

fx_sequence = set(f_x(x_min,x_max,a,b,c,scale))

fx_sequence = list(fx_sequence)

fx_sequence.sort(reverse=True)


#繪圖

for e_fxs in fx_sequence:

? ? count = fx.count(e_fxs)

? ? count2,plen,pplen = 0,0,0

? ? while count2 < count:

? ? ? ? #print(pplen,' ? ',len(fx)-1,' ? ',fx)

? ? ? ? plen = fx.index(e_fxs,pplen,len(fx))

? ? ? ? indicator = fx[plen]

? ? ? ? print(' '*(plen-pplen), end='')

? ? ? ? print('*', end='')

? ? ? ? pplen = plen+1

? ? ? ? count2+=1

? ? if fx_sequence.index(e_fxs) < (len(fx_sequence)-1):

? ? ? ? print('\n'* (e_fxs - fx_sequence[fx_sequence.index(e_fxs)+1]),end="")


fx_2.0 python一/二次函數(shù)繪圖的評論 (共 條)

分享到微博請遵守國家法律
二连浩特市| 哈密市| 静海县| 铜鼓县| 故城县| 河北省| 宁远县| 隆林| 岳普湖县| 周至县| 定结县| 英德市| 永新县| 湖南省| 崇义县| 鹤壁市| 安远县| 上高县| 文昌市| 望奎县| 宝清县| 大连市| 南康市| 梁平县| 库伦旗| 呈贡县| 锡林郭勒盟| 封丘县| 资源县| 巴彦县| 无极县| 竹山县| 玉门市| 安陆市| 南昌县| 苏尼特右旗| 鄱阳县| 柘城县| 叶城县| 清水河县| 鄢陵县|