{"id":743,"date":"2024-04-14T11:16:29","date_gmt":"2024-04-14T11:16:29","guid":{"rendered":"https:\/\/javigomez.org\/?p=743"},"modified":"2025-09-29T20:32:51","modified_gmt":"2025-09-29T20:32:51","slug":"06-06-python-clases-herencia","status":"publish","type":"post","link":"https:\/\/javigomez.org\/index.php\/2024\/04\/14\/06-06-python-clases-herencia\/","title":{"rendered":"06.07 Python \u2013 Clases &#8211; Herencia"},"content":{"rendered":"\n<pre class=\"wp-block-code\"><code>class Persona:\n    def __init__(self, nombre):\n        self.nombre = nombre\n\n    def hablar(self):\n        print(f\"Hola, mi nombre es {self.nombre}.\")\n\nclass Estudiante(Persona):\n    def estudiar(self):\n        print(\"Estoy estudiando\")\n\nestudiante=Estudiante(\"Javi\")\nestudiante.estudiar()\nestudiante.hablar()\n<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>class Persona:\n    def __init__(self, nombre, edad):\n        self.nombre = nombre\n        self.edad = edad\n\nclass Empleado(Persona):\n    def __init__(self, nombre, edad, sueldo):\n        super().__init__(nombre, edad)\n        self.sueldo = sueldo\n\nempleado1 = Empleado('Juan', 28, 5000)\nprint(empleado1.nombre)\nprint(empleado1.edad)\nprint(empleado1.sueldo)<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>class Persona:\n    def __init__(self, nombre):\n        self.nombre=nombre\n\n    def __str__(self):\n        return f\"Nombre: {self.nombre}\"\n\n    def padre(self):\n        print (\"PADRE\")\n\n\nclass Estudiante(Persona):\n    def __init__(self,nombre,edad):\n        super().__init__(nombre)\n        self.edad=edad\n\n    def __str__(self):\n        return f\"{super().__str__()}   Edad:{self.edad} \"\n\n    def hijo(self):\n        super().padre()\n        print(\"HIJO\")\n\n\ne=Estudiante(\"Javi\",56)\n\nprint(e)\n\ne.hijo()\n<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-4-3 wp-has-aspect-ratio\"><div class=\"wp-block-embed__wrapper\">\n<iframe loading=\"lazy\" title=\"PYTHON U06 07 Clases herencia\" width=\"1200\" height=\"900\" src=\"https:\/\/www.youtube.com\/embed\/lGIudjglyVE?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen><\/iframe>\n<\/div><\/figure>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[79,184,277],"class_list":["post-743","post","type-post","status-publish","format-standard","hentry","category-python","tag-clases","tag-herencia","tag-python"],"_links":{"self":[{"href":"https:\/\/javigomez.org\/index.php\/wp-json\/wp\/v2\/posts\/743","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/javigomez.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/javigomez.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/javigomez.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/javigomez.org\/index.php\/wp-json\/wp\/v2\/comments?post=743"}],"version-history":[{"count":1,"href":"https:\/\/javigomez.org\/index.php\/wp-json\/wp\/v2\/posts\/743\/revisions"}],"predecessor-version":[{"id":856,"href":"https:\/\/javigomez.org\/index.php\/wp-json\/wp\/v2\/posts\/743\/revisions\/856"}],"wp:attachment":[{"href":"https:\/\/javigomez.org\/index.php\/wp-json\/wp\/v2\/media?parent=743"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/javigomez.org\/index.php\/wp-json\/wp\/v2\/categories?post=743"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/javigomez.org\/index.php\/wp-json\/wp\/v2\/tags?post=743"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}