首页 > 编程语言 >Think Python-How to Think Like a Computer Scientist_chapter4_练习 4-3

Think Python-How to Think Like a Computer Scientist_chapter4_练习 4-3

时间:2023-04-30 10:22:55浏览次数:49  
标签:turtle Like lt Computer angle1 angle2 Think math

# coding=gbk 
import math
import turtle
bob = turtle.Turtle()
print(bob)

def pie(t,r,n):
    """画一个包含 n 个三角形的饼图。
    t:Turtle object
    r:三角形腰长
    n:包含几个三角形或几边形
    """
    angle1 = 180 / n
    angle2 = 90 + angle1
    y = 2 * math.sin(math.radians(angle1)) *r
    t.lt(angle1)
    for i in range(n):
        t.fd(r)
        t.lt(angle2)
        t.fd(y)
        t.lt(angle2)
        t.fd(r)
        t.lt(180)

pie(bob,100,7)        
turtle.mainloop()

效果图:



标签:turtle,Like,lt,Computer,angle1,angle2,Think,math
From: https://www.cnblogs.com/lld01/p/17364961.html

相关文章

  • Spring Security 报:Encoded password does not look like BCrypt
    SpringBoot集成Security时,报EncodedpassworddoesnotlooklikeBCrypt原因:SecurityConfig必须Bean的形式实例化/***配置用户身份的configure()方法**@paramauth*@throwsException*/@Overrideprotectedvoidconfigure(AuthenticationManagerBuilderau......
  • Cheems. Would you like going to the dock later to order some French fries?
    Prologue"So,wherearewegoing?""I'mgoingtothedocklatertoordersomeFrenchfries.""No,youmisunderstood...Imean,whatistheultimategoalofourlife?""What'syouropinion?""......
  • Spring Security 报:Encoded password does not look like BCrypt
    SpringBoot集成Security时,报EncodedpassworddoesnotlooklikeBCrypt原因:SecurityConfig必须Bean的形式实例化/***配置用户身份的configure()方法**@paramauth*@throwsException*/@Overrideprotectedvoidconfigure(AuthenticationManagerBuilder......
  • 斯坦福 UE4 C++ ActionRoguelike游戏实例教程 15.创建持续效果BUFF
    斯坦福课程UE4C++ActionRoguelike游戏实例教程0.绪论概述本篇文章对应Lecture18–CreatingBuffs,WorldInteraction,71、72节。将会基于之前实现的SurAction能力系统,教你如何定义和创建拥有持续效果的BUFF,例如许多游戏常见的灼烧、中毒效果。目录分析创建BUFF基类......
  • 斯坦福 UE4 C++ ActionRoguelike游戏实例教程 16.优化交互,实现看到物体时出现交互提
    斯坦福课程UE4C++ActionRoguelike游戏实例教程0.绪论概述本篇文章对应Lecture18–CreatingBuffs,WorldInteraction,73节。本文将会重构以前实现过的SurInteractionComponent,实现在玩家注释可交互物体时,可以出现可交互提示,效果如下:在文章的最后,我会放出所有相关的代......
  • AtCoder Regular Contest 111 F Do you like query problems?
    洛谷传送门AtCoder传送门挺有意思的计数。计数感觉很难做,不妨转成期望,期望又可以转成概率之和。考虑枚举\(w\in[0,m-1]\),把\(>w\)的数设为\(1\),\(\lew\)的数设为\(0\)。那么期望就是所有\(w\),\(a_i\)为\(1\)的概率之和。对于一个\(i\),只有以下的操作能改变\(......
  • thinkphp在模型中自动完成session赋值示例代码
    相信用过thinkphp的用户都知道thinkphp的模型可以完成很多辅助功能,比如自动验证、自动完成等,今天在开发中遇到自动完成中需要获取session值然后自动赋值的功能,具体看代码;classArticlelModelextendsModel{protected$_auto=array(array('addtime','time',1,'function'......
  • show table status like 'table'\G 详细信息介绍
    mysql>showtablestatuslike'leyangjun'\G***************************1.row*************************** Name:leyangjun          表名字        Engine:MyISAM                表存储引擎 Version:10      ......
  • Vulhub 漏洞学习之:ThinkPHP
    Vulhub漏洞学习之:ThinkPHP目录Vulhub漏洞学习之:ThinkPHP0利用工具1ThinkPHP2.x任意代码执行漏洞1.1环境安装1.2漏洞利用过程1.3GetShell2ThinkPHP3.x2.1ThinkPHP3.x日志泄露漏洞2.1.1漏洞原理2.1.2漏洞利用过程3ThinkPHP55.0.20远程代码执行漏洞3.1环境安装3.......
  • Thinkpad-t470电脑 Hackintosh 黑苹果efi引导文件
    原文来源于黑果魏叔官网,转载需注明出处。(下载请直接百度黑果魏叔)硬件型号驱动情况主板Thinkpad-t470处理器[email protected]/3.4GhzTurbo已驱动内存16GBDDR42666Mhz(SKHynix)已驱动硬盘IntelSSDPro7600P512GBNVME已驱动显卡IntelHDGraphics520已驱动声......