Test Bank for Prelude to Programming Chapter 3

Similar documents
Name: Class: Date: 9. The compiler ignores all comments they are there strictly for the convenience of anyone reading the program.

9 Control Statements. 9.1 Introduction. 9.2 Objectives. 9.3 Statements

Solving Rational Equations

Mean, Median, Standard Deviation Prof. McGahagan Stat 1040

Exercise 1: Python Language Basics

Visual Logic Instructions and Assignments

Zero: If P is a polynomial and if c is a number such that P (c) = 0 then c is a zero of P.

Properties of Real Numbers

2.5 Zeros of a Polynomial Functions

1 Description of The Simpletron

Introducing Programming using TI-Nspire Stephen Arnold, T 3 Australia

Binary Adders: Half Adders and Full Adders

Welcome to Basic Math Skills!

Supplemental Worksheet Problems To Accompany: The Pre-Algebra Tutor: Volume 1 Section 1 Real Numbers

Chapter 14: Boolean Expressions Bradley Kjell (Revised 10/08/08)

The Answer to the 14 Most Frequently Asked Modbus Questions

3.1. RATIONAL EXPRESSIONS

1. Building Testing Environment

Using Casio Graphics Calculators

Question 1a of 14 ( 2 Identifying the roots of a polynomial and their importance )

AP Computer Science Java Mr. Clausen Program 9A, 9B

Chapter 11 Number Theory

MATLAB Programming. Problem 1: Sequential

26 Integers: Multiplication, Division, and Order

How to test and debug an ASP.NET application

EQUATIONS and INEQUALITIES

CHAPTER 3. Methods of Proofs. 1. Logical Arguments and Formal Proofs

Government Girls Polytechnic, Bilaspur

El Dorado Union High School District Educational Services

What is a Loop? Pretest Loops in C++ Types of Loop Testing. Count-controlled loops. Loops can be...

POLYNOMIAL FUNCTIONS

1. a procedure that you perform frequently. 2. Create a command. 3. Create a new. 4. Create custom for Excel.

Recurring Work Orders - Overview. Purpose. Generating Tasks

The Prime Numbers. Definition. A prime number is a positive integer with exactly two positive divisors.

The Factor Theorem and a corollary of the Fundamental Theorem of Algebra

Unix Scripts and Job Scheduling

Session 29 Scientific Notation and Laws of Exponents. If you have ever taken a Chemistry class, you may have encountered the following numbers:

Handout #1: Mathematical Reasoning

Chapter 8 Selection 8-1

PART A: For each worker, determine that worker's marginal product of labor.

Discrete Mathematics and Probability Theory Fall 2009 Satish Rao, David Tse Note 2

How to Create User-Defined Fields and Tables

Section 1.1 Linear Equations: Slope and Equations of Lines

PART-A Questions. 2. How does an enumerated statement differ from a typedef statement?

J a v a Quiz (Unit 3, Test 0 Practice)

Chapter 7: Additional Topics

Electric Landing Gear controllers and sequencer LGC12 / LGC 13C

Expense Management. Configuration and Use of the Expense Management Module of Xpert.NET

SQL - QUICK GUIDE. Allows users to access data in relational database management systems.

There are a number of superb online resources as well that provide excellent blackjack information as well. We recommend the following web sites:

Introduction to LogixPro - Lab

A.2. Exponents and Radicals. Integer Exponents. What you should learn. Exponential Notation. Why you should learn it. Properties of Exponents

Selection: Boolean Expressions (2) Precedence chart:

Session 6 Number Theory

Excel & Visual Basic for Applications (VBA)

ALGORITHMS AND FLOWCHARTS

COWLEY COUNTY COMMUNITY COLLEGE REVIEW GUIDE Compass Algebra Level 2

ML for the Working Programmer

An Integer Square Root Algorithm

hp calculators HP 17bII+ Net Present Value and Internal Rate of Return Cash Flow Zero A Series of Cash Flows What Net Present Value Is

Task Scheduler. Morgan N. Sandquist Developer: Gary Meyer Reviewer: Lauri Watts

Vieta s Formulas and the Identity Theorem

MULTIPLE CHOICE. Choose the one alternative that best completes the statement or answers the question.

A LEVEL H446 COMPUTER SCIENCE. Code Challenges (1 20) August 2015

Paper Creating Variables: Traps and Pitfalls Olena Galligan, Clinops LLC, San Francisco, CA

MATH10040 Chapter 2: Prime and relatively prime numbers

VHDL Test Bench Tutorial

Logging and SNMP Trap Notification Of Events. Isonas Access Control System. Release 12 June 2007

The Point-Slope Form

Test Generator. Creating Tests

SOME EXCEL FORMULAS AND FUNCTIONS

Chapter 2: Algorithm Discovery and Design. Invitation to Computer Science, C++ Version, Third Edition

Negative Integral Exponents. If x is nonzero, the reciprocal of x is written as 1 x. For example, the reciprocal of 23 is written as 2

