This file contains 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
# First program in Python! | |
print("Hello world!") |
This file contains 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 the turtle graphics module | |
import turtle | |
# Create a new turtle with the | |
# Turtle function of the turtle module | |
t = turtle.Turtle() | |
# 100 times... | |
for x in range(100): | |
t.forward(x) # Move forward x steps |
This file contains 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 everything in the p5.py library | |
from p5 import * | |
def draw(): | |
# On each frame... | |
if mouse_is_pressed: | |
fill(100) # Fill color gray | |
else: | |
fill(255) # Fill color white | |
This file contains 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 Bio.Seq import Seq | |
# Create sequence object | |
my_sequence = Seq("AGTACACTGGT") | |
# Show the sequence object | |
print("Sequence:", my_sequence) | |
# The sequence was created with a generic alphabet. | |
# The alphabet tells us whether it is a DNA, RNA or |
This file contains 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
""" | |
Todo buen lenguaje de programación provee de al menos: | |
- Expresiones primitivas. | |
- Formas de combinar. | |
- Formas de abstraer. | |
A continuación vemos cómo se da eso en Python | |
""" | |
# --> Expresiones primitivas: |
This file contains 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) |
This file contains 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 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 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 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.") |
OlderNewer