#!/usr/bin/python3 # -*- coding: utf-8 -*- """ Basic variables and types """ thisisanint = 1 print(type(thisisanint)) # This is the same, but with a nice hint: thisisanintwithatypehint: int = 2 print(type(thisisanintwithatypehint)) thisisastring = "hey" print(type(thisisastring)) # This is the same, but with a nice hint: thisisastringwithatypehint: str = "hey" print(type(thisisastringwithatypehint)) # what is the value now? # You don't need the hints on re-assignment thisisanint = 4 print(type(thisisanint)) # What is the value now? thisisanint = thisisanintwithatypehint print(type(thisisanint)) # what is the string now? thisisastring = "anotherstring" print(type(thisisastring)) # what is the string now? thisisastring = thisisastringwithatypehint print(type(thisisastring)) # what happens here? thisisanint = thisisastring print(type(thisisanint)) # Python is dynamically typed! # The : type hints above are just comments, # but they can be checked by an optional pre-processor: # $ mypy --strict --disallow-any-explicit 01_variables.py