Introduction to Computer Science Using Python: a Computational Problem-Solving Focus

Introduction to Computer Science Using Python: a Computational Problem-Solving Focus

<p> Introduction to Computer Science Using Python: A Computational Problem-Solving Focus Charles Dierbach, John Wiley and Sons (1st Edition)</p><p>Section 1.1 What is Computer Science?</p><p>True/False Questions 1. True or False? Programming defines the field of computer science.</p><p>2. True or False? A representation of a problem that includes the relevant aspects of what is being represented is known as an abstraction.</p><p>3. True or False? In order to solve a problem computationally, two things are needed: a representation that captures all the relevant aspects of the problem, and an algorithm that solves the problem by use of the representation.</p><p>4. True or False? In the Man, Cabbage, Goat and Wolf problem example, the state [W, E, W, E] indicates that the cabbage and wolf are on the east side of the river, and the man and goat are on the west side.</p><p>5. True or False? Regardless of your skills as a programmer, computing problem solving cannot be performed without the knowledge and use of computer algorithms.</p><p>6. True or False? The Traveling Salesman Problem becomes intractable using a brute-force approach for more than twenty cities.</p><p>7. True or False? There are more possible chess games that can be played than the number of grains of sand it would take to fill the universe solid.</p><p>8. True or False? Any algorithm that correctly solves a given problem must solve the problem in a reasonable amount of time; otherwise it is of limited practical use.</p><p>9. True or False? The brute force approach is one of the most widely used algorithmic programming solutions because it is such an efficient problem – solving method.</p><p>10. True or False? Any algorithm that solves a general computational problem is referred to as tractable.</p><p>Multiple Choice Questions 11. Computer science is fundamentally about (a) computational Problem Solving (b) programming (c) software engineering</p><p>Introduction to Computer Science Using Python – Dierbach Copyright 2013 John Wiley and Sons 1 Chapter 1 Test Bank Questions</p><p>12. The idea of a brute force approach can be described as (a) trying all possible solutions to a given problem (b) a computational approach that uses a great deal of memory (c) the most efficient, effective, and direct means to solve a problem</p><p>13. An algorithm is of practical use if it (a) uses the brute force approach (b) can find a solution a problem in a reasonable amount of time (c) bypasses the need for computational problem solving</p><p>Fill-in-the-Blank Questions 14. An __algorithm___ is a finite number of clearly described, unambiguous, “doable” steps that can be systematically followed to produce a desired result for given input in a finite amount of time.</p><p>Open Response Questions 15. For the Man, Cabbage, Goat, Wolf problem, assume that each state is represented by a sequence of the form [man, cabbage, goat, wolf], in which a value of 0 indicates that the item is on the east side of the river, and a value of 1 indicates that the item is on the west side. For example, [1,0,1,0] would indicate that the cabbage and wolf are on the east side of the river, and the man and goat on the west side. (a) Give a list of all the invalid states in this representation. (b) Give a sequence of states that solves the problem (assuming that all items start on the east side of the river, and the village is on the west side.) ANSWERS (a) [1,0,0,0] [0,1,1,1] [1,1,0,0] [0,0,1,1] [1,0,0,1] [0,1,1,0] (b) [0,0,0,0], [1,0,1,0], [0,0,1,0] , [1,1,1,0] , [0,1,0,0], [1,1,0,1], [0,1,0,1] , [1,1,1,1] OR [0,0,0,0], [1,0,1,0], [0,0,1,0], [1,0,1,1] , [0,0,0,1] , [1,1,0,1], [0,1,0,1] , [1,1,1,1]</p><p>Section 1.2 Computer Algorithms</p><p>True/False Questions 16. True or False? All algorithms must terminate after a finite amount of time.</p><p>17. True or False? Algorithms are general computational methods for solving specific problems.</p><p>2 Introduction to Computer Science Using Python: A Computational Problem-Solving Focus Charles Dierbach, John Wiley and Sons (1st Edition) 18. True or False? The computation that a given computer performs is only as good as the underlying algorithm used.</p><p>19. True or False? Because computers can execute instructions very quickly and reliably without error, algorithms and computers are a perfect match. Multiple Choice Questions 20. Which of these is not an algorithm? (a) A pasta recipe (b) A shopping list (c) The steps used in performing long division</p><p>21. Most algorithms require computers because (a) they would require too much time and/or detail for a person to apply (b) algorithms are only written in programming languages (c) most algorithms are simple and practical enough for computers to understand</p><p>Open Response Questions 22. For the Day of the Week algorithm given below, determine the day of the week for the following dates:</p><p>(a) September 14, 1864 (b) April 5, 1971 (c) February 21, 2004</p><p>1. Let century_digits be equal to the first two digits of the year. 2. Let year_digits be equal to the last two digits of the year. 3. Let value be equal to year_digits + floor(year_digits / 4) 4. If century_digits equals 18, then add 2 to value, else if century_digits equals 20, then add 6 to value. 5. If the month is equal to January and year is not a leap year, then add 1 to value, else, if the month is equal to February and the year is a leap year, then add 3 to value; if not a leap year, then add 4 to value, else, if the month is equal to March or November, then add 4 to value, else, if the month is equal to April or July, then add 0 to value, else, if the month is equal to May, then add 2 to value, else, if the month is equal to June, then add 5 to value, else, if the month is equal to August, then add 3 to value, else, if the month is equal to October, then add 1 to value, else, if the month is equal to September or December, then add 6 to value,</p><p>Introduction to Computer Science Using Python – Dierbach Copyright 2013 John Wiley and Sons 3 Chapter 1 Test Bank Questions</p><p>6. Set value equal to (value + day) mod 7 7. If value is equal to 1, then the day of the week is Sunday; else if value is equal to 2, day of the week is Monday; else if value is equal to 3, day of the week is Tuesday; else if value is equal to 4, day of the week is Wednesday; else if value is equal to 5, day of the week is Thursday; else if value is equal to 6, day of the week is Friday; else if value is equal to 0, day of the week is Saturday Section 1.3 Computer Hardware</p><p>True/False Questions 23. True or False? The more voltage levels that the hardware is able to utilize and distinguish, the more reliable the hardware design becomes.</p><p>24. True or False? All of the information in a computer system is represented using digits 0-9.</p><p>25. True or False? Digital computers are designed to either use binary values 0,1.</p><p>26. True or False? In binary representation, each digit represents either the value -1, 0, or 1.</p><p>27. True or False? A transistor is an electronic switch that can switch at very high speed.</p><p>28. True or False? Integrated circuits, the building blocks of computer hardware, are made up millions or even billions of transistors.</p><p>29. True or False? The decimal value of the binary number 1001 is 9.</p><p>30. True or False? The binary number 1000 is larger than binary number 0111.</p><p>31. True or False? The number following binary number 1011 is 1100.</p><p>32. True or False? The term “bit” stands for binary digit.</p><p>33. True or False? A byte is a group of (usually) eight bits.</p><p>34. True or False? The algorithm for converting a number in base 10 to base 2 is to successively divide the number by ten until the remainder becomes 0.</p><p>35. True or False? The fundamental hardware components of computer system are the central processing unit (CPU), main memory, volatile memory, input/output devices, and buses.</p><p>36. True or False? Main memory is volatile, meaning that its contents are retained only when power is supplied. </p><p>37. True or False? A Central Processing Unit is designed to execute instructions written as a sequence of bits.</p><p>38. True or False? A flash (USB) drive is an example of a device containing nonvolatile memory.</p><p>4 Introduction to Computer Science Using Python: A Computational Problem-Solving Focus Charles Dierbach, John Wiley and Sons (1st Edition) 39. True or False? Buses provide communication between hardware components.</p><p>40. True or False? An operating system is the part of the hardware that controls all the other hardware components of a computer system.</p><p>41. True or False? An operating system is an example of system software.</p><p>42. True or False? An operating system is what determines the look and feel of a given computer system, not the particular hardware components of the system.</p><p>43. True or False? Moore’s Law states that the number of transistors that can be put on a silicon chip doubles roughly every two years, first predicted in 1980. Multiple Choice Questions 44. Computer hardware comprises (a) applications and programs used by your computer (b) files stored on your computer (c) the physical parts of a computer system</p><p>45. All information within a computer system is represented by the use of (a) graphs, charts, numbers, and complex algorithmic languages (b) only two digits, 0 and 1 (c) sixteen digits, 0 – 9 and A – F known as hexadecimal representation</p><p>46. The term bit stands for (a) beta digit (b) binary digit (c) binary integrated transistor</p><p>47. Although values represented in base 2 are significantly longer than those represented in base 10, binary representation is used in digital computing because (a) it’s impossible to design a switch with more than two options (b) of the resulting simplicity of hardware design (c) early technology wasn’t advanced enough to utilize binary representation</p><p>48. An operating system (a) is software that manage the hardware of a computer and provides a user interface (b) converts binary data to hexadecimal data for the computer to understand</p><p>Fill-in-the-Blank Questions</p><p>Introduction to Computer Science Using Python – Dierbach Copyright 2013 John Wiley and Sons 5 Chapter 1 Test Bank Questions</p><p>49. We are used to representing numbers in a decimal system, that is, in base __ten___.</p><p>50. Any information can be represented by use of only __two____ symbols.</p><p>51. 10011 is a binary number. The number that it translates to in the decimal system that we are used to is __19___.</p><p>52. A byte usually consists of __eight__ bits.</p><p>53. The prediction that the number of transistors that would be able to be put on a silicon chip would double roughly every two years is known as _Moore’s Law__.</p><p>6 Introduction to Computer Science Using Python: A Computational Problem-Solving Focus Charles Dierbach, John Wiley and Sons (1st Edition)</p><p>Open Response Questions 54. Convert the following binary numbers to base ten.</p><p>(a) 1010 (b) 10000 (c) 1111 (d) 1111111 (e) 10000001 (a) 10 (b) 16 (c) 15 (d) 127 (e) 129</p><p>55. Show all steps for converting the following base ten values into binary (base 2) representation. (a) 11 (b) 25 (c) 47 </p><p>ANSWERS (a) 11 / 2  5, with remainder 1 5 / 2  2, with remainder 1 2/2  1, with remainder 0 1/2  0, with remainder 1 Thus, 11 = 1011 (base 2)</p><p>(b) 25 / 2  12, with remainder 1 12 / 2  6, with remainder 0 6/2  3, with remainder 0 3/2  1, with remainder 1 1/2  0, with remainder 1 Thus, 25 = 11001 (base 2)</p><p>(c) 47 / 2  23, with remainder 1 23 / 2  11, with remainder 1 11/2  5, with remainder 1 5/2  2, with remainder 1 2/2  1, with remainder 0 1/2  0, with remainder 1 Thus, 47 = 101111 (base 2)</p><p>Introduction to Computer Science Using Python – Dierbach Copyright 2013 John Wiley and Sons 7 Chapter 1 Test Bank Questions</p><p>Section 1.4 Computer Software</p><p>True/False Questions 56. True or False? Charles Babbage is considered the first computer programmer.</p><p>57. True or False? While system software is intrinsic to a computer system, application software serves the particular needs of the user.</p><p>58. True or False? The statement “Hear are the results.” contains a semantic error.</p><p>59. True or False? Programming languages are artificial languages, and therefore do not have a clear set of rules of syntax.</p><p>60. True or False? Most programs are written in machine code because this is the only thing the CPU can process.</p><p>61. True or False? Python is a “high level” programming language?</p><p>62. True or False? Compiled programs generally execute faster than interpreted programs.</p><p>63. True or False? Computers do not understand what a program is meant to do, they only follow given instructions.</p><p>64. True or False? Program debugging is a small part of program development.</p><p>65. True or False? Syntax errors are generally easier to find than logic (semantic) errors.</p><p>66. True or False? The two major programming paradigms in use today are imperative programming and object-oriented programming.</p><p>Multiple Choice Questions 67. A photo editing program is an example of (a) system software (b) application software (c) security software (d) none of the above</p><p>68. “Hello there, how are you?” is an example of an English sentence that is (a) syntactically correct (b) semantically incorrect (c) both of the above</p><p>69. “Colorless green ideas sleep furiously” is an example of an English sentence that is (a) syntactically correct</p><p>8 Introduction to Computer Science Using Python: A Computational Problem-Solving Focus Charles Dierbach, John Wiley and Sons (1st Edition) (b) semantically correct (c) neither the above Fill-in-the-Blank Questions 70. The Central Processing Unit can only run programs written in __machine code____.</p><p>71. The two major programming paradigms in use today are __imperative__ programming and ___object-oriented___ programming.</p><p>Open Response Questions 72. For each of the following, indicate whether it contains a syntax error, a semantic (logic) error, or has no syntax or semantic errors. (a) n1 = 10 n2 = 20 print('The sum of n1 + n2 is', n2)</p><p>Semantic (logic) error: print('The sum of n1 + n2 is', n1 + n2)</p><p>(b) n1 = 5 n2 = 10 n3 = 20 result = n1(n2 + n3) print('Result =', result)</p><p>Syntax error: n1(n2 + n3) should be n1 * (n2 + n3)</p><p>(c) firstname = input('Please enter your first name: ') lastname = input('Please enter your last name: ') print('Hello', firstname, lastname)</p><p>No errors (syntactically and semantically correct)</p><p>Section 1.5 The Process of Computational Problem Solving</p><p>True/False Questions 73. True or False? A brute force approach to computational problem solving is never tractable.</p><p>74. True or False? Every computational problem has an infinite number of solutions.</p><p>75. True or False? There is only one best solution for any given computational problem.</p><p>76. True or False? The best representation of the data in a given program is the one that is most intuitive and understandable by other programmers.</p><p>Introduction to Computer Science Using Python – Dierbach Copyright 2013 John Wiley and Sons 9 Chapter 1 Test Bank Questions</p><p>77. True or False? Algorithms that work well in general, but not necessarily for every problem instance, are called probabilistic algorithms.</p><p>78. True or False? Any changes made in correcting a program error should be fully understood as to why the changes correct the detected error. Multiple Choice Questions 79. Software testing is a crucial part of software development. Testing is done (a) incrementally as the program is being developed (b) when the program is complete (c) when the program needs to be updated (d) all of the above</p><p>80. A program is generally designed to solve a problem. For each problem, there may be: (a) only one solution (b) only an approximate solution (c) a best solution (d) numerous solutions (e) any of the above</p><p>Open Response Questions 81. Give the four fundamental steps of computational problem solving described in chapter 1. ANSWER: Analysis, Design, Implementation, Testing</p><p>Section 1.6 The Python Programming Language</p><p>True/False Question 82. True or False? Guido van Rossum is the created of the Python programming language.</p><p>83. True or False? IDLE is the integrated development environment (IDE) bundled with the Python programming language.</p><p>84. True or False? The Python Standard Library is a collection of example Python programs.</p><p>85. True or False? The values of the arithmetic expression 2 * (2 ** 3) in Python is 16.</p><p>86. True or False? The following expressions 4(2 + 6) and 4*(2 + 6) are equivalent in Python.</p><p>87. True or False? The input function in Python both displays output on the screen and gets input from the user.</p><p>Multiple Choice Questions 88. Python is most commonly translated by use of an</p><p>10 Introduction to Computer Science Using Python: A Computational Problem-Solving Focus Charles Dierbach, John Wiley and Sons (1st Edition) (a) interpreter (b) compiler (c) executer</p><p>89. Characters within quotes, such as ‘Hello World!’, are called (a) buffers (b) textlines (c) strings 90. For the following lines of Python code, assuming that the user enters “Charles” when prompted for their name, what would the output be? name = input(‘What is your name? ‘) print(‘Hello’, name)</p><p>(a) Hello, Charles (b) Hello, Charles (c) Hello, Charles!</p><p>Fill-in-the-Blank Questions 91. “A name that is assigned to a value” is a simple description of what fundamental programming concept? ___a variable___</p><p>Open Response Questions 92. Give the value of each of the following in Python. (a) 4 * 3 (b) (4 * 5) + 12 (c) (6 + 9) / 10 (d) 2 ** 4 (a) 12 (b) 32 (c) 1.5 (d) 16</p><p>93. What is displayed by the following Python code? (a) n = 20 print('n = ', n) Displays on screen: n = 20</p><p>(b) n = 20 k = n + 10 print('k = ', n) Displays on screen: k = 30</p><p>(c) n = 20 k = 10 print('n + k = ', n + k) Displays on screen: n + k = 30</p><p>Introduction to Computer Science Using Python – Dierbach Copyright 2013 John Wiley and Sons 11 Chapter 1 Test Bank Questions</p><p>94. What is displayed by the following Python code? Assume that the user enters Crystal for each of the following user prompts. (a) name = input('What is your name? ') print('Hello', name) Displays on screen: Hello Crystal (a) name = input('What is your name? ') print('Hello,', name, 'is a nice name')</p><p>Displays on screen: Hello, Crystal is a nice name</p><p>12</p>

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    12 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us