# Homework 2-2 Starter Code. # Your name here: # Task 2: Gauss' Method maxVal = 100 # Question 1: Write the loop that will add up all the numbers from 1 to maxVal # in the conventional way # Print out the answer (nicely!) # Question 2: Write the loop that will add up all the odd numbers from 1 to maxVal # Print out the answer! # Task 3: word = "hi" myList = ["hello", "hi", "ni hao", "annyong", "bonjour", "ciao"] # Question 1 found = False # Write your loop to check whether word is in myList # Print out the answer # This will help you to check whether you got the right answer if word in myList: print("The word", word, "was found in", myList) # Question 2 foundIndex = -1 i = 0 # Write your loop here. ## Go through each item in myList in turn ## Check to see whether the item matches word ## If so, set foundIndex to i ## Add one to i and repeat # Print out the value of foundIndex # This will help you to check whether you got the right answer. # Note: if word is not found, this method will return an error. # That's ok. It's not your fault. We don't like Python's way of handling this, either. print("The index of", word, "in", myList, "is", myList.index(word))