Fiz um programa para verificar o Tipo de Dados usando o conceito de Variaveis e Type.
Assim conseguimos ver a dinamica de funcionamento da funcao type().
# PROOGRAMA TYPE()
entrada_usuario = input("Digite algo: ")
try:
# Tenta converter para booleano (para 'True' e 'False')
if entrada_usuario.lower() == 'true':
valor_convertido = True
tipo = 'bool'
elif entrada_usuario.lower() == 'false':
valor_convertido = False
tipo = 'bool'
else:
# Tenta converter para inteiro
valor_convertido = int(entrada_usuario)
tipo = 'int'
except ValueError:
try:
# Se não for int, tenta converter para float
valor_convertido = float(entrada_usuario)
tipo = 'float'
except ValueError:
# Se não for int nem float, é uma string
valor_convertido = entrada_usuario
tipo = 'str'
print(f"O valor digitado é: {valor_convertido}")
print(f"O tipo de dado é: {tipo} ({type(valor_convertido)})")