-
-
Save parzibyte/3bbc2a692851a7f48ddd7bb10e3ff59a to your computer and use it in GitHub Desktop.
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
""" | |
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