Tutorial Python 32 - Modulos (Modules)

preview_player
Показать описание

🐊 Síguenos en:

----
Código Facilito es una de las plataformas de aprendizaje online de programación más grandes de habla hispana. Desde el 2010 formamos programadores en toda América Latina y España enseñando. HTML, JavaScript, React, Python, Rails, Go y mucho más.
Рекомендации по теме
Комментарии
Автор

muchisimas gracias por los tutos bro! genial :D

simongonzalez
Автор

Gracias por el video amigo, te juro que no entendia porque no me funcionaba el import de los cojones, ahora lo tengo claro :P

ferchulanderful
Автор

gracias por estos tutoriales, la verdad me an introducido al mundo de la progracion se puede decir que eres un buen instructor, son excelentes los tutoriales

manuelmedina
Автор

Seguira el curos muy bueno ya lo vi todo, porfavor seria muy bueno que lo sigan (0=p

alejandroreyes
Автор

Tengo un proyecto que me dice:

Traceback (most recent call last):
File "archivo.py", line 3, in <module>
from seleniumFork import SFork
ImportError: No module named seleniumFork

Pero el modulo si existe y me dice que no. A que se deberá esto? :(

PPKNTOO
Автор

dale, sigan con los siguientes tutoriales, por dios agreguen los que no estan en la lista

peter_castle
Автор

seguiran el curso ? me ha gustado su forma de explicar

AlexisDiazc
Автор

Parece bueno el curso, pero es para estudiantes avanzados....saludos amigo.

photoafpimagen
Автор

Buenas noches, quisiera saber si conocen algo de contract testing, hay un ejemplo en GitHub que se llama PythonEats, sin embargo no se como ejecutarlo, podrian ayudarme, muchas gracias

luiscarlosbarreto
Автор

Una consulta van a seguir con el curso me gustaria ver el desarrollo de aplicaciones form en python se los agradeceria

jordanordonezcabrera
Автор

como entro a esa ventana azul? yo tengo el pythonG y no puedo usar modulos

razachrisok
Автор

Hola amigos de codigofacilito  muy buenos videos de pythonme los avente en 3 dias xDDD me gustaria algo mas visual(ventanas botones etc) o un poco mas avanzado  es una sugerencia saludos ...(Y)

edgarmontano
Автор

Podrías utilizar PyCharm es muy buen IDE, muchas gracias por tus vídeos.

daklina
Автор

No mames, ¿eres de la ESCOM del poli? Es la mejor escuela para ISC, lo reconozco como puma, excelente el curso, saludos men

johanngordillo
Автор

flaco, estan afuera de la playlist, buscalos en la barra de busqueda. = no termino el curso todavia pero hay 4 mas.

peter_castle
Автор

es muy complicado ya no quiero nada ya abu abu me duele mi pie

RhigoFull
Автор

Me gusta tu página pero lamentablemente el sonido no acompaña tu explicación. Se siente demasiado rápido, parece pegar las palabras y se pierde una buena explicación. No pongo en duda conocimiento. Me parece bien pero la transmisión del conocimiento no llega bien. Te expongo esto porque veo saben bien lo que hacen....

davidmartinez
Автор

Hola a todos


He realizado este código según este ejercicio a partir de los conocimientos impartidos por este canal y otros previos, si alguno quiere pegarle una ojeada y estudiarlo les dejaré el código a continuación más el enunciado del ejercicio, espero que le sirva a alguno


ENUNCIADO:
La “granja de mi tío” es una empresa dedicada a la comercialización de diferentes animales (gallinas, cerdos y vacas). De cada animal se tiene un código, un precio de compra, y un peso. Sin embargo, dependiendo del tipo de animal se tiene la siguiente información:

Gallinas: tipo (ponedora o de engorde) y edad en meses
Cerdos: sexo
Vacas: tipo (lechera o de producción)
La “granja de mi tío” requiere un sistema que le permita gestionar la compra y la venta de los diferentes animales. Para cada compra se debe registrar todos los datos del respectivo animal, así como la fecha (que está compuesta por un día, mes y año) y el precio de la compra (En cada compra solo se adquiere un animal). Además, el sistema debe permitir:

Registrar una compra (el dueño de la granja adquiere un animal)
Registrar una venta (el animal ya no está disponible para la venta), este método debe incluir la forma de calcular el precio de venta sabiendo que:
Gallinas tiene un precio de venta igual al precio de compra por un porcentaje de ganancia que depende del tipo: ponedora= 30%, de engorde = 45%.
Cerdos: el precio de venta es igual al precio de compra por una ganancia del 50%.
Vaca, el precio de venta es igual al peso * 5000;
Calcular la ganancia obtenida por el total de las ventas.
Modificar el peso de un animal, incrementándolo o disminuyéndolo en un valor X.
Modificar la edad de una gallina.
Determinar la cantidad de animales comprados o vendidos en una fecha dada.


CÓDIGO:
clase principal
from datetime import date
import Animal
f=[]
sell=[]
acu=0
def Buy():
t=("chicken", "pig", "cow")
c=input("animal's code: ")
confirm=True
if f: #true si la lista no está vacía, false si está vacía
for x in f:
if(x.GetCode()==c):
confirm=False
if confirm:
trae=int(input("Price: "))
w=int(input("Weigth: "))
tipe=input("What is the animal to buy: ").lower()
o = True
for s in t:
if(s==tipe):
o=True
if(o):
if(tipe=='chicken'):
ts=input("¿Fattening or Laying: ").lower()
e=int(input("age in months: "))
print(date.today())
a=Animal.Chicken(c, w, trae, tipe, str(date.today()))
a.Chicken(ts, e)
a.ToString()
f.append(a)
elif (tipe=='pig'):
sex=input("sex: ")
a=Animal.Pig(c, w, trae, tipe, str(date.today()))
a.Pig(sex)
a.ToString()
f.append(a)
elif (tipe=='cow'):
mp=input("milker or production: ").lower()
a=Animal.Cow(c, w, trae, tipe, str(date.today()))
a.Cow(mp)
a.ToString()
f.append(a)
else:
print("in this momento you can't buy this animal")
print("Thanks for your bought")
else:
print("Sorry, the code typed has already been created")
def Sell():
if f:
print("this the animal's list to sell, please pay attencion to the parameters of the each animal according your need")
global acu
for x in f:
x.Information()
print("type the animal's code to buy")
code=input("Code: ")
for x in f:
if x.GetCode()==code:
r=x
f.remove(x)
if (r.GetTipe()== 'chicken'):

print("The price of this animal is ", r.GetPrice()*1.45)

acu=acu+r.GetPrice()*1.45
else:
print("The price of this animal is ", r.GetPrice()*1.30)

acu = acu + r.GetPrice() * 1.30
elif (r.GetTipe()== 'pig'):
print("The price of this animal is ", r.GetPrice() * 1.50)
acu = acu + r.GetPrice() * 1.50
elif (r.GetTipe()== 'cow'):
print("The price of this animal is ", r.GetPrice() * 5000)
acu = acu + r.GetPrice() * 5000

sell.append(r)
else:
print("In this moment there is not animals for to sell")

def Calculate():
global acu
print("The profit obtained at until moment is: ", acu)
def Change():
if f:
choise=input("change weight or age of the an animal?: ").lower()
if choise=='weight':
print("choose the animal's code: ")
for x in f:
x.Information()
code=input("code: ")
for x in f:
if x.GetCode()==code:
print("Remember that you only can change the weight in a 'x' valor")
w=int(input("x valor: "))
x.SetWeight(w)
a=x
print("Update successful, this is the new weight->", a.GetWeight())
elif choise=='age':
print("choose the animal's code: ")
for x in f:
if x.GetTipe()=='chicken':
x.Information()
code = input("code: ")
for x in f:
if x.GetCode() == code:
a = int(input("new age: "))
x.SetAge(a)
print("Update successful")
else:
print("Please write weight or age to change")
else:
print("There is not animals in the list")
def Determ():
if sell or f:
print("Input a date in this format AAAA-MM-DD")
ds=input("Date: ")
bought=0
soled=0
for x in sell:
if x.GetDateBought()==ds:
bought=bought+1
if x.GetDateSell()==ds:
soled=soled+1
for x in f:
if x.GetDateBought()==ds:
bought=bought+1
print(" animals bought in ", ds, "=", bought, '\n'+
"animals soled in ", ds, "=", bought)
else:
print("There is not animals soled or bought")
s=True
d={'1': Buy, '2': Sell, '3': Calculate, '4': Change, '5':Determ}
while s==True:

print("""THIS IS THE FARM'S MENU
1.register a purchase
2.Register a sale
3.Calculate profit
4.Change age or weight
5.Determ
6.exit
""")

a=input("Choose your option: ")
try:
if a=='6':
s=False
print("thank you for visit us")
else:
d[a]();
except:
print("Please choose a right option")

Clase animal

class Animal:
def __init__(self, code, weight, price, tipe, datebought):
self.code=code
self.weight=weight
self.price=price
self.tipe=tipe
self.datebought=datebought
self.datesell="null"
def GetDateSell(self):
return self.datesell
def SetDateSell(self, datesell):
self.datesell=datesell
def GetDateBought(self):
return self.datebought
def SetDateBought(self, datebought):
self.datebought=datebought
def GetTipe(self):
return self.tipe
def GetCode(self):
return self.code
def GetWeight(self):
return self.weight
def GetPrice(self):
return self.price
def SetCode(self, code):
self.code=code
def SetWeight(self, weight):
self.weight= self.weight+weight
def SetPrice(self, price):
self.price=price
class Chicken(Animal):
def Chicken(self, type, age):
self.type=type
self.age=age
def ToString(self):
return print("""The animal has been bought with the parameters
code=""", self.code, """
weigh=""", self.weight, """
price=""", self.price, """
type""", self.type, """
age=""", self.age)
def Information(self):
return print("""
animal=""", self.tipe, """
code=""", self.code, """
weigh=""", self.weight, """
price=""", self.price, """
type""", self.type, """
age=""", self.age)
def GetType(self):
return self.type
def SetType(self, type):
self.type=type
def GetaAge(self):
return self.age
def SetType(self, age):
self.age = age
class Pig(Animal):
def Pig(self, sex):
self.sex=sex
def ToString(self):
return print("""The animal has been bought with the parameters
code=""", self.code, """
weigh=""", self.weight, """
price=""", self.price, """
sex""", self.sex)
def Information(self):
return print("""
animal=""", self.tipe, """
code=""", self.code, """
weigh=""", self.weight, """
price=""", self.price, """
sex""", self.sex)

def GetSex(self):
return self.sex
def SetSex(self, sex):
self.sex=sex
class Cow(Animal):
def Cow(self, type):
self.type=type
def ToString(self):
return print("""The animal has been bought with the parameters
code=""", self.code, """
weigh=""", self.weight, """
price=""", self.price, """
type""", self.type)
def Information(self):
return print("""
animal=""", self.tipe, """
code=""", self.code, """
weigh=""", self.weight, """
price=""", self.price, """
type=""", self.type)
def GetType(self):
return self.type

def SetType(self, type):
self.type = type

joseantoniosanchesgarcia
Автор

Exelente curso loko pero para la proxima hbla mas claro... o no ten rapido. xD

HadesxXx
Автор

un poquito enredado para el novato, deberias rehacer el video. Saludos y gracias

rogergallegos
join shbcf.ru