Skip to content

Latest commit

 

History

History
executable file
·
69 lines (48 loc) · 1.23 KB

File metadata and controls

executable file
·
69 lines (48 loc) · 1.23 KB

Variables

Examples in Python 3

"""
Create some variables
"""

x = 42
print(x)

y = 4.2
print(y)

text = "Hello world!"
print(text)

a, b = 4, 2
print(a)
print(b)

Illegal variable naming

"""
Following examples will lead to syntax errors as the variables names are illegal
"""
# Leading numbers
5ants = "More than 4 elephants"

# Illegal characters
@nt$ = 5

# Keywords
from = "Sweden"

Reserved keywords

The following words can not be used to name variables, as they are keywords:

False      class      finally    is         return
None       continue   for        lambda     try
True       def        from       nonlocal   while
and        del        global     not        with
as         elif       if         or         yield
assert     else       import     pass
break      except     in         raise

Reference and read more

Assignment statements

Identifiers and keywords

Revision history

2014-07-16 (sylvanas) PA1 First try.