Ejercicio en Pycharm, Código con estilo II
#EJERCICIO17
#programa_suma_basica
import time
print"Ingrese un primer valor: "
a=int(input(""))
print"Ingrese un segundo valor: "
b=int(input(""))
suma=a+b
print"Suma de valores ingresados: "
print(suma)
#EJERCICIO18
#programa_manejo_matematicas
import time
from math import *
print"Ingrese un primer valor: "
x=int(input(""))
print"Ingrese un segundo valor: "
y=int(input(""))
s=log(x+y)
print"El resultado es: ",s
time.sleep(5)
#EJERCICIO19
#encoding:utf-8
edad=10
if edad > 0 and edad < 18:
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"
#EJERCICIO20
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"
#EJERCICIO21
print "Dame el valor: "
a=int(input(""))
if a > 0 :
print"Es un numero positivo"
elif a == 0 :
print"Es neutro "
else:
print "Es un numero negativo"
#EJERCICIO22
"""Uso_de_metodos_con_if""
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))
#EJERCICIO23
def xmayor(num1,num2):
if num1 % num2 == 0:
print num1," es multiplo de ",num2
else:
print num1," no es multiplo de ",num2
num1=input("Dame el numero: ")
num2=input("Dame el numero: ")
print(xmayor(num1,num2))
#EJERCICIO24
def notas(nota):
if nota >= 0 and nota <= 3 :
return"Insuficiente"
elif nota >= 4 and nota <= 6 :
return"Suficiente"
elif nota >= 7 and nota <= 10 :
return"Bien"
nota=input("Ingrese la nota: ")
print notas(nota)
#EJERCICIO25
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):
return monto-precioProducto
monto = input("Ingrese el monto: ")
if monto < 5:
print iniciar(monto)
else:
print'Monto debe ser menor a 5'
#EJERCICIO26
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 _cuotas(Prestamo, meses):
cuotas=Prestamo/meses
return cuotas
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 darle un prestamo")
else:
print"No es mayor de edad"
Ejercicio en bloc de notas:
#EJERCICIO16
from Tkinter import *
#mi marco
raiz = Tk()
raiz.title("Mi aplicacion usando block de notas");
#nombre
nombreLabel1 = Label(raiz,text="Nombre :")
nombreLabel1.grid(row=0,column=0)
#el entry del nombre
cuadro1nombre = Entry(raiz)
cuadro1nombre.grid(row=0,column=1)
#apellido
apellidoLabel2= Label(raiz,text="Apellido : ")
apellidoLabel2.grid(row=1,column=0)
#el entry del nombre
cuadro2apellido= Entry(raiz)
cuadro2apellido.grid(row=1,column=1)
raiz.mainloop()
Comentarios
Publicar un comentario