print "Welcome to Python!"
# Write your code below!
my_variable = 10
# Write your code above!
print my_variable
# Set the variables to the values listed in the instructions!
my_int = 7
my_float = 1.23
my_bool = True
# Write your code above!
print my_int
print my_float
print my_bool
# 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
def spam():
eggs = 12
return eggs
print spam()
# What is the value of the mysterious_variable?
mysterious_variable = 42
"""Sipping from your cup 'til it runneth over,
Holy Grail.
"""
# Set count_to equal to the sum of two big numbers
count_to = 99 + 999
# Write code above!
print count_to
# Set eggs equal to 100 using exponentiation on line 3!
eggs = 10 ** 2
# Write your code above!
print eggs
#Set spam equal to 1 using modulo on line 3!
spam = 7 % 2
# Write your code above!
print spam
# Sonny Li
monty = True
python = 1.234
monty_python = python ** 2
- Variables, which store values for later use
- Data types, such as numbers and booleans
- Whitespace, which separates statements
- Comments, which make your code easier to read
- Arithmetic operations, including
+
, -
, *
, /
, **
, and %
# Assign the variable total on line 8!
meal = 44.50
tax = 6.75 / 100
tip = 15.0 / 100
meal = meal + meal * tax
total = meal + meal * tip
print("%.2f" % total)