If you want a commandline version, you can ask me, but tell you what, since those values are all
float numbers, so it's hard to get a precise graph in commandline window.
Well, in this version, I enlarged each element's position by 40 and then change them to integer, guess this is an endurable loss of precision.
#
from math import radians
from math import sin
from Tkinter import *
pos = []
xPos = 0
centerX = 0
centerY = 0
for deg in range(-360, 361, 10):
pos.append([xPos, int(40*(sin(radians(deg))))]) #1000 too big for my screen
xPos+=1
if deg == 0:
centerX = xPos-1
centerY = pos[-1][1]
root = Tk()
root.title('trianble graph from -180 to 180')
width, height = 550, 450
mHei = height/2
mWid = width/2
canvas = Canvas(root, width=width, height=height)
canvas.create_line(0, mHei, width, mHei)#x axis
canvas.create_line(mWid, 0, mWid, height)#y axis
xStep = (width-150)/len(pos)
yStep = (height-150)/len(pos)
radius = 3
# the middle point (sin(0) is first drawn and used as position reference for all
canvas.create_oval(mWid-radius, mHei-radius, mWid+radius, mHei+radius, fill='green')
print pos
print xStep, yStep, centerX, centerY
#exit(0)
for i in pos:
if i[0] == centerX: #center processed already.
continue
x = mWid + xStep*(i[0]-centerX)
# y is smaller, the bigger the value, so use minus
y = mHei - yStep*(i[1]-centerY)
canvas.create_oval(x-radius, y-radius, x+radius, y+radius, fill='green')
canvas.pack()
root.mainloop()
如何用python表示三角函数在python中,有一个math module,你可以import math , 里面有math.sin(), math.cos(), math.asin()和math.acos()四个函数 。相信你也知道asin和acos的意思,就是arcsin和arccos 。有了这四个函数你就可以求函数值和角度了 。但是要注意括号里面填的数值 , 要用弧度制 。
python三角函数怎么输入度数python三角函数输入度数:acos(x) //返回x的反余弦弧度值 。asin(x) //返回x的反正弦弧度值 。atan(x) //返回x的反正切弧度值 。
def read_cell(x,y):if cell_type(x,y)==4: #4是真值类型(bool) , return "TRUE" if cell_value(x,y)==1 else "FALSE" 。
elif cell_type(x,y)==2: #2是数字类型(number),return str(cell_value(x,y)),else:#其他类型不再一一列举 , 用到时再做增加 。
python三角函数规范的代码:
Python采用强制缩进的方式使得代码具有较好可读性 。而Python语言写的程序不需要编译成二进制代码 。Python的作者设计限制性很强的语法 , 使得不好的编程习惯(例如if语句的下一行不向右缩进)都不能通过编译 。其中很重要的一项就是Python的缩进规则 。
一个和其他大多数语言(如C)的区别就是,一个模块的界限,完全是由每行的首字符在这一行的位置来决定(而C语言是用一对大括号{}来明确的定出模块的边界,与字符的位置毫无关系) 。通过强制程序员们缩进,Python确实使得程序更加清晰和美观 。
【python打印三角函数 python打印输出三角形】python打印三角函数的介绍就聊到这里吧,感谢你花时间阅读本站内容,更多关于python打印输出三角形、python打印三角函数的信息别忘了在本站进行查找喔 。
推荐阅读
- 神舟怎么连接独立显卡主机,神舟怎么连接独立显卡主机设置
- 关注公众号小黄书,有什么小黄书的公众号
- 重启redis的命令,redis重启命令行
- 斗鱼直播有哪些大主播,斗鱼都有谁直播
- c语言函数的实参不能是 c语言函数实参个数
- 新媒体的现状如何写,新媒体营销现状
- 微信公众号写作视频,微信公众号文章视频
- cocoa游戏开发,cocoscreator游戏开发
- vb.net日期类型 vbnet日期比较