print("Hello World!")
print("Hello World!") # This is a comment
# print "What will this line do?"
print("Carpe")
print("diem")
# You can separate multiple values with commas
print("Carpe", "diem")
# You can also use end="" to stay on the same line
print("Carpe ", end="")
print("diem")
x = 42
y = 99
# Place variable names in {squiggly braces} to print their values, like so:
print(f'Did you know that {x} + {y} is {x+y}?')
print("Uh oh!) # ERROR! missing close-quote
# Python output:
# SyntaxError: EOL while scanning string literal
print("We started running...")
print(1/0) # ERROR! Division by zero!
print("...we never reach this line")
# Python output:
# ZeroDivisionError: integer division or modulo by zero
print("2+2=5") # ERROR! Untrue!!!
# Python output:
# 2+2=5
name = input("Enter your name: ")
print("Your name is:", name)
x = input("Enter a number: ")
print("One half of", x, "=", x/2) # Error!
x = int(input("Enter a number: "))
print("One half of", x, "=", x/2)
print(math.factorial(20)) # we did not first import the math module
# Python output:
# NameError: name 'math' is not defined
import math
print(math.factorial(20)) # much better...
# Note that the module name is included before the function name, separated by a .
# A function called from a module like this is more precisely known as a "method."
# We'll explain functions this week, and more about methods in a future week!