This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Generic recursive tree reduce algorithm | |
======================================= | |
Trees are one of the most ubiquitous data structures. It is amazing how often we | |
as programmers tend to reimplement the same algorithms for different trees. | |
This module defines a generic tree-reduce algorithms that can be | |
used with any tree-like object such as filesystem paths, lists, nested | |
dictionaries an expression tree or even specialized tree classes! The only thing |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Generic tree utilities for Python | |
================================= | |
Trees are one of the most ubiquitous data structures. It is amazing how often we | |
as programmers tend to reimplement the same algorithms for different trees. | |
This module defines generic tree-traverse and tree-reduce algorithms that can be | |
used with any tree-like object such as filesystem paths, lists, nested | |
dictionaries, expression trees or even specialized tree classes! The only thing |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
A simple function `parse_newick` to parse tree structures specified in the | |
Newick format (NHX supported). The function allows to customize the final | |
representation, be it lists, dicts or a custom Tree class. | |
Usage | |
----- | |
``` | |
def tree_as_dict(label, children, distance, features): | |
if children: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from turtle import Turtle | |
squirtle = Turtle() | |
def izquierda(pasos): | |
squirtle.left(90) | |
squirtle.forward(pasos) | |
def derecha(pasos): | |
squirtle.right(90) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
edad = int(input("Cuántos años tienes?")) | |
if edad > 65: | |
print("Ya te jubilaste?") | |
if edad > 21: | |
print("Ya eres un adulto.") | |
if edad > 13: | |
print("Eres todo un joven adolescente.") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
edad = int(input("Cuántos años tienes?")) | |
if edad > 65: | |
print("Ya te jubilaste?") | |
elif tu_edad > 21: | |
print("Ya eres un adulto.") | |
elif edad > 13: | |
print("Eres todo un joven adolescente.") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
edad = int(input("Cuántos años tienes?") | |
if edad > 65: | |
print("Ya te jubilaste?") | |
elif edad > 21: | |
print("Ya eres un adulto.") | |
elif edad > 13: | |
print("Eres todo un joven adolescente.") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import turtle | |
squirtle = turtle.Turtle() | |
# Los colores que usaremos | |
colors = ["red", "yellow", "blue", "orange", "green", "purple"] | |
n_colors = len(colors) | |
for i in range(100): | |
# Obtén el índice del color |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import turtle | |
import random | |
squirtle = turtle.Turtle() | |
for i in range(100): | |
# Haz un giro aleatorio | |
coin = random.choice([True, False]) | |
angle = random.randint(0, 360) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from turtle import Turtle | |
gamera = Turtle() | |
# Podríamos hacer muchas cosas padres con sólo repetir: | |
gamera.forward(50) | |
gamera.left(30) | |
gamera.forward(50) | |
gamera.left(30) | |
gamera.forward(50) |
NewerOlder