Chapter 3: Problem 27
Determine the types of some objects. Consider the following calls to the makelist function from page \(96:\) \(11=\) makelist \((0,100,1)\) \(12=\) makelist \((0,100,1.0)\) \(13=\) makelist \((-1,1,0.1)\) \(14=\) makelist \((10,20,20)\) \(15=\) makelist \(([1,2],[3,4],[5])\) \(16=\) makelist \(((1,-1,1)\), ('myfile. dat', 'yourfile. dat')) \(17=\) makelist('myfile.dat', 'yourfile.dat', 'herfile.dat') Determine in each case what type of objects that become elements in the returned list and what the contents of value is after one pass in the loop. Hint: Simulate the program by hand and check out in an interactive session what type of objects that result from the arithmetics. It is only necessary to simulate one pass of the loop to answer the questions. Some of the calls will lead to infinite loops if you really execute the makelist calls on a computer. This exercise demonstrates that we can write a function and have in mind certain types of arguments, here typically int and float objects. However, the function can be used with other (originally unintended) arguments, such as lists and strings in the present case, leading to strange and irrelevant behavior (the problem here lies in the boolean expression value \(<=\) stop which is meaningless for some of the arguments).
Short Answer
Step by step solution
Key Concepts
These are the key concepts you need to understand to accurately answer the question.