pizza2_fb.py

Created by schraf

Created on January 04, 2022

363 Bytes

Ma chaine Youtube consacrée aux maths, à la programmation en Python, aux calculatrices, Excel, etc.

Découpage d'une pizza

xc,yc sont les coordonnées de la pointe de la part de pizza, réparties sur un cercle de rayon 20 et centré en (0,0). Il ne faut pas oublier d’orienter la tortue avant de tracer les arcs de cercles (en partant à 90° pour le premier)

Testez par exemple pizza(3) ou pizza(17)


import turtle
from math import sin, cos, pi

t = turtle

def pizza(n):   
 a = 360 / n
 for k in range(n):
  c, s = cos(2 * k * pi / n), sin(2 * k * pi / n)    
  x, y = 100 * c, 100 * s
  xc, yc = 20 * c, 20 * s
  t.penup()
  t.goto(xc,yc)
  t.pendown()
  t.goto(x,y)
  t.setheading(90 + a * k)
  t.circle(80, a)
  t.goto(xc, yc)

t.hideturtle()

During your visit to our site, NumWorks needs to install "cookies" or use other technologies to collect data about you in order to:

With the exception of Cookies essential to the operation of the site, NumWorks leaves you the choice: you can accept Cookies for audience measurement by clicking on the "Accept and continue" button, or refuse these Cookies by clicking on the "Continue without accepting" button or by continuing your browsing. You can update your choice at any time by clicking on the link "Manage my cookies" at the bottom of the page. For more information, please consult our cookies policy.