0% found this document useful (0 votes)
62 views4 pages

Recettes et exercices Python pratiques

The document contains examples of using Python to solve various math and coding exercises. These include: 1. Calculating recipe ingredients for chocolate mousse based on a number of people. 2. Drawing a cube using the Turtle module by giving commands to turn and move the turtle. 3. Calculating coordinate points around a hexagon based on user input for the length of one side. 4. Taking user input of different numeric values and performing various math operations on them like addition, multiplication, division, exponents, etc. and printing the results.

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)
62 views4 pages

Recettes et exercices Python pratiques

The document contains examples of using Python to solve various math and coding exercises. These include: 1. Calculating recipe ingredients for chocolate mousse based on a number of people. 2. Drawing a cube using the Turtle module by giving commands to turn and move the turtle. 3. Calculating coordinate points around a hexagon based on user input for the length of one side. 4. Taking user input of different numeric values and performing various math operations on them like addition, multiplication, division, exponents, etc. and printing the results.

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

1] EXERCICE : recette mousse au chocolat avec affectation et variable

n = 2
sucre_vanille = 1*n//4
chocolats_noir = 100*n//4
oeufs = 3*n//4

2] EXERCICE : (script recette mousse au chocolat avec input() et


print())

n = float(input("nombres de personnes : "))


sucre_vanille = 1*n//4
chocolats_noir = 100*n//4
oeufs = 3*n//4
print("sucre vanille :", sucre_vanille)
print("chocolats noir :", chocolats_noir)
print("oeufs :", oeufs)
nombres de personnes : 7
sucre vanille : 1.0
chocolats noir : 175.0
oeufs : 5.0

3] EXERCICE : dessiner un cube avec turtle (sans indication)

import turtle

[Link]('black')
turtle.begin_fill()
[Link](100)
[Link](120)
[Link](100)
[Link](60)
[Link](100)
[Link](120)
[Link](100)
turtle.end_fill()
[Link]('red')
turtle.begin_fill()
[Link](60)
[Link](100)
[Link](120)
[Link](100)
[Link](60)
[Link](100)
[Link](120)
[Link](100)
turtle.end_fill()
[Link]('green')
turtle.begin_fill()
[Link](60)
[Link](100)
[Link](120)
[Link](100)
[Link](60)
[Link](100)
turtle.end_fill()

(avec indication angle 60°)

import turtle

[Link]('black')
turtle.begin_fill()
[Link](100)
[Link](120)
[Link](100)
[Link](60)
[Link](100)
[Link](120)
[Link](100)
turtle.end_fill()
[Link]('red')
turtle.begin_fill()
[Link](60)
[Link](100)
[Link](120)
[Link](100)
[Link](60)
[Link](100)
[Link](120)
[Link](100)
turtle.end_fill()
[Link]('green')
turtle.begin_fill()
[Link](60)
[Link](100)
[Link](120)
[Link](100)
[Link](60)
[Link](100)
turtle.end_fill()

(amelioré avec [Link])

import math as m
import turtle as t

[Link]("blue")
t.begin_fill()
[Link](100,0)
[Link]([Link]([Link]/3)*100,[Link]([Link]/3)*100)
[Link]([Link](2*[Link]/3)*100,[Link](2*[Link]/3)*100)
[Link](0,0)
t.end_fill()
[Link]("black")
t.begin_fill()
[Link]([Link](2*[Link]/-3)*100,[Link](2*[Link]/-3)*100)
[Link]([Link]([Link]/-3)*100,[Link]([Link]/-3)*100)
[Link](100,0)
[Link](0,0)
t.end_fill()
[Link]("red")
t.begin_fill()
[Link]([Link](2*[Link]/3)*100,[Link](2*[Link]/3)*100)
[Link](-100,0)
[Link]([Link](2*[Link]/3)*100,-[Link](2*[Link]/3)*100)
t.end_fill()

4] EXERCICE : 2.4

import math as m

n = float(input("entre une longeur :"))

a = (-[Link]([Link])*n,0.0)
b = ([Link]([Link]/3)*n,[Link]([Link]/3)*n)
c = ([Link](2*[Link]/3)*n,[Link](2*[Link]/3)*n)
d = ([Link](3*[Link]/3)*n,[Link](3*[Link]/3)*n)
e = ([Link](4*[Link]/3)*n,[Link](4*[Link]/3)*n)
f = ([Link](5*[Link]/3)*n,[Link](5*[Link]/3)*n)

print(a)
print(b)
print(c)
print(d)
print(e)
print(f)

(correction par moi-même)

import math as m

n = float(input())

a = (-[Link]([Link])*n,0.0)
b = ([Link]([Link]/3)*n,[Link]([Link]/3)*n)
c = ([Link](2*[Link]/3)*n,[Link](2*[Link]/3)*n)
d = ([Link](3*[Link]/3)*n,[Link](3*[Link]/3)*n)
e = ([Link](4*[Link]/3)*n,[Link](4*[Link]/3)*n)
f = ([Link](5*[Link]/3)*n,[Link](5*[Link]/3)*n)

coordonnee = [a,b,c,d,e,f]

for letter in coordonnee :


x,y = letter
print(x,y)

5] EXERCICE : 2.5
x = int(input())
y = int(input())
z = float(input())
t = float(input())

a = x - y
b = x + z
c = z + t
d = x * z
e = x / 2
f = x / (y+1)
g = (x+y)*z / (4*x)
h = x ** (-1/2)

liste = [a,b,c,d,e,f,g,h]

for number in liste:


print(number)

6] EXERCICE : 2.

You might also like