Practicas

Suma

#Programa Suma basica
import time
print"Ingresa el primer valor: "
a=int(input(""))
print"Ingresa el segundo valor: "
b=int(input(""))
suma=a+b
print "Suma de Valores ingresados: "
time.sleep(5)
print(suma)
view raw suma.py hosted with ❤ by GitHub

Múltiplos

# encoding: utf-8
def xmayor (num1,num2):
if num2 % num1 == 0:
print num1, "es multiplo de",num2
else :
print num1, "No es multiplo de ",num2
num1=input("Dame el primer numero ")
num2=input("Dame el segundo numero ")
xmayor(num1,num2)
view raw multiplos.py hosted with ❤ by GitHub

Matemática

#Programa manejo de matematicas
import time
from math import*
print"Ingresa el primer valor: "
x=int(input(""))
print"Ingresa el segundo valor: "
y=int(input(""))
suma=(x+y)
s = log(x+y)
print "El resultado el logaritmo natural de ",suma,": "
time.sleep(5)
print(s)
view raw mat.py hosted with ❤ by GitHub

if6

def iniciar(monto):
dulce = raw_input('Elija la letra ')
if dulce == 'a':
precioProducto = 2.5
print 'Su cambio es: ', calcularcambio (precioProducto , monto)
elif dulce == 'b':
precioProducto = 1.4
print 'Su cambio es: ', calcularcambio (precioProducto , monto)
elif dulce == 'c':
precioProducto = 1.2
print 'Su cambio es: ', calcularcambio (precioProducto , monto)
def calcularcambio(precioProducto , monto):
cambio = monto – precioProducto
return cambio
monto= input("ingresa el monto: ")
if monto < 5:
iniciar(monto)
else:
print 'Monto debe ser menor a 5'
view raw if6.py hosted with ❤ by GitHub

if5

def notas(nota):
if nota >= 0 and nota <= 3:
return "Insuficiente :v"
elif nota >= 4 and nota <= 6:
return "Suficiente"
elif nota >= 7 and nota <=10:
return "Bien"
nota= input('ingrese la nota: ')
print notas(nota)
view raw if5.py hosted with ❤ by GitHub

if4

# encoding: utf-8
def Numero (num):
if num > 0:
return "Es positivo"
elif num < 0:
return "Es negativo"
elif num==0:
return "Es un cero"
num=input("Dame el numero ")
print (Numero(num))
view raw if4.py hosted with ❤ by GitHub

if3

print 'Dame el valor: '
a= int (input(""))
if a>0:
print 'Es un numero positivo'
elif a==0:
print 'Es igual a cero'
else:
print 'Es un numero negativo'
view raw if3.py hosted with ❤ by GitHub

If2

# encoding: utf-8
print 'Dame el valor: '
a= int (input(""))
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'
view raw if2.py hosted with ❤ by GitHub

Ventana con Tkinter

from Tkinter import*
# Mi marco
raiz=Tk()
raiz.title("Mi aplicasion")
# Mi etiqueta nombre
nombreLabel1=Label(raiz,text="Nombre del alumno:")
nombreLabel1.grid(row=0,column=0)
# el entry del nombre
cuadronombre = Entry(raiz)
cuadronombre.grid(row=0,column=1)
# Mi etiqueta Apellido
ApellidoLabel1=Label(raiz,text="Apellido del alumno:")
ApellidoLabel1.grid(row=1,column=0)
# el entry del Apellido
Apellidonombre = Entry(raiz)
Apellidonombre.grid(row=1,column=1)
raiz.mainloop()
view raw Ejemplo1.py hosted with ❤ by GitHub

Edad

# encoding: utf-8
edad=18
print "Dame la Edad:"
edad = int(input(""))
if edad >= 0 and edad <18: # Todo metodo con ":"
print "Eres un niño"
elif edad <0:
print "No numeros negativos"
elif edad >=18 and edad < 27:
print "Eres un joven"
elif edad >=27 and edad < 60:
print "Eres un adulto"
else:
print 'Eres de la tercera edad'
view raw edad.py hosted with ❤ by GitHub

Banco

def _cuotas(prestamo,meses):
cuotas = prestamo/meses
return cuotas
def _prestamo(ingresos,egresos):
prestamo = input ('Monto del prestamo: ')
meses = input ('Cuantos meses de pago?: ')
print "Monto de pago por mes: ", _cuotas(prestamo,meses)
def edad():
edad = input('Ingrese su edad: ')
if edad >= 18:
ingresos = input('Dame tus ingresos:')
egresos = input('Dame tus egresos: ')
if ingresos >= egresos:
_prestamo(ingresos, egresos)
else:
print 'No es posible hacer el prestamo 😑'
else:
print 'No es mayor de edad'
edad()
view raw if7.py hosted with ❤ by GitHub

Deja un comentario

Diseña un sitio como este con WordPress.com
Comenzar