1.3.3 Primitive Types & Type Casting

Unit: Unit 1: Fundamentals of Python • Interactive Practice

Quick Answer & Summary:

Interactive Python programming tutorial and practice in your browser.

Interactive Challenge (Run Live in Browser):

# Type checking and explicit casting
raw_input = "45"
numeric_val = int(raw_input)
tax_rate = 0.08
total = numeric_val * (1 + tax_rate)

print("Type of raw_input:", type(raw_input).__name__)
print("Type of numeric_val:", type(numeric_val).__name__)
print("Total:", round(total, 2))
Open in Live Interactive Python Sandbox →