10 Listing data and basic command syntax

Math 3000 Section 003 Intro to Abstract Math Homework 2

Objective. Materials. TI-73 Calculator

Keywords are identifiers having predefined meanings in C programming language. The list of keywords used in standard C are : unsigned void

Elementary Number Theory and Methods of Proof. CSE 215, Foundations of Computer Science Stony Brook University

Six-servo Robot Arm. DAGU Hi-Tech Electronic Co., LTD Six-servo Robot Arm

Divide: Paper & Pencil. Computer Architecture ALU Design : Division and Floating Point. Divide algorithm. DIVIDE HARDWARE Version 1

Data Preparation in SPSS

Calculator. Introduction. Requirements. Design. The calculator control system. F. Wagner August 2009

Classes and Objects in Java Constructors. In creating objects of the type Fraction, we have used statements similar to the following:

TRICKS AND TRAPS PRESENTATION

The Deadly Sins of Algebra

How do you compare numbers? On a number line, larger numbers are to the right and smaller numbers are to the left.

ExamView Dynamic Questions Training Guide for PC and Mac Users

Siemens S7 Status Word

LESSON 4 Missing Numbers in Multiplication Missing Numbers in Division LESSON 5 Order of Operations, Part 1 LESSON 6 Fractional Parts LESSON 7 Lines,

MAT 2170: Laboratory 3

Q&As: Microsoft Excel 2013: Chapter 2

One Dimension Array: Declaring a fixed-array, if array-name is the name of an array

CNCTRAIN OVERVIEW CNC Simulation Systems

Windows PowerShell Essentials

Cartesian Products and Relations

Previously, you learned the names of the parts of a multiplication problem. 1. a. 6 2 = 12 6 and 2 are the. b. 12 is the

Lies My Calculator and Computer Told Me

Using Parametric Equations in SolidWorks, Example 1

3.2. Solving quadratic equations. Introduction. Prerequisites. Learning Outcomes. Learning Style

Introduction to Java. CS 3: Computer Programming in Java

Transcription:

Test Bank for Prelude to Programming Chapter 3 MULTIPLE CHOICE 1. Which of the following is not a type of selection structure? a. single-alternative b. dual-alternative c. multiple-alternative d. Case or switch e. all of the above are types of selection structures ANS: E 2. Given the following program segment, what is the test condition? 1. Input Answer 2. If Answer = No Then 3. Write Try Again 4. Input Answer 5. 6. Write Are you having fun yet? (Y/N) 7. Input Response a. Answer b. Answer = No c. Response d. Response = Y 3. Given the following program segment, if the user inputs Hooray! on Line 1, what is the next line to be executed? 1. Input Answer 2. If Answer = No Then 3. Write Try Again 4. Input Answer 5. 6. Write Are you having fun yet? 7. Input Response a. Line 2 b. Line 3 c. Line 5 d. Line 6 ANS: A 2007 Pearson Education 1

4. What is the output of code corresponding to the following program segment if Age = 18? If Age >= 18 Then Write You are eligible to vote. Set Vote = Age - 18 Write You can vote in, Vote, years. a. You are eligible to vote. b. You can vote in 18 years. c. You are eligible to vote. You can vote in 18 years. d. You can vote in 0 years. ANS: A 5. If MyName = Bunny and YourName = Buddy, which of the following is not true? a. MyName > YourName b. MyName <= YourName c. MyName >= YourName d. YourName > MyName 6. If X = True and Y = False, which of the following will give a result of True? a. X AND Y b. X OR Y c. NOT X OR Y d. NOT X AND NOT Y 7. If X = 2, Y = 4, and Z = 6, which of the following will give a result of False? a. (X < Y) AND (Y < Z) b. (Y > X) AND (Z > X) c. (X > Y * Z) OR (X * Y > Z) d. (X > Y * Z) OR (Z > X * Y) ANS: D 2007 Pearson Education 2

8. Given that Jamie worked 50 hours (Hours = 50) last week and earns $10.00 an hour (Rate = 10), how much did Jamie earn last week, before taxes (TotalPay)? If (Rate >=10) OR (Hours <=40) Then TotalPay = Hours * Rate TotalPay = (Hours * Rate)+(Hours 40)*Rate*1.5 a. $ 500 b. $ 650 c. $ 750 d. $ 400 ANS: A 9. Given that Marcy worked 42 hours (Hours = 42) last week and earns $10.00 an hour (Rate = 10), how much did Jamie earn last week, before taxes (TotalPay)? If (Rate >=10) AND (Hours <=40) Then TotalPay = Hours * Rate TotalPay = (40 * Rate)+(Hours 40) * Rate * 1.5 a. $ 500 b. $ 420 c. $ 430 d. $ 650 ANS: C 10. Given that the user input for Response is Open Sesame and Guess = Open Sesame, what would be displayed if code corresponding to the following program segment were run? Input Response Select Case Of Response Case: new Write You re a newbie Case: 23 Write You re Number 23 Case: Guess Write The door to Sesame Street is open! Default Write Huh? End Case a. You re a newbie b. You re Number 23 c. The door to Sesame Street is open! 2007 Pearson Education 3

