Python
是只好猫咪
我是狗子,祝你开心
展开
-
Python turtle 学习之画个五角星
使用环境为Python 3.5#画个五角星玩玩from turtle import *fillcolor("red") #设置填充颜色begin_fill()while True: forward(200) #设置五角星的大小 right(144) if abs(pos()) < 1: breakend_fill()原创 2017-07-19 13:50:48 · 20676 阅读 · 0 评论 -
python学习之 利用蒙特卡洛方法计算PI值
使用环境为python IDLE3.5.#利用蒙特卡洛方法计算PI值from random import randomfrom math import sqrtfrom time import clockDARTS = 2**26 #这个时候已经比较精确了,耗时也将近1分钟了。修改DARTS可以进一步提高计算精度。hits=0clock() #引入time.clock(原创 2017-07-19 21:52:25 · 4622 阅读 · 1 评论 -
python 学习之二次函数求解以及异常处理
# quadraticEnd.pyimport mathdef main(): print("This program finds the real solutions to a quadratic equation. \n") try: a,b,c = eval(input("Please enter the coefficients(a,b,c):原创 2017-07-30 14:55:33 · 1168 阅读 · 0 评论