I tried my best to list the topics for the exam but I may have forgotten one or two. Your default assumption should be that if I covered it in class before files, it is fair game for the exam.
I will add practice problems as I find new interesting questions, so come back to this page every few days, more practice problems may have appeared.
If you want to see the short video I will record about the test, click here (video is now available!).
while
loop and for
loopevenize
that takes a list of numbers as input and modifies the elements of the list so that all the elements that are even are unchanged, but all odd elements are multiplied by 2.extractEvens
that takes a list of numbers as input and returns a new list that contains all the even elements of the input list in the same order in which they apppeared in the original list.myList = [5, 17, 45, 30, 29, 18] lookFor = int(input("Enter a number: ")) i = 0 while i < len(myList) and myList[i] != lookFor: i = i + 1 print(i)
for i in range(5): print("*"*i)
for i in range(5): print("{0:_>5}".format("*"*i))
myList = [1,2,3,4,5] for i in range(len(myList)): if myList[i] == 4: myList[i] = 1729 print(myList)
currentValue = 2 while currentValue < 100: print(currentValue) currentValue = 2 * currentValue + 5 print("DONE")
def printLots(n): for i in range(n): print("{0:$<5} {1:*>5} {2:!^4}".format(i, i+1, i+2))
def addToList(x,theList): for i in range(x): theList.append(x) myList = [1,2,3,4,5] addToList(6, myList) print(myList)
def doSomething(theList): newList = [] for i in range(len(theList)): newList.append(theList[i] + 5) return newList myList = [1,2,3,4,5] aList = doSometyhing(myList) print(myList, aList)
def main(): myList = [1,3,5,78,9] otherList = doSomethingElse(myList) print(otherList) def doSomethingElse(aList): for i in range(len(aList)-1): aList[i] = aList[i] + 3 # draw stack diagram here return aList * 2 if __name__ == "__main__": main()