d. Huh? e. Nothing would be displayed since Response is not one of the conditions in the Case statement. ANS: C 11. The term defensive programming refers to all of the following except: a. ensuring that a division by zero does not take place b. ensuring that input data is within the proper range c. ensuring that there are no compound conditions in a selection structure d. ensuring that a negative number is not input to the Sqrt function ANS: C 12. A multiple-alternative structure cannot be implemented by using which of the following: a. a single If-Then statement b. several If-Then statements c. several If-Then- statements d. a single Case statement ANS: A 13. Given the following program, choose the line necessary to replace the XXXX s so that the program segment will ensure that an illegal operation does not occur. Write Enter a number: Write This program will display the square root Write of your number. Input MyNumber XXXXXXXXXXXXXXXXXX Write The square root of, MyNumber Write is:, Sqrt(MyNumber) Write Illegal operation! a. If MyNumber < 0 b. If MyNumber <= 0 c. If MyNumber >= 0 d. If MyNumber <> 0 ANS: C 14. Which of the following will test to make sure the number entered by the user into the variable named InRange is between 5 and 50? a. If (InRange > 5) AND (InRange < 50) Then b. If (InRange >= 5) AND (InRange <= 50) Then 2007 Pearson Education 4

c. If (InRange > 5) OR (InRange < 50) Then d. If (InRange >= 5) OR (InRange <= 50) Then 15. Which of the following program segments is equivalent to the program segment given below? If Pay >= 500 Then TaxRate =.3 If (Pay >= 300) AND (Pay < 500) Then TaxRate =.2 If (Pay >= 100) AND (Pay < 300) Then TaxRate =.1 a. If Pay > 100 Then TaxRate =.1 If Pay > 300 Then TaxRate =.2 If Pay > 500 Then TaxRate =.3 b. If Pay >= 500 Then TaxRate =.3 If Pay >= 300 TaxRate =.2 TaxRate =.1 c. If Pay >= 500 Then TaxRate =.3 TaxRate =.2 If Pay > 100 Then TaxRate =.1 d. none of the above are equivalent to the given example 2007 Pearson Education 5

TRUE/FALSE 1. True/False: A single-alternative selection structure always contains an clause. 2. True/False: The assignment operator and the comparison operator are the same. 3. True/False: The statement Set Cost = Price + Tax is an example of a comparison statement. 4. True/False: The statement 15 >= -63 will result in the value True. 5. True/False: If X = False and Y = False, is the statement NOT X OR NOT Y true or false? 6. True/False: Suppose MyNumber = 6. Is the following expression True or False? (2 * MyNumber 4 > 6 ) AND (MyNumber < 10) 7. True/False: If A = 20 and B = 15, then both of the following statements are True: A > B and B <= A 8. True/False: The type of operators that are evaluated second in the hierarchy of order of operations are logical operators. 9. True/False: The Case statement can only be used to compare numeric data. 10. True/False: The integer 16 does not have a reciprocal. 11. True/False: If a division operation is performed in a program and the divisor is 0, execution will halt and an error message will be displayed. 12. True/False: Defensive programming includes checking for the illegal operation of trying to take the square root of zero. 13. True/False: A program that uses menus instead of requiring the user to memorize commands is often known as a menu-driven program. 2007 Pearson Education 6

14. True/False: If A = 9, then Sqrt(A * A) = 3. 15. True/False: In a menu-driven program, the options on the main module usually correspond to separate program modules. SHORT ANSWER 1. A selection structure consists of a(n) together with one or more blocks of statements. ANS: test condition 2. A statement which checks to see if the value of the expression on the left side is the same as the value of the expression on the right side is an example of the use of the operator. ANS: comparison 3. Two strings are if they contain exactly the same characters in the same order. ANS: equal 4. A(n) is used to summarize the actions of the logical operators. ANS: truth table 5. Logical operators are used to create conditions from given conditions. ANS: compound, simple 6. In the hierarchy of the order of operations, operations are performed first. ANS: arithmetic 7. Some programming languages allow variables to be of logical or type. oolean 8. The >= is one of the operators. ANS: relational 9. The multiple-alternative selection structure that does not use an If-Then- clause is the or statement. ANS: Case, Switch 10. Including statements in a program to check for improper data during execution of the program is known as programming. ANS: defensive 11. The program segment that catches a division by zero is known as a(n). ANS: error trap 2007 Pearson Education 7

12. One type of illegal operation is an attempt to take the square root of a(n). ANS: negative number 13. The reciprocal of 0 is. ANS: undefined 14. The order of operations for is NOT first, then AND, then OR. ANS: logical operators 15. A dual-alternative selection structure is also known as a(n) structure. ANS: If-Then- 2007 Pearson Education 8