Statistiques : Permet de créer un graphique camembert suivant les données saisies
from turtle import * # Data for the pie chart sizes = [15, 30, 45, 10] # Percentages for each category labels = ['15%', '30%', '45%', '10%'] # Corresponding percentage labels # Function to draw a pie chart slice def draw_slice(pct, label): angle = pct * 360 / 100 # Convert percentage to angle penup() forward(80) # Move to the circumference of the larger circle left(90) pendown() circle(80, angle) # Draw the arc with the new larger radius left(90) forward(80) # Move back to the center left(90) penup() forward(120) # Move further out to write the label outside the pie write(label) backward(120) # Move back to the center left(90) pendown() # Reset orientation for the next slice right(90 + angle) # Rotate to the starting position for the next slice # Initialize turtle speed(0) # Max speed for drawing penup() goto(0, 0) # Start at the bottom of the larger circle to center it better pendown() # Draw each slice for i in range(len(sizes)): draw_slice(sizes[i], labels[i]) # Hide the turtle after completing the pie chart hideturtle()