My finger exercise answers for Introduction to Computing and Programming using Python (Guttag, 2013)
Questions answered so far:
Finger 2.1
#Finger exercise: Write a program that examines three variables— x , y , and z — #and prints the largest odd number among them. If none of them are odd, it #should print a message to that effect.
Finger 2.4
#Finger exercise: Write a program that asks the user to input 10 integers, and #then prints the largest odd number that was entered. If no odd number was #entered, it should print a message to that effect.
Finger 3.1
#Finger exercise: Write a program that asks the user to enter an integer and #prints two integers, root and pwr , such that 0 < pwr < 6 and root**pwr is equal #to the integer entered by the user. If no such pair of integers exists, it should #print a message to that effect.
Finger 3.2
#Finger exercise: Let s be a string that contains a sequence of decimal numbers #separated by commas, e.g., s = '1.23,2.4,3.123' . Write a program that prints #the sum of the numbers in s .
Finger 3.3
#Finger exercise: What would have to be changed to make the code in Figure #3.4 work for finding an approximation to the cube root of both negative and #positive numbers? (Hint: think about changing low to ensure that the answer #lies within the region being searched.)
Finger 3.4
#Finger exercise: What is the decimal equivalent of the binary number #10011 ?
Finger 3.5
#Finger exercise: Add some code to the implementation of Newton-Raphson that #keeps track of the number of iterations used to find the root. Use that code as #part of a program that compares the efficiency of Newton-Raphson and bisection #search. (You should discover that Newton-Raphson is more efficient.)
Finger 4.1
#Finger exercise: Write a function isIn that accepts two strings as arguments #and returns True if either string occurs anywhere in the other, and False #otherwise. Hint: you might want to use the built-in str operation in .
Finger 4.3
#Finger exercise: When the implementation of fib in Figure 4.7 is used to #compute fib(5) , how many times does it compute the value fib(2) ?
Finger 7.1
#Finger exercise: Implement a function that meets the specification below. Use a try-except block.
Finger 7.2
#Finger Exercise: Implement a function that satisfies the specification