Common Computing Mistakes

Samantha doesn't care about the name of her variables after she has defined them. This often results in duplicate names in her Python code, and since Python is case sensitive, this can cause some trouble.

Tony wants to print out the full lyrics to the song "99 Bottles of Beer on the Wall," so he's written the code below. The song is supposed to involve taking down each of the 99 bottles in turn and passing them around until all the bottles have been taken down and passed around.

1
2
3
4
5
6
7
8
9

number=99whilenumber>1:# each loop prints one verse of the songprint(str(number)+" bottles of beer on the wall.")print(str(number)+" bottles of beer.")print("Take one down; pass it around.")number=number-1print(str(number)+" bottles of beer on the wall.")print(" ")

The song will have extra verses after all the bottles have been usedNothing; this will print the correct number of versesThe song will have verses missing in the middle of the songThe song runs out of verses before the bottles are all used

Xavier works at a sporting goods shop in the online sales department, and he is debugging the code below, which is designed to call the purchase_item() function several times, until all desired items have been bagged. The purchase_item() function will purchase exactly 1 item each time it is called, but will not make any changes to variables in the program.