Python - Función Type

#48 ejemplos utilizando la función type en Python:[br][br]#1. devuelve <class 'int'>[br]print(type(5)) [br]#2. devuelve <class 'float'>[br]print(type(5.0)) [br]#3. devuelve <class 'str'>[br]print(type('Hola')) [br]print(type("Hola"))[br]#4. devuelve <class 'bool'>[br]print(type(True)) [br]#5. devuelve <class 'bool'>[br]print(type(False)) [br]#6. devuelve <class 'list'>[br]print(type([1, 2, 3])) [br]#7. devuelve <class 'tuple'>[br]print(type((1, 2, 3))) [br]#8. devuelve <class 'dict'>[br]print(type({1:'uno', 2:'dos'})[br]#9. devuelve <class 'set'> [br]print(type({1, 2, 3})) [br]#10. devuelve <class 'complex'> [br]print(type(2+3j)) [br]#11. devuelve <class 'range'>[br]print(type(range(5))) [br]#12. devuelve <class 'bytes'>[br]print(type(b'Hola'))[br]#13. devuelve <class 'bytearray'>[br]print(type(bytearray(5))) [br]#14. devuelve <class 'memoryview'>[br]print(type(memoryview(b'Hola'))) [br]print(type(memoryview(b"Hello")))[br]#15. devuelve <class 'NoneType'>[br]print(type(None)) [br]#16. devuelve <class 'builtin_function_or_method'>[br]print(type(abs)) [br]#17. devuelve <class 'builtin_function_or_method'>[br]print(type(len))[br]#18. devuelve <class 'function'>[br]print(type(lambda x: x+1)) [br]#19. devuelve <class 'generator'>[br]print(type((x for x in range(5)))) [br]#20. devuelve <class 'list_iterator'>[br]print(type(iter([1, 2, 3]))) [br]#21. devuelve <class 'type'>[br]print(type(int)) [br]#22. devuelve <class 'type'>[br]print(type(float)) [br]#23. devuelve <class 'type'>[br]print(type(str)) [br]#24. devuelve <class 'type'>[br]print(type(bool)) [br]#25. devuelve <class 'type'>[br]print(type(list)) [br]#26. devuelve <class 'type'>[br]print(type(tuple)) [br]#27. devuelve <class 'type'>[br]print(type(dict)) [br]#28. devuelve <class 'type'>[br]print(type(set)) [br]#29. devuelve <class 'type'>[br]print(type(complex))[br]#30. devuelve <class 'type'>[br]print(type(range)) [br]#31. devuelve <class 'zip'>[br]print(type(zip([1,2,3],[4,5,6]))) [br]#32. devuelve <class 'set'>[br]print(type(set([1,2,3]))) [br]#33. devuelve <class 'frozenset'>[br]print(type(frozenset([1,2,3])))[br]#34. devuelve <class 'bytes'>[br]print(type(bytes(5))) [br]#35. devuelve <class 'str'>[br]print(type(chr(65))) [br]#36. devuelve <class 'int'>[br]print(type(ord("A")))[br]#37. devuelve <class 'str'>[br]print(type(hex(255)))[br]#38. devuelve <class 'str'>[br]print(type(oct(255))) [br]#39. devuelve <class 'str'>[br]print(type(bin(255))) [br]#40. devuelve <class 'int'>[br]print(type(abs(-5))) [br]#41. devuelve <class 'int'>[br]print(type(round(5.6))) [br]#42. devuelve <class 'int'>[br]print(type(pow(2,3))) [br]#43. devuelve <class 'int'>[br]print(type(max([1,2,3]))) [br]#44. devuelve <class 'int'>[br]print(type(min([1,2,3]))) [br]#45. devuelve <class 'int'>[br]print(type(sum([1,2,3]))) [br]#46. devuelve <class 'int'>[br]print(type(len("Hola"))) [br]#47. devuelve <class 'bool'>[br]print(type(isinstance("Hola", str)))[br]#48. devuelve <class 'bool'>[br]print(type(issubclass(str, object)))
Geogebra Python

Information: Python - Función Type