Skip to content
Extraits de code Groupes Projets
Valider bb65d19a rédigé par Martin Delcourt's avatar Martin Delcourt
Parcourir les fichiers

Added ex5.py

parent 0f6bae0e
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
import math
v0 = float(input("Vitesse initiale ?"))
alpha = float(input("Angle initial ?"))
v0_x = v0*math.cos(alpha*math.pi/180)
v0_y = v0*math.sin(alpha*math.pi/180)
g = 9.81
# Paramètres A et B tels que y = A*x + B*x²
A = v0_y / v0_x
B = 0.5*g/v0_x**2
n_lines = 50
n_col = 100
print(" "+n_col*"-")
lineId = 0
while lineId < n_lines:
colId = 0
txt_to_print = "|"
while colId < n_col:
t = 0
filled = False
x = colId - 0.5
while x < colId + 0.5: # Boucle sur x pour avoir une ligne continue
y = A*x - B*x**2
if abs(n_lines-y-lineId)<0.5:
filled = True # S'assurer qu'on ne remplisse qu'une fois une case
txt_to_print+="x"
break
x+=0.1
if not filled:
txt_to_print += " " # Case non remplie
colId+=1
lineId+=1
print txt_to_print+"|"
print(" "+n_col*"-")
import math
v0 = float(input("Vitesse initiale ?"))
alpha = float(input("Angle initial ?"))
v0_x = v0*math.cos(alpha*math.pi/180)
v0_y = v0*math.sin(alpha*math.pi/180)
g = 9.81
n_lines = 50
n_col = 100
print(" "+n_col*"-")
lineId = 0
while lineId < n_lines:
colId = 0
txt_to_print = "|"
while colId < n_col:
t = 0
filled = False
while t < 10000: # On évalue toute la trajectoire pour chaque case du tableau...
x = v0_x*t
y = v0_y*t - 0.5*g*t**2
t+=0.01
if abs(x - colId ) < 0.5 and abs(n_lines-y-lineId)<0.5:
txt_to_print+="x"
filled = True
break
if y < 0 or x < 0 or x > n_col:
break
if filled == False:
txt_to_print += " "
colId+=1
lineId+=1
print txt_to_print+"|"
print(" "+n_col*"-")
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter