最美情侣中文字幕电影,在线麻豆精品传媒,在线网站高清黄,久久黄色视频

歡迎光臨散文網(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ù)繪圖的評論 (共 條)

分享到微博請遵守國家法律
定远县| 东兰县| 长沙市| 龙井市| 綦江县| 会理县| 龙里县| 绍兴县| 东乌珠穆沁旗| 漯河市| 万年县| 昭平县| 东源县| 台州市| 武定县| 黎川县| 五华县| 通渭县| 樟树市| 滦平县| 无极县| 青河县| 甘谷县| 探索| 科技| 靖远县| 湟源县| 南和县| 陕西省| 堆龙德庆县| 三门峡市| 弥渡县| 禄劝| 嘉祥县| 定日县| 都匀市| 曲阜市| 洛阳市| 肃宁县| 庆城县| 大渡口区|