Skip to main content
Web Fundamentals: Assignment 1 is due at the end of week 2.
My College
On this page

Types and Variables

Learn Python's basic types, variables, and conversions.

This lesson introduces Python's type system. Replace this with your own content.

Declaring variables

A variable gets its type from the value assigned to it. A type hint after the name documents the type you expect:

Pythontypes.py
count = 0 # int
price = 9.99 # float
name = "Ada" # str
age: int = 30
ratio: float = 0.5
ready: bool = False
print(type(count), type(price), type(name))

Topics

  • Basic types
  • Variables and assignment
  • Type conversions

Last updated: