import math
def calculo():
print "menu de opcion"
print "1. - determinar si el numero es par"
print "2. - sacar seno y coseno de dos numeros"
print "3. - sacar logaritmo de un nuemro"
print "4. - salir"
opcion = int(input ("dame la opcion: "))
calculo()
USOFOR1:
def aumentacuatro(inico,fin):
i=inicio
for i in range(inicio,fin,4):
print i
inicio = int(input ("ingrese el numero de inicio"))
fin = int(input ("ingrese numero fin" ))
aumentacuatro(inicio,fin)
NOTA:
def notas(nota):
if nota>=0 and nota <= 3:
return "insufuciente"
elif nota>=4 and nota <= 6:
return "sufuciente"
elif nota>=7 and nota <= 10:
return "muy bien"
nota= input("ingrese la calificacion :")
print notas(nota)
PAR, IMPAR:
def par_impar(numeroini, numerofin):
while numeroini <= numerofin:
residuo = numeroini % 2
if residuo == 0:
print"el numero es par", numeroin
elif residuo != 0:
print"el numero es impar", numeroini
numeroini = 1 + numeroini
numeroini = int(input("ingrese el numero inicial: "))
numerofin = int(input("ingrese numero final: "))
par_impar(numeroini, numerofin)
SUMA:
def suma(inicio, fin):
suma= 0
while inicio <= fin:
suma= suma + inicio
inicio= inicio + 1
print "la suma es: ", suma
inicio= int(input("dame le numero inicial a sumar: "))
fin= int(input("dame el numero final a sumar: "))
suma(inicio, fin)
HOLA MUNDO:
#programa hola mundo
import time
print "hola mundo"
time. sleep(20)
USO IF 2:
edad = 65
if edad >= 0 and edad < 18:
print "eres un nino"
if edad >=18 and edad < 27:
print "eres un joven"
if edad >=27 and edad < 60:
print "eres un adulto"
else:
print "eres un adulto mayor"
USO IF 3:
a=5
if a=5 :
print "es un cinco"
elif a==6 :
print "es un seis"
elif a==7 :
print "es un siete"
else:
print "no es ningun numero deseado"
SUMA 2:
import time
a = 5
b = 10
suma = a+b
print (suma)
time.sleep(20)
SUMA 1:
"Mi primer programa en python"
""" programa: Hola mundo
Autor: Armando Hernandez LealFecha: 07/02/19 """
import time
a=5
b=6
time.sleep(1)
suma=a+b
print(suma)
SUMA DE PALABRAS:
"Mi primer programa en python"
""" programa: Hola mundo
Autor: Armando Hernandez LealFecha: 07/02/19 """
import time
a=hola
b=mundo
time.sleep(1)
unir=a+b
print(unir)
No hay comentarios.:
Publicar un comentario