Python Variables

Variables are created when you assign them a value:

x = 4 # x is of type int
x = "John Doe" # x is now of type str
Multiple String Literals

Adjacent string literals are concatenated:

SUSS1 = "Singapore University " "of " "Social Sciences"
SUSS2 = "Singapore University of Social Sciences"
# SUSS1 is equivalent to SUSS2
Assigning Multiple Variables

You can assign multiple variables in a single line:

x, y, z = "Orange", "Banana", "Cherry"
x = y = z = "Orange"

Previous     Next

Use the Search Bar to find content on MarketingMind.