Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created April 24, 2019 17:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save parzibyte/3bbc2a692851a7f48ddd7bb10e3ff59a to your computer and use it in GitHub Desktop.
Save parzibyte/3bbc2a692851a7f48ddd7bb10e3ff59a to your computer and use it in GitHub Desktop.
"""
Algunos ejemplos para determinar el tipo
de una variable en Python
@author parzibyte
"""
lista = [1, 2, 3]
print("Tipo de lista es list?", type(lista) is list)
print(type([1, 2, 3]) is list) # True
print(type([1, 2, 3]) is dict) # False
print(type([1, 2, 3]) is int) # False
print(type([1, 2, 3]) is float) # False
print(type(["Part of me", "Firework", "Roar"]) is list) # True
print(type({"clave": "Valor"}) is dict) # True
print(type(1) is int) # True
print(type(1.0) is float) # True
print(type("Hola mundo") is str) # True
class Mascota:
def __init__(self, edad):
pass
mascota = Mascota(2)
print(type(mascota) is Mascota) # True
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment