1. A(n) structure is a logical design that controls the order in which a set of statements execute. a. function b. control c. sequence d.

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

Algorithm & Flowchart & Pseudo code. Staff Incharge: S.Sasirekha

WESTMORELAND COUNTY PUBLIC SCHOOLS Integrated Instructional Pacing Guide and Checklist Computer Math

CSC 221: Computer Programming I. Fall 2011

Chapter 13: Program Development and Programming Languages

Chapter 13: Program Development and Programming Languages

PROG0101 Fundamentals of Programming PROG0101 FUNDAMENTALS OF PROGRAMMING. Chapter 3 Algorithms

#820 Computer Programming 1A

We will learn the Python programming language. Why? Because it is easy to learn and many people write programs in Python so we can share.

Exercise 4 Learning Python language fundamentals

Database Programming with PL/SQL: Learning Objectives

Chapter 5. Selection 5-1

Visual Logic Instructions and Assignments

I PUC - Computer Science. Practical s Syllabus. Contents

Programming Your App to Make Decisions: Conditional Blocks

Python Programming: An Introduction To Computer Science

TECHNOLOGY Computer Programming II Grade: 9-12 Standard 2: Technology and Society Interaction

2 SYSTEM DESCRIPTION TECHNIQUES

El Dorado Union High School District Educational Services

Computers. An Introduction to Programming with Python. Programming Languages. Programs and Programming. CCHSG Visit June Dr.-Ing.

River Dell Regional School District. Computer Programming with Python Curriculum

Storage Classes CS 110B - Rule Storage Classes Page 18-1 \handouts\storclas

Embedded Systems. Review of ANSI C Topics. A Review of ANSI C and Considerations for Embedded C Programming. Basic features of C

VB.NET Programming Fundamentals

Thomas Jefferson High School for Science and Technology Program of Studies Foundations of Computer Science. Unit of Study / Textbook Correlation

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

Some programming experience in a high-level structured programming language is recommended.

Computer Programming I

Writing Simple Programs

McGraw-Hill The McGraw-Hill Companies, Inc.,

EMC Publishing. Ontario Curriculum Computer and Information Science Grade 11

Introduction to Python

Object Oriented Software Design

VHDL Test Bench Tutorial

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

Welcome to Introduction to programming in Python

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

Two-way selection. Branching and Looping

VISUAL GUIDE to. RX Scripting. for Roulette Xtreme - System Designer 2.0

Fundamentals of Programming and Software Development Lesson Objectives

Exercise 1: Python Language Basics

Object Oriented Software Design

2. Capitalize initial keyword In the example above, READ and WRITE are in caps. There are just a few keywords we will use:

Problem Solving Basics and Computer Programming

Sources: On the Web: Slides will be available on:

ARIZONA CTE CAREER PREPARATION STANDARDS & MEASUREMENT CRITERIA SOFTWARE DEVELOPMENT,

High-Level Programming Languages. Nell Dale & John Lewis (adaptation by Michael Goldwasser)

ALGORITHMS AND FLOWCHARTS

JavaScript: Control Statements I

Introduction to Python

QUIZ-II QUIZ-II. Chapter 5: Control Structures II (Repetition) Objectives. Objectives (cont d.) 20/11/2015. EEE 117 Computer Programming Fall

Chapter One Introduction to Programming

DATA 301 Introduction to Data Analytics Microsoft Excel VBA. Dr. Ramon Lawrence University of British Columbia Okanagan

Pseudo code Tutorial and Exercises Teacher s Version

Perl in a nutshell. First CGI Script and Perl. Creating a Link to a Script. print Function. Parsing Data 4/27/2009. First CGI Script and Perl

Programming and Software Development CTAG Alignments

6.170 Tutorial 3 - Ruby Basics

KITES TECHNOLOGY COURSE MODULE (C, C++, DS)

Computer Programming I & II*

Chapter 1 An Introduction to Computers and Problem Solving

Informatica e Sistemi in Tempo Reale

2011, The McGraw-Hill Companies, Inc. Chapter 5

CS 141: Introduction to (Java) Programming: Exam 1 Jenny Orr Willamette University Fall 2013

1 Introduction. 2 Overview of the Tool. Program Visualization Tool for Educational Code Analysis

APP INVENTOR. Test Review

Outline. multiple choice quiz bottom-up design. the modules main program: quiz.py namespaces in Python

Programming and Software Development (PSD)

Curriculum Map. Discipline: Computer Science Course: C++

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

Course Title: Software Development

PROBLEM SOLVING SEVENTH EDITION WALTER SAVITCH UNIVERSITY OF CALIFORNIA, SAN DIEGO CONTRIBUTOR KENRICK MOCK UNIVERSITY OF ALASKA, ANCHORAGE PEARSON

Designing with Exceptions. CSE219, Computer Science III Stony Brook University

Java Programming (10155)

The Elective Part of the NSS ICT Curriculum D. Software Development

Chapter 5 Functions. Introducing Functions

This loop prints out the numbers from 1 through 10 on separate lines. How does it work? Output:

Candle Plant process automation based on ABB 800xA Distributed Control Systems

Chapter 12 Programming Concepts and Languages

Outline. hardware components programming environments. installing Python executing Python code. decimal and binary notations running Sage

Computer Science III Advanced Placement G/T [AP Computer Science A] Syllabus

Flowchart Techniques

Selection Statements

Visual Basic Programming. An Introduction

ARIZONA CTE CAREER PREPARATION STANDARDS & MEASUREMENT CRITERIA SOFTWARE DEVELOPMENT,

AQA GCSE in Computer Science Computer Science Microsoft IT Academy Mapping

Iteration CHAPTER 6. Topic Summary

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

JavaScript: Introduction to Scripting Pearson Education, Inc. All rights reserved.

Modeling, Computers, and Error Analysis Mathematical Modeling and Engineering Problem-Solving

Python Programming: An Introduction to Computer Science

Moving from CS 61A Scheme to CS 61B Java

Software Development. Topic 1 The Software Development Process

IF The customer should receive priority service THEN Call within 4 hours PCAI 16.4

Computational Mathematics with Python

Oracle Database: Develop PL/SQL Program Units

[Refer Slide Time: 05:10]

Transcription:

Chapter Four MULTIPLE CHOICE 1. A(n) structure is a logical design that controls the order in which a set of statements execute. a. function b. control c. sequence d. iteration 2. The decision structure that has two possible paths of execution is known as. a. single alternative b. double alternative c. dual alternative d. two alternative 3. Multiple Boolean expressions can be combined by using a logical operator to create expressions. a. sequential b. logical c. compound d. mathematical 4. When using the operator, one or both subexpressions must be true for the compound expression to be true. a. Or b. And c. Not d. Maybe 5. Which logical operators perform short-circuit evaluation? a. or, not b. not, and c. or, and d. and, or, not 6. Which of the following is the correct if clause to determine whether y is in the range 10 through 50? a. if 10 < y or y > 50 b. if 10 > y and y < 50 c. if y > 10 and y < 50 d. if y > 10 or y < 50 7. A Boolean variable can reference one of two values:. a. yes or no b. true or false c. T or F d. Y or N

8. What is the result of the following Boolean expression, if x equals 5, y equals 3, and z equals 8? x < y or z > x a. true b. false c. 8 d. 5 9. What is the result of the following Boolean expression, if x equals 5, y equals 3, and z equals 8? x < y and z > x a. true b. false c. 8 d. 5 10. What is the result of the following Boolean expression, if x equals 5, y equals 3, and z equals 8? not (x < y or z > x) and y < z a. true b. false c. 8 d. 5 11. What does the following expression mean? x <= y a. x is less than y b. x is less than or equal to y c. x is greater than y d. x is greater than or equal to y 12. Which of the following is the correct if clause to use to determine whether choice is other than 10? a. if choice!= 10: b. if choice!= 10 c. if choice <> 10: d. if choice <> 10 13. When using the operator, both subexpressions must be true for the compound expression to be true. a. or b. and c. not d. maybe 14. In Python, the symbol is used as the not-equal-to operator. a. == b. <>

c. <= d.!= 15. In Python the symbol is used as the equality operator. a. == b. = c. >= d. <= TRUE/FALSE 1. True/False: The if statement causes one or more statements to execute only when a Boolean expression is true. 2. True/False: The Python language is not sensitive to block structuring of code. 3. True/False: Python allows you to compare strings, but it is not case sensitive. 4. True/False: Nested decision structures are one way to test more than one condition. 5. True/False: Python uses the same symbols for the assignment operator and the equality operator. 6. True/False: The not operator is a unary operator and it must be a compound expression. 7. True/False: Short-circuit evaluation is performed with the not operator. 8. True/False: Expressions that are tested by the if statement are called Boolean expressions. 9. True/False: Decision structures are also known as selection structures. 10. True/False: An action in a single alternative decision structure is performed only when the condition is true. FILL IN THE BLANK 1. The statement is used to create a decision structure. 2. In flowcharting, the symbol is used to represent a Boolean expression. 3. A(n) decision structure provides only one alternative path of execution. 4. In a decision structure, the action is executed because it is performed only when a certain condition is true. 5. A(n) operator determines whether a specific relationship exists between two values.

6. A(n) statement will execute one block of statements if its condition is true, or another block if its condition is false. 7. Python provides a special version of a decision structure known as the statement, which makes the logic of the nested decision structure simpler to write. 8. The logical operator reverses the truth of a Boolean expression. 9. Boolean variables are commonly used as to indicate whether a specific condition exists. 10. A(n) expression is made up of two or more Boolean expressions.

Chapter Five MULTIPLE CHOICE 1. What is the disadvantage of coding in one long sequence structure? a. Duplicated code makes the program faster to write. b. Writing a long sequence of statements is error prone. c. If parts of the duplicated code have to be corrected, the correction has to be made many times. d. It does not make use of decision structures. 2. What type of loop structure repeats the code a specific number of times? a. Condition-controlled loop b. Number-controlled loop c. Count-controlled loop d. Boolean-controlled loop 3. What type of loop structure repeats the code based on the value of the Boolean expression? a. Condition-controlled loop b. Number-controlled loop c. Count-controlled loop d. Boolean-controlled loop 4. What is the format for the while clause in Python? a. while condition b. while condition : c. while condition statement d. while condition : statement 5. What are the values that the variable num contains through the iterations of the following for loop? for num in range(2, 9, 2) a. 2, 3, 4, 5, 6, 7, 8, 9 b. 2, 5, 8 c. 2, 4, 6, 8 d. 1, 3, 5, 7, 9 6. What are the values that the variable num contains through the iterations of the following for loop? for num in range(4) a. 1, 2, 3, 4 b. 0, 1, 2, 3, 4 c. 1, 2, 3 d. 0, 1, 2, 3 7. The variable used to keep the running total is called a(n). a. Accumulator b. Total

c. running total d. grand total 8. What is not an example of an augmented assignment operator? a. *= b. /= c. -= d. <= 9. is the process of inspecting data that has been input to a program to make sure it is valid before it is used in a computation. a. Input validation b. Correcting data c. Data validation d. Correcting input 10. The first input operation is called the, and its purpose is to get the first input value that will be tested by the validation loop. a. priming read b. first input c. loop set read d. loop validation 11. What is the structure that causes a statement or a set of statements to execute repeatedly? a. Sequence b. Decision c. Module d. Repetition 12. When will the following loop terminate? while keep_on_going!= 999 : a. When keep_on_going refers to a value less than 999 b. When keep_on_going refers to a value greater than 999 c. When keep_on_going refers to a value equal to 999 d. When keep_on_going refers to a value not equal to 999 13. In Python, a comma-separated sequence of data items that are enclosed in a set of brackets is called a. a. sequence b. variable c. value d. List 14. In Python, the variable in the for clause is referred to as the because it is the target of an assignment at the beginning of each loop iteration. a. target variable b. loop variable c. for variable d. count variable

