Thursday, June 12, 2014
Python Fundamentals II
This week's assignment involved debugging some code provided and then extending it with some directives designed to provide practice with using conditionals and loops. The first part of the output below (names listed as winning and losing) was provided with some bugs in the code to prevent it from running. These were found and fixed. The second part of the assignment involved generating a list of 20 random integers that ranged from 0 to 10, printing the result and then pruning a single integer from the generated list. The list was generated from a simple while loop (as per instructions) that appended a new random number to the list for each iteration. The break state for the loop was when a variable incremented each time reached the value of 20. Python's list functionality made manipulating the list quite easy and only took two lines of code to remove all instances of a particular integer.
Subscribe to:
Post Comments (Atom)

No comments:
Post a Comment