Python Syntax

Lesson 01/13 – Welcome!

 
print "Welcome to Python!"

Lesson 02/13 – Variables

 
# Write your code below!
my_variable = 10

Lesson 03/13 – Booleans

 
# Set the variables to the values listed in the instructions!
my_int = 7
my_float = 1.23
my_bool = True

Lesson 04/13 – You’ve Been Reassigned

 
# my_int is set to 7 below. What do you think
# will happen if we reset it to 3 and print the result?

my_int = 7

# Change the value of my_int to 3 on line 8!

my_int = 3

# Here's some code that will print my_int to the console:
# The print keyword will be covered in detail soon!

print my_int

Lesson 05/13 – Whitespace

 
def spam():
eggs = 12
return eggs
        
print spam()

Lesson 06/13 – Whitespace Means Right Space

 
def spam():
    eggs = 12
    return eggs
        
print spam()

Lesson 07/13 – A Matter of Interpretation

 
spam = True
eggs = False

Lesson 08/13 – Single Line Comments

 
#this is a comment

mysterious_variable = 42

Lesson 09/13 – Multi-Line Comments

 
"""Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce arcu arcu, vehicula id urna eget, mollis ullamcorper eros. Nullam felis risus, iaculis sed ipsum quis, interdum mollis lacus. Phasellus efficitur magna commodo augue porta, ac sodales magna tempus. Sed mollis sagittis lacus, vel sodales dolor blandit eu. Quisque eu ex lorem. Duis sit amet leo eu sapien porta molestie. Praesent sed tristique diam. Maecenas venenatis, enim nec molestie imperdiet, lacus urna condimentum ex, sit amet posuere eros tellus pharetra sapien. Phasellus nec felis pretium, hendrerit magna ac, dignissim nibh. Sed nec cursus dui. Nunc ac justo accumsan, tristique tortor vitae, suscipit velit. In rutrum, mauris non fermentum semper, lectus risus blandit dolor, quis iaculis justo tellus id nulla. Nam malesuada pellentesque leo, eu sollicitudin eros vestibulum at. Curabitur sit amet luctus eros, eu dapibus magna.
"""

Lesson 10/13 – Math

 
# Set count_to equal to the sum of two big numbers
count_to = 1234 + 1234


print count_to

Lesson 11/13 – Exponentiation

 
#Set eggs equal to 100 using exponentiation on line 3!

eggs = 100 ** 1

print eggs

Lesson 12/13 – Modulo

 
#Set spam equal to 1 using modulo on line 3!

spam = 5 % 4

print spam

Lesson 13/13 – Bringing It All Together

 
#this is a comment
monty = True
python = 1.234
monty_python = python ** 2