Created
November 2, 2021 15:33
-
-
Save jmlon/ec7c7639e6c8f3a5ded29e64a5850322 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
# Tipos de datos | |
# Definir algunas variables de varios tipos | |
a = 123 | |
b = 4.56 | |
c = 'Hola Mundo' | |
d = [ 1,2,3.33 ] | |
e = ( 1,2,3.33 ) | |
f = { 'a':1, 'b':2 } | |
g = True | |
h = 1+2j | |
i1 = set([1, 2, 3]) | |
i2 = {1,2,3} | |
# Mostrar el tipo de dato de las variables | |
print(type(a)) | |
print(type(b)) | |
print(type(c)) | |
print(type(d)) | |
print(type(e)) | |
print(type(f)) | |
print(type(g)) | |
print(type(h)) | |
print(type(i1), type(i2)) | |
# Comprobar el tipo de dato de las variables | |
assert type(a)==int | |
assert type(b)==float | |
assert type(c)==str | |
assert type(d)==list | |
assert type(e)==tuple | |
assert type(f)==dict | |
assert type(g)==bool | |
assert type(h)==complex | |
assert type(i1)==set | |
# Referencia | |
# https://docs.python.org/3/reference/datamodel.html#objects-values-and-types | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment