QUE ONDA CHAVOS....!!!!!

Ya que van a ver mi blog, spero que les guste...!!!!
Aqui se van a enterar de todo lo que hacemos diariamente en el cole a y por cierto de lo bien que nos la pasamos las 6 peritas en nuestra gran clase...jajaja☻☺♥

LA MEJOR SERIE...!!!!!!

LA MEJOR SERIE...!!!!!!
LA FIESTA VA A EMPEZAR!!!!!

martes, 1 de septiembre de 2009

PROGRAMACION

RESUMEN

Python permite indicar que deseamos que se repita un trozo de programa de dos formas
distintas: mediante la sentencia while y mediante la sentencia for. La primera de ellas es más
general.

La sentencia while

En inglés, "while" significa "mientras". La sentencia while se usa así:

while :
acción
acción
...
acción

Permite expresar en Python acciones cuyo significado es:
"Mientras se cumpla esta condición, repite estas acciones."

Las sentencias que denotan repetición se denominan bucle.

Ejemplo:

i = 0
while i <>
print i
i += 1
print ’Hecho’

Si ejecutamos el programa, por pantalla aparecerá el siguiente texto: 0 1 2 Hecho

PROGRAMAS

Programa 95: (NÚMEROS DEL 0 AL 2)

i=0
while i<3:
print i
i+=1
print 'hecho'

RESULTADO

0
1
2
hecho


Programa 96: (NUMEROS PARES)

i=0
while i<10:
print i
i+=2
print 'hecho'

RESULTADO

0
2
4
6
8
10
hecho

Programa 97: (NUMEROS IMPARES)

i=3
while i <10:
print i
i+=2
print 'hecho'

RESULTADO

3
5
7
9
hecho

Programa 98: (POTENCIA DE 2)


i=1
while i<100:
print i
i*=2

RESULTADO

2
4
8
16
32
64
128

Programa 99:

i=10
while i<2:
print i
i*=2

RESULTADO

No aparece nada


Programa 100: (VALOR INICIAL MENOR QUE 10:2 )

i=int(raw_input('ingrese valor inicial: '))

while i<10:
print i
1+i=1

RESULTADO

2
3
4
5
6
7
8
9



Programa 101: (INICIO Y FIN DE LA LISTA DE NUMEROS)

i=int(raw_input('ingrese el valor inicial: '))
limite=int(raw_input('ingrese el limite: '))

while i<>
print i
i+=1

RESULTADO

INGRESE EL VALOR INICIAL:2
INGRESE EL LIMITE:12

2
3
4
5
6
7
8
9
10
11


Programa 102: (incremento)

i=int(raw_input('ingrese el valor inicial: '))
limite=int(raw_input('ingrese el limite: '))
incremento=int('ingrese el incremento: '))

while i
print i
i+=incremento

RESULTADO

INGRESE EL VALOR INICIAL: 5
INGRESE EL LIMITE: 10
INGRESE EL INCREMENTO: 3

5
8
10

No hay comentarios:

Publicar un comentario