It has me a bit confused, I was in freecodecamp practicing a bit of what css is, and at the beginning I used ul li, for example, but later on other times it told me to use ul > li. Is there any difference between these?
Gabriel Martinez's questions
I was in freecodecamp, I use it to exercise and learn in html, and normally it explains certain things to me or I find them on google, but something happened to me that it does not explain to me, it tells me how to solve it (It tells me that This is solved by placing clear: right; in the .divider ), but not because it happens, the problem is that "% Daily Value * " is out of the div "label" visually speaking, I attach the case in codepen: https://codepen.io/DemonShike/pen/ xxWojNv
And on freecodecamp https://www.freecodecamp.org/learn/2022/responsive-web-design/learn-typography-by-building-a-nutrition-label/step-41
I am learning poo and a doubt arose because this code does not work in the first way, but in the second way, which is when I put the "Car()" class inside the "car" variable, I want to know the Why does it work like this, because if I just call the class it doesn't work. I'm learning through videos so I don't have a teacher as such to whom to ask this question, I hope I don't cause problems here by asking.
*First Form
class Coche:
# atributos o propiedades (variables)
#caracteristicas del coche
color = "Rojo"
marca = "Ferrari"
Modelo = "Aventador"
velocidad = 300
caballaje = 500
plazas = 2
# Metodos ,son acciones que hace el objeto (coche) (antes se les llamaba funcion)
def setColor(self, paletaColor): # Ademas otra funcion de self,es que basicamente te va a dejar al usarla intereactuar con lo que haya dentro de la clase
self.color = paletaColor #con este metodo yo estoy cambiando el atributo o la variable de color
def getColor(self):
return self.color #con esta funcion,o motodo,yo estoy llamando al atributo
def setModelo(self, marca):
self.Modelo = marca
def getModelo(self):
return self.Modelo
def acelerar(self): #con self entre los parametros se puede acceder a todos los atributos de una clase
self.velocidad += 1
def frenar(self):
self.velocidad -=1
def getVelocidad(self):
return self.velocidad
def getMarca(self):
return self.marca
def setMarca(self, marcaElegida):
self.marca = marcaElegida
# Fin definicion clase
print("COCHE 1: ")
Coche().acelerar()
Coche().acelerar()
Coche().acelerar()
print(Coche().velocidad)
*Second Way here is where I put the Car class inside the car variable, and if it works when executed, I want to know why the other way doesn't work
class Coche:
# atributos o propiedades (variables)
#caracteristicas del coche
color = "Rojo"
marca = "Ferrari"
Modelo = "Aventador"
velocidad = 300
caballaje = 500
plazas = 2
# Metodos ,son acciones que hace el objeto (coche) (antes se les llamaba funcion)
def setColor(self, paletaColor): # Ademas otra funcion de self,es que basicamente te va a dejar al usarla intereactuar con lo que haya dentro de la clase
self.color = paletaColor #con este metodo yo estoy cambiando el atributo o la variable de color
def getColor(self):
return self.color #con esta funcion,o motodo,yo estoy llamando al atributo
def setModelo(self, marca):
self.Modelo = marca
def getModelo(self):
return self.Modelo
def acelerar(self): #con self entre los parametros se puede acceder a todos los atributos de una clase
self.velocidad += 1
def frenar(self):
self.velocidad -=1
def getVelocidad(self):
return self.velocidad
def getMarca(self):
return self.marca
def setMarca(self, marcaElegida):
self.marca = marcaElegida
coche = Coche()
print("COCHE 1: ")
coche.acelerar()
coche.acelerar()
coche.acelerar()
print(coche.velocidad)