15. Which of the following represents an example to calculate the sum of the numbers (accumulator)? a. total + number = total b. number += number c. total += number d. total = number TRUE/FALSE 1. True/False: Reducing duplication of code is one of the advantages of using a loop structure. 2. True/False: A better way to repeatedly perform an operation is to write the statements for the task once, and then place the statements in a loop that will repeat the statements as many times as necessary. 3. True/False: In flowcharting, the decision structure and the repetition structure both use the diamond symbol to represent the condition that is tested. 4. True/False: The first line in the while loop is referred to as the condition clause. 5. True/False: In Python, an infinite loop usually occurs when the computer accesses the wrong memory address. 6. True/False: Both of the following for clauses would generate the same number of loop iterations: for num in range(4): for num in range(1,5): 7. True/False: The integrity of a program s output is only as good as the integrity of its input. For this reason the program should discard input that is invalid and prompt the user to enter correct data. 8. True/False: Functions can be called from statements in the body of a loop, and loops can be called from the body of a function. 9. True/False: In a nested loop, the inner loop goes through all of its iterations for every single iteration of an outer loop. 10. True/False: To get the total number of iterations of a nested loop, multiply the number of iterations of all the loops. FILL IN THE BLANK 1. A(n) structure causes a statement or set of statements to execute repeatedly.

2. A(n) -controlled loop causes a statement or set of statements to repeat as long as a condition is true. 3. The while loop is known as a(n) loop because it tests conditions before performing an iteration. 4. A(n) loop usually occurs when the programmer forgets to write code inside the loop that makes the test condition false. 5. In Python, you would use the statement to write a count-controlled loop. 6. A(n) total is a sum of numbers that accumulates with each iteration of a loop. 7. A(n) is a special value that marks the end of a sequence of items. 8. The acronym refers to the fact that the computer cannot tell the difference between good data and bad data. 9. A(n) validation loop is sometimes called an error trap or an error handler. 10. The function is a built-in function that generates a list of integer values.

Chapter Six MULTIPLE CHOICE 1. What is a group of statements that exists within a program for the purpose of performing a specific task? a. function b. subtask c. procedure d. subprogram 2. The first line in the function definition is known as the function. a. header b. block c. return d. parameter 3. The design technique can be used to break down an algorithm into functions. a. subtask b. block c. top-down d. simplification 4. A set of statements that belong together as a group and contribute to the function definition is known as a(n). a. header b. block c. return d. parameter 5. A(n) chart is also known as a structured chart. a. flow b. data c. hierarchy d. organizational 6. A(n) variable is created inside a function. a. global b. constant c. defined d. local 7. The of a local variable is the function in which the variable is created. a. global b. defined c. local d. scope 8. A(n) is any piece of data that is passed into a function when the function is called.

a. global b. argument c. scope d. parameter 9. A(n) is a variable that receives an argument that is passed into a function. a. global b. argument c. scope d. parameter 10. The argument specifies which parameter the argument should be passed into. a. keyword b. local c. global d. string 11. A(n) variable is accessible to all the functions in a program file. a. keyword b. local c. global d. string 12. A(n) constant is a global name that references a value that cannot be changed. a. keyword b. local c. global d. string 13. When a function is called by its name, then it is. a. executed b. located c. defined d. exported 14. It is recommended that programmers should avoid using variables in a program when possible. a. local b. global c. string global d. keyword 15. A variable s is the part of a program in which the variable may be accessed. a. global b. argument c. scope d. local 16. The Python library functions that are built into the Python can be used by simply calling the function. a. code

b. compiler c. linker d. interpreter 17. Python comes with functions that have been already prewritten for the programmer. a. standard b. library c. custom d. built-in 18. Which of the following statements causes the interpreter to load the contents of the random module into memory? a. load random b. import random c. upload random d. download random 19. Which of the following will assign a random number in the range of 1 through 50 to the variable number? a. random(1,50) = number b. number = random.randint(1, 50) c. randint(1, 50) = number d. number = random(range(1, 50)) 20. What is the result of the following statement? x = random.randint(5, 15) * 2 a. A random integer from 5 to 15, multiplied by 2, assigned to the variable x b. A random integer from 5 to 15 assigned to the variable x c. A random integer from 5 to 15, selected in 2 steps, assigned to the variable x d. A random integer from 5 to 15, raised to the power of 2, assigned to the variable x 21. What type of value is returned by the functions random and uniform? a. integer b. number c. float d. double 22. In a value-returning function, the value of the expression that follows the key word will be sent back to the part of the program that called the function. a. def b. return c. sent d. result 23. What type of function can be used to determine whether a number is even or odd? a. even b. odd c. math d. Boolean

