Python - Cómo finalizar un programa

 
Vista:

Cómo finalizar un programa

Publicado por Martín (3 intervenciones) el 17/01/2012 08:34:02
Hola.

En un ejercicio se pide modificar el programa (que transcribo a continuación) para que se detenga cuando el usuario lo indique. Pues no sé cómo hacerlo... Gracias por la ayuda.
(es el ejercicio 143 el manual que está en este mismo blog)
____________________________________________________________________________
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
from math import sqrt
 
window_coordinates(-500,-500, 500,500)
 
x1 = -200
y1 = -200
velocidad_x1 = 0.1
velocidad_y1 = 0
m1 = 20
 
x2 = 200
y2 = 200
velocidad_x2 = -0.1
velocidad_y2 = 0
m2 = 20
 
circulo_1 = create_circle(x1, y1, m1, 'red')
circulo_2 = create_circle(x2, y2, m2, 'blue')
 
 
for t in range(1,10000): #sospecho que hay que modificar algo aquí, pero no sé cómo
  r = sqrt( (x2-x1)**2 + (y2-y1)**2 )
 
  aceleracion_x1 = m2 * (x2 - x1) / r**3
  aceleracion_y1 = m2 * (y2 - y1) / r**3
  aceleracion_x2 = m1 * (x1 - x2) / r**3
  aceleracion_y2 = m1 * (y1 - y2) / r**3
 
  velocidad_x1 += aceleracion_x1
  velocidad_y1 += aceleracion_y1
  velocidad_x2 += aceleracion_x2
  velocidad_y2 += aceleracion_y2
 
  x1 += velocidad_x1
  y1 += velocidad_y1
  x2 += velocidad_x2
  y2 += velocidad_y2
 
  erase(circulo_1)
  circulo_1 = create_circle(x1, y1, m1, 'red')
  erase(circulo_2)
  circulo_2 = create_circle(x2, y2, m2, 'blue')

___________________________________________________________________________
Saludos!!
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder