'''
Created on Sep 28, 2014

@author: Susan
'''
# Question about data files
# I will not ask you to read in from a file, but
# you do need to be able to process data that I have
# already read in and put in a list. 
#
'''
If data file is:
bear,180,15
cat,52,10
dog,53,10

then you might get it as a list of strings as this:
[ "bear,180,15", "cat,52,10", "dog,53,10"]
'''


def isEven(number):
    if number % 2 == 0:
        return True
    return False
    
print isEven(42)
print isEven(41)

def isEven2(number):
    if number % 2 == 0:
        return True
    elif number %2 == 1:
        return False
    # better to say else:
    

def isSomething(number):
    if (number>3) == False and (number == 4)==False:
        print "both are false"
        
isSomething(2)

def isSomething2(number):
    if not (number>3) and not (number == 4):
        print "both are false"

isSomething2(2)


alist = ["a", "is", "the", "sun"]

# how many words in the list have the letter "s"
def howMany(alist):
    count = 0
    for word in alist:
        if word.find("s") >= 0:
            count += 1
    return count

print "How many words with s", howMany(alist)

# return 1 if there is a word with s, 0 otherwise
def isAWordWithS(alist):
    count = 0
    for word in alist:
        if word.find("s") >= 0:
            count += 1
            return count
    return count  # must be 0, not found

list1 = [55, 66]
list2 = [4, 3, 2]

print list1 + list2

newList = [ ]
print newList
for n in range(1,5):
    newList = newList + [n*3]
    print newList
    
str1 = "this is a long sentence"
print str1.split()
str2 = "Joann:Smith:45:soccer"
print str2.split(":")
print str2.split()

for ch in str1:
    print ch,ch
    
print "now with a while"

size = len(str1)
count = 0
while count < size:
    print str1[count], str1[count]
    count += 1


x = 3
if x >2:
    if x > 0:
        if x > -2:
            print "all three true"
else:
    print "not greater than 2"
# if you have one else, which if does it go with?
# in this case it goes with the first if    
    
alist = ["a", "is", "the", "sun"]

print alist[2]
print [alist[2]]
print alist[1:2]
print alist[1:1]
print alist[1:2] + ["ord-way"]




word = "hello"
# process string backwards with -1 increment
answer = ''
for ch in range(len(word)-1,-1,-1):
    answer += word[ch]
    
print answer
print range(len(word)-1,-1,-1)
    
# THIS IS NOT FOR TEST 1 - append is not on the test
list = ["this is a list"]
list.append("word")
print list