Menu iconMenu icon
Python y SQL Biblia

Capítulo 22 - Apéndice C: Hoja de trucos de Python

Sintaxis Básica de Python

  1. Función Print
print("Hello, World!")
  1. Asignación de Variables
x = 5
y = "Hello, World!"
  1. Comentarios
# This is a single line comment
"""
This is a
multi-line comment
"""
  1. Instrucciones Condicionales
if x > y:
    print("x is greater than y")
elif x < y:
    print("x is less than y")
else:
    print("x is equal to y")
  1. Bucles
for i in range(5):
    print(i)

while x < 10:
    print(x)
    x += 1
  1. Funciones
def my_function():
    print("Hello from a function")

Sintaxis Básica de Python

  1. Función Print
print("Hello, World!")
  1. Asignación de Variables
x = 5
y = "Hello, World!"
  1. Comentarios
# This is a single line comment
"""
This is a
multi-line comment
"""
  1. Instrucciones Condicionales
if x > y:
    print("x is greater than y")
elif x < y:
    print("x is less than y")
else:
    print("x is equal to y")
  1. Bucles
for i in range(5):
    print(i)

while x < 10:
    print(x)
    x += 1
  1. Funciones
def my_function():
    print("Hello from a function")

Sintaxis Básica de Python

  1. Función Print
print("Hello, World!")
  1. Asignación de Variables
x = 5
y = "Hello, World!"
  1. Comentarios
# This is a single line comment
"""
This is a
multi-line comment
"""
  1. Instrucciones Condicionales
if x > y:
    print("x is greater than y")
elif x < y:
    print("x is less than y")
else:
    print("x is equal to y")
  1. Bucles
for i in range(5):
    print(i)

while x < 10:
    print(x)
    x += 1
  1. Funciones
def my_function():
    print("Hello from a function")

Sintaxis Básica de Python

  1. Función Print
print("Hello, World!")
  1. Asignación de Variables
x = 5
y = "Hello, World!"
  1. Comentarios
# This is a single line comment
"""
This is a
multi-line comment
"""
  1. Instrucciones Condicionales
if x > y:
    print("x is greater than y")
elif x < y:
    print("x is less than y")
else:
    print("x is equal to y")
  1. Bucles
for i in range(5):
    print(i)

while x < 10:
    print(x)
    x += 1
  1. Funciones
def my_function():
    print("Hello from a function")