Tutorial 2
Problem 1.
Chapter 9, pages 86 and 87 from our online textbook
What does the following Python program do? Hand trace it in order to answer the question.
Problem 2.
Modify the Python program found in Problem 1 above such that it reads the content of the file
some_words.txt and calls the function whatDoIDo(<argument>) passing each word read
from this file as an argument.
The content of the file some_words.txt is as follows:
armour
civic
kayak
mother
politics
racecar
radiator
rotator
zoo
For each of the above word (test data), what is the expected result?
Problem 3.
Question inspired from Chapter 6, page 54 of our online textbook
Describe how we would incrementally develop a function called hypotenuse that returns the
length of the hypotenuse of a right triangle given the lengths of the other two legs as
arguments. Write the test case(s) we would use in order to test each stage of the development
process (i.e., each version of our function as we incrementally develop it).
Problem 4.
From our online textbook
A stack diagram is the diagram we produce when we box trace the execution of a function.
Problem 5.
Counting exercise: in a table, write all the binary numbers corresponding to the decimal
numbers 010 to 3210.
Problem 6.
Consider the following binary numbers. Convert each of them to its equivalent decimal number.
Let us show our work, i.e., show how we get to our answer.
a. 100100112
b. 000011002
c. 111100112
d. 010100102
e. 011101102
Problem 7.
Consider the following decimal numbers. Convert each of them to its equivalent binary number.
Let us show our work, i.e., show how we get to our answer. Pad your answer to nearest
multiple of 8-bit binary number.
a. 2810
b. 49810
c. 249810
Problem 8.
From our online textbook
版权所有:编程辅导网 2021 All Rights Reserved 联系方式:QQ:99515681 微信:codinghelp 电子信箱:99515681@qq.com
免责声明:本站部分内容从网络整理而来,只供参考!如有版权问题可联系本站删除。