#a = [1,2,3]
#b = a
#b is a
#b == a
#b = a[:]

#b == a
#b = a[:]

"""
Explanation: wk0.1 A curious case of conditionals
Intro to git and github
Feedback form: https://docs.google.com/forms/d/1A0rjsJUUBlQTXOpHN0wGglDEG4Mte5DorovPTS_cbsI/viewform?usp=send_form
Read these:
* https://help.github.com/articles/set-up-git/
* https://www.atlassian.com/git/tutorials/syncing/git-push
A few challenges
Complete reverse_string and primes challenges in challenge folder.
Reviewing some ideas from yesterday
End of explanation
"""


4 is 2**2

"""
Explanation: While Conditional.: return discussion

Follow up on yesterday's discussion on conditionals

more on conditionals:
* is and is not
  * difference between is and ==
End of explanation
"""


# a in range(10)

assert a == 1
30 in range(10)

"""
Explanation: Try evaluating each of the lines below in your python REPL. What's going on? 
a = [1, 2, 3]
b = a
b is a
b == a
b = a[:]
b is a
b == a
If you have a hypothesis about the difference between is and ==, devise some tests you could try out to disprove your hypothesis. Implement them. Were you correct?

in and not in
End of explanation
"""


x = False
y = 0

x/y and x

"""
Explanation: and, or
End of explanation
"""


#1000 == 10**3

#1000 is 10**3

#4 is 2**2
#python stores small values,  whereas with 10**3 it has to calculate

#a = [1,2,3]
#c =[1,2,3]
#b =a
#a is c

#a[:] is not b

#for x in range(10):
#    print (x)

#10 <= x and x < 20

#x = 1.5
#if x < 10 and x > 0:
#    print ("x is between ten and zero")

#x = 'a'
#if x == 'a' or x =='b':
#    print('x is a or b')

#'a' or 'b'

2 or 3

'''x = True
y = True

not (x and y)'''

'''x = False
y = 0
x and x/y
#and requires both to be true so the error of the division by zero is superceded by the falsity of the first condition''''

"""
Explanation: comparison priority

not has the highest priority and or the lowest, so that A and not B or C is equivalent to (A and (not B)) or C.



Short circuit operators
End of explanation
"""


a = [1, 2, 3]
L = [4, 5, 6]

a[len(a):]


"""
Explanation: More string and list practice

Add elements from a list L to the end of another list at least three different ways.
End of explanation
"""


a[:4] + ['b'] + a[4:]

"""
Explanation: Insert elements into a list at least two different ways.
End of explanation
"""


str1 = "hello"
str1 = list(str1)
str1.insert(3, 'demo')
str1 = ''.join(str1)
str1

# str1 = "Hello world"
# str1 = str1[:3] + 'llllll' + str1[4:]
# str1

"""
Explanation: Insert an element into a string (this might take more than one step...).
End of explanation
"""



lst  = [1 , 2, 3, 4]
lst.remove(3)
lst

"""
Explanation: Remove an item from a list by value.
End of explanation
"""


lst.pop(0)
lst

"""
Explanation: Remove an item from a list by index.
End of explanation
"""


lst = [1, 2, 3, 4]

lst.clear()
lst

"""
Explanation: Remove all items from a list two different ways.
End of explanation
"""


lst = [1, 2, 2, 3, 4]
lst.index(2)

"""
Explanation: Return the index in the list of the first item whose value is x.
End of explanation
"""


lst.count(1)

"""
Explanation: Return the number of times x appears in the list.
End of explanation
"""


lst = [1, 2, 3]
lst.append(5)

lst

str1 ='abc'
b = list(str1).append(5)
b

"""
Explanation: Capitalize the first element in a string
End of explanation
"""


def %(duh):
    """ Append 5 to the end of the list"""
    return duh + '5'

def area(xadsf787adf, asdfjljk4):
    return xadsf787adf*asdfjljk4

foo = 7
bar = 10
area(foo, bar)

str1 = 'asdf'
#string_changer(str1)

"""
Explanation: Capitalize all elements in a string
End of explanation
"""


def namer(n, a):
    print('My name is {name} and my age is {age}'.format(age=a, name=n))
    
namer('Richie', 8)

str1.split()

"""
Explanation: Strip leading, trailing, and all whitespace (ex. leading: '  asdf  ' --> 'asdf  ', trailing:'  asdf  ' --> '  asdf', all:'   asdf   ' --> 'asdf').
End of explanation
"""


#0.
a = ['x',2,3]
b = [4,5,6]
f = a.pop()
b.append(f)
g = a.pop()
b.append(g)
h = a.pop()
b.append(h)
b


w = [1,2,3]
w.insert(3,4)
w


'Hello my name is Nick'.split()

a.index('x')

a.count('x')

'hello'.capitalize()

'hello'.upper()

a = [1,2,3]
L = [4,5,6]
a.extend(L)
a



a=[1,2,3]
L = [4,5,6]
a + L

a = [1,2,3]
L = [4,5,6]
for x in a:
    L.append(x)
print (L)

a = [1,2,3]
a.append(4)
a

a.insert(4,5)
a

#insert element into a string
str1 = 'hello'
str1 = list(str1)
str1.insert(3,'b')
str1 = ''.join(str1)
str1

str1 = 'hello world'
str1 = str1[:3] + 'llll' + str1[4:]
str1

#remove an item by value
lst = [1,2,3]
lst.remove(3)
lst

#remove an item by index
lst.pop(0)
lst

# remove all items from a list two different ways
lst = [1,2,3,4]
del lst[:]
lst

lst = [1,2,3,4]
lst.clear()
lst

#Return the index in the list of the first item whose value is x


str1 = 'abc'
b = list(str1).append(5)
b
#immutable always outputs something, mutable does not

def string_changer(duh):
    return duh + '5'

str1 = 'asdf'
string_changer(str1)

def area(w,h):
    return w*h

area(3,4)

#strip leading, trailing and all whitespace

#lstrip,rstrip,strip

str1 = '          absad          '
str1.strip()

str1 = '   asd  fw'
b = str1.split()
''.join(b)


def namer(name):
    print ('My name is {}'.format(name))

namer('Joe')

def namer(n):
    print ('My name is {name}'.format(name=n))

namer('Joe')

#Split a sentence 

str1.split(sep=None)

"""
Explanation: Split a sentence into a list of words (no whitespace), how would you split on comma or semi-colon?


Read up on how to format strings
End of explanation
"""


10 * (1/0)

4 + spam*3

'2' + 2

"""
Explanation: Intro to pins assignment

Intro to try/except and error handling
Syntax errors vs. exceptions
End of explanation
"""


while True:
    try:
        x = int(input("Please enter a number: "))
        break
    except ValueError:
        print("Oops!  That was no valid number.  Try again...")

b == a
b = a[:]

"""
Explanation: Handing exceptions
End of explanation
"""


