In [2]:
5
Out[2]:
5
In [4]:
5.5 + 5
Out[4]:
10.5
In [5]:
print 'hello'
hello
In [6]:
[1,2,3]
Out[6]:
[1, 2, 3]
In [7]:
['I', 'am', 'awesome']
Out[7]:
['I', 'am', 'awesome']
In [8]:
scoreboard = 0
In [9]:
goal = 3
In [10]:
scoreboard = scoreboard + goal
In [11]:
print scoreboard
3
In [13]:
age = 18
if age > 20:
    print 'welcome'
else:
    print 'get out'
get out
In [14]:
age = 18
if age > 20:
print 'welcome'
else:
    print 'get out'
IndentationError: expected an indented block
In [15]:
age = 18
if age > 20:
    print 'welcome'
else:
    print 'get out'
if age > 40:
    print 'hello, mam'
get out
In [17]:
age = 21
if age > 20:
    print 'welcome'
else:
    print 'get out'
    if age > 40:
        print 'hello, mam'
welcome
In [18]:
awesome_list = ['a', 'b', 'c']
for letter in awesome_list:
    print letter
a
b
c
In [19]:
lsdkjfsdlfkj
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-19-13d9fbedbecb> in <module>()
----> 1 lsdkjfsdlfkj

NameError: name 'lsdkjfsdlfkj' is not defined
In [20]:
alphabet = ['blah']
In [21]:
kjdkjvhkjhdsk
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-21-94a886acce59> in <module>()
----> 1 kjdkjvhkjhdsk

NameError: name 'kjdkjvhkjhdsk' is not defined
In [22]:
'I'm awesome'
  File "<ipython-input-22-9f0b3a0b5c3e>", line 1
    'I'm awesome'
       ^
SyntaxError: invalid syntax
In [23]:
{}
Out[23]:
{}
In [24]:
if age > 18:
print age
IndentationError: expected an indented block
In [25]:
age = {glen: 23, craig: 27}
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-25-d76655bae145> in <module>()
----> 1 age = {glen: 23, craig: 27}

NameError: name 'glen' is not defined
In [26]:
age = {'glen': 23, craig: 27}
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-26-27af9f251e1e> in <module>()
----> 1 age = {'glen': 23, craig: 27}

NameError: name 'craig' is not defined
In [27]:
age = {'glen': 23, 'craig': 27}
In [28]:
age['glen']
Out[28]:
23
In [29]:
age['doug']
---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
<ipython-input-29-f96932cf1b06> in <module>()
----> 1 age['doug']

KeyError: 'doug'
In [30]:
age = {'glen': 23, 'craig': 27}
print age['glen']
23
In [31]:
if age > 18:
    print age
for letter in awesome_list:
    print letter
{'glen': 23, 'craig': 27}
a
b
c
In [32]:
age = {
       'glen': 23,
       'craig': 27
}
In [33]:
age
Out[33]:
{'craig': 27, 'glen': 23}
In [34]:
numbers = [1,2,3]
print numbers[0]
1
In [35]:
print numbers[3]
---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
<ipython-input-35-10a05e7a541e> in <module>()
----> 1 print numbers[3]

IndexError: list index out of range
In [36]:
cookies = 2300
age = 23
cookies_per_year = cookies / age
In [37]:
print cookies_per_year
100
In [38]:
age = 0
In [39]:
print age
0
In [40]:
cookies_per_year = cookies / age
---------------------------------------------------------------------------
ZeroDivisionError                         Traceback (most recent call last)
<ipython-input-40-95a43ec1a79e> in <module>()
----> 1 cookies_per_year = cookies / age

ZeroDivisionError: integer division or modulo by zero
In [41]:
if age > 0:
    cookies_per_year = cookies / age
else:
    print 'must enter an age over 0, baby'l
must enter an age over 0, baby
In [42]:
if age is not 0:
    print 'yay'
In [43]:
def give_me_number():
    return 5
In [44]:
print give_me_number()
5
In [45]:
print give_me_number()
5
In [46]:
a_number = give_me_number()
In [47]:
print a_number
5
In [48]:
print give_me_number() + 5
10
In [49]:
def five():
    some_number = 5
In [50]:
print some_number
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-50-93680231c440> in <module>()
----> 1 print some_number

NameError: name 'some_number' is not defined
In [51]:
def five():
    some_number = 5
print some_number
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-51-f963ae7b5091> in <module>()
      1 def five():
      2     some_number = 5
----> 3 print some_number

NameError: name 'some_number' is not defined
In [52]:
def hi_glen():
    return 'hi glen'
In [53]:
print hi_glen()
hi glen
In [54]:
def hi(name):
    return 'hi, ' + name
In [55]:
print 'hi, ' + 'glen'
hi, glen
In [56]:
print hi('glen')
hi, glen
In [57]:
web_input_name = 'glen'
print hi(web_input_name)
hi, glen
In [58]:
print hi('adam')
hi, adam
In [59]:
print hi(5)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-59-63482630a7c0> in <module>()
----> 1 print hi(5)

<ipython-input-54-45ebdbf215f2> in hi(name)
      1 def hi(name):
----> 2     return 'hi, ' + name

TypeError: cannot concatenate 'str' and 'int' objects
In [60]:
print hi([1,2,3])
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-60-db2fc5616897> in <module>()
----> 1 print hi([1,2,3])

<ipython-input-54-45ebdbf215f2> in hi(name)
      1 def hi(name):
----> 2     return 'hi, ' + name

TypeError: cannot concatenate 'str' and 'list' objects
In [61]:
def greet(language, name):
    if language is 'english':
        return 'hi, ' + name
    if language is 'spanish':
        return 'hola, ' + name
    else:
        return 'hello, ' + name
In [62]:
user_name = 'glen'
user_language = 'english'
print greet(user_language, user_name)
hi, glen
In [63]:
print greet('spanish', 'marta')
hola, marta
In [64]:
def nothing():
    number = 5
print nothing()
None
In [65]:
None
In [66]:
def plus1(num):
	num = num + 1

number = 5
plus1(number)
print number
5
In [69]:
def plus1(num):
	num = num + 1

new_number = 5
plus1(new_number)
print new_number
5
In [70]:
def plus1(num):
	num = num + 1

number = 5
plus1(number)
print num
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-70-e002e078866e> in <module>()
      4 number = 5
      5 plus1(number)
----> 6 print num

NameError: name 'num' is not defined
In [71]:
def plus1(num):
	num = num + 1
    return num

number = 5
print plus1(number)
IndentationError: unindent does not match any outer indentation level
In [72]:
print plus1()
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-72-d54380300449> in <module>()
----> 1 print plus1()

TypeError: plus1() takes exactly 1 argument (0 given)