[go: up one dir, main page]

0% found this document useful (0 votes)
35 views2 pages

Mes Scripts Test

The document describes a Python program that uses the turtle module to draw either a square or rectangle based on user input. It prompts the user to enter "square" or "rectangle", then uses turtle functions like color, begin_fill, forward and left to draw the chosen shape. An if/else statement directs the code flow. The program is later updated to add a write function to label angles for the rectangle.

Uploaded by

souhail
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
35 views2 pages

Mes Scripts Test

The document describes a Python program that uses the turtle module to draw either a square or rectangle based on user input. It prompts the user to enter "square" or "rectangle", then uses turtle functions like color, begin_fill, forward and left to draw the chosen shape. An if/else statement directs the code flow. The program is later updated to add a write function to label angles for the rectangle.

Uploaded by

souhail
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

Dessinez un carre ou un rectangle selon notre choix avec turtle :

import turtle

choix = input("carre ou rectangle :")

if choix.lower() == "carre" :
carre = turtle.color("red"), turtle.begin_fill(), turtle.forward(100),
turtle.left(90), turtle.forward(100), turtle.left(90), turtle.forward(100),
turtle.left(90), turtle.forward(100), turtle.end_fill()
print(carre)
turtle.exitonclick()

elif choix.lower() == "rectangle" :


rectangle = turtle.color("green","purple"), turtle.begin_fill(),
turtle.forward(200), turtle.left(90), turtle.forward(100), turtle.left(90),
turtle.forward(200), turtle.left(90), turtle.forward(100), turtle.end_fill()
print(rectangle)
turtle.exitonclick()

else: print("choisissez la bonne forme")

Ajout de la fonction turtle.write et correction :

import turtle

choix = input("carre ou rectangle :")

if choix.lower() == "carre" :
carre = turtle.color("red"), turtle.begin_fill(), turtle.forward(100),
turtle.left(90), turtle.forward(100), turtle.left(90), turtle.forward(100),
turtle.left(90), turtle.forward(100), turtle.end_fill()
turtle.exitonclick()

elif choix.lower() == "rectangle" :


rectangle = turtle.color("green","purple"), turtle.begin_fill(),
turtle.forward(200), turtle.left(90), turtle.forward(100), turtle.left(90),
turtle.forward(200), turtle.left(90), turtle.forward(100), turtle.end_fill()
font = ("arial",12,"normal")
turtle.color("black"), turtle.write("90 degré",font = font)
turtle.exitonclick()

else: print("carre ou rectangle seulement!")

Method :

test = 'bonjour !'.upper()


print(test)

ou
test = 'bonjour'
print(test.upper())

You might also like