24. The Python standard library s module contains numerous functions that can be used in mathematical calculations. a. math b. string c. random d. number 25. Which of the following functions returns the largest integer that is less than or equal to x? a. floor b. ceil c. lesser d. greater 26. What makes it easier to reuse the same code in more than one program? a. Mods b. Procedures c. Modules d. Functions 27. In a menu-driven program, what statement is used to determine and carry out the user s desired action? a. if-else b. if-elif-else c. while d. for 28. A value-returning function is. a. a single statement that perform a specific task b. called when you want the function to stop c. a function that will return a value back to the part of the program that called it d. a function that receives a value when it is called 29. What does the following statement mean? num1, num2 = get_num() a. The function get_num() is expected to return a value each for num1 and num2. b. The function get_num() is expected to return a value and assign it to num1 and num2. c. Statement will cause a syntax error. d. Statement will cause a run-time error. 30. Given the following function definition, what would the statement print magic(5) display? def magic(num): return num + 2 * 10 a. 70 b. 25 c. Statement will cause a syntax error. d. Statement will cause a run-time error. TRUE/FALSE

1. True/False: Python function names follow the same rules for naming variables. 2. True/False: The function header marks the beginning of the function definition. 3. True/False: A function definition specifies what a function does and causes the function to execute. 4. True/False: The hierarchy chart shows all the steps that are taken inside a function. 5. True/False: A local variable can be accessed from anywhere in the program. 6. True/False: Different functions can have local variables with the same names. 7. True/False: Python allows for passing multiple arguments to a function. 8. True/False: To assign a value to a global variable in a function, the global variable must first be declared in the function. 9. True/False: The value assigned to a global constant can be changed in the mainline logic. 10. True/False: One of the reasons not to use global variables is that it makes a program hard to debug. 11. True/False: A value-returning function is like a simple function except that when it finishes it returns a value back to the called part of the program. 12. True/False: Boolean functions are useful for simplifying complex conditions that are tested in decision and repetition structures. 13. True/False: Unlike other languages, in Python, the number of values a function can return is limited to one. 14. True/False: In Python, one can have a list of variables on the left side of the assignment operator. 15. True/False: In Python, there is no restriction on the name of a module file. 16. True/False: The randrange function returns a randomly selected value from a specific sequence of numbers. 17. True/False: One of the drawbacks of a modularized program is that the only structure we could use is sequence structure. 18. True/False: In a menu-driven program, a loop structure is used to determine the menu item the user selected. 19. True/False: The math function, atan(x), returns one tangent of x in radians.

20. True/False: The math function, ceil(x), returns the smallest integer that is greater than or equal to x. FILL IN THE BLANK 1. The approach called is taking a large task and dividing it into several smaller tasks that are easily performed. 2. The code for a function is known as a function. 3. The function header begins with the keyword followed by the name of the function. 4. The main function contains a program s logic, which is the overall logic of the program. 6. In a flowchart, a function call is depicted by a(n) that has vertical bars. 7. The top-down design breaks down the overall task of the program into a series of. 8. A(n) chart is a visual representation of the relationships between functions. 9. Arguments are passed by to the corresponding parameter variables in the function. 10. A variable is visible only to statements in the variable s. 11. Functions in the standard library are stored in files that are known as. 12. The term is used to describe any mechanism that accepts input, performs some operation that cannot be seen, and produces output. 13. To refer to a function in a module, in our program we have to use the notation. 14. A value-returning function has a(n) statement that returns a value back to the part of the program that called it. 15. The chart is an effective tool that programmers use for designing and documenting functions. 16. The P in the acronym IPO refers to. 17. In Python, a module s file name should end in 18. A(n) program displays a list of the operations on the screen and allows the user to select the operation that the program should perform.

19. The approach of makes the program easier to understand, test, and maintain. 20. The return values of the trigonometric functions in Python are in.