Computer Science 15-110, Spring 2011
Class Notes: Getting Started with Python
Getting Started with Python
print "Uh oh! # ERROR! missing close-quote
Python output:
SyntaxError: EOL while scanning string literal
print 1/0 # ERROR! Division by zero!
Python output:
ZeroDivisionError: integer division or modulo by zero
print "2+2=5" # ERROR! Untrue!!!
Python output:
2+2=5
print "This works just fine
print "But this example demonstrates a problem"
print "with multiline paste in the Python Shell"
print "Try pressing Up Arrow and Down Arrow a few times in the Chopin shell..."
print "This also works with Alt-P (previous) and Alt-N (next)."
print "Note that IDLE only supports Alt-P/Alt-N and not the Up/Down Arrow."
Python output:Works:
NameError: name 'math' is not defined
Python output:
2.2360679775
carpe diem - carpe diem - carpe diem - carpe diem - carpe diem - carpe diem - carpe diem - carpe diem - carpe diem