Docsity

Python Midterm Exam Questions and Answers, Exams of Advanced Education

Toggle sidebar
bg1
Python Midterm Exam Questions and
Answers
Abstraction - ANSWERS-What is the name for the process of paying attention
too important properties while ignoring nonessential details.
Local variable - ANSWERS-Every module has all of the following except
________?
Call - ANSWERS-Programmers say that one module can ______ another;
meaning that the first module causes the second module to execute.
Functional cohesion - ANSWERS-The more that a module's statements
contribute to the job, the greater the ________ of the module.
In scope - ANSWERS-In most modern programming languages, a variable or
constant that is declared in a module is _______ in that module.
False - ANSWERS-Printing summaries is a typical housekeeping task. (T/F)
True - ANSWERS-The detail loop in a typical program will execute the most.
(T/F)
Which routines call which other routines. - ANSWERS-A hierarchy chart tells
you ______.
Comments - ANSWERS-What are nonexecuting statements that programmers
place within code to explain program statements in English?
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13

Partial preview of the text

Download Python Midterm Exam Questions and Answers and more Exams Advanced Education in PDF only on Docsity!

Python Midterm Exam Questions and

Answers

Abstraction - ANSWERS-What is the name for the process of paying attention too important properties while ignoring nonessential details. Local variable - ANSWERS-Every module has all of the following except ________? Call - ANSWERS-Programmers say that one module can ______ another; meaning that the first module causes the second module to execute. Functional cohesion - ANSWERS-The more that a module's statements contribute to the job, the greater the ________ of the module. In scope - ANSWERS-In most modern programming languages, a variable or constant that is declared in a module is _______ in that module. False - ANSWERS-Printing summaries is a typical housekeeping task. (T/F) True - ANSWERS-The detail loop in a typical program will execute the most. (T/F) Which routines call which other routines. - ANSWERS-A hierarchy chart tells you ______. Comments - ANSWERS-What are nonexecuting statements that programmers place within code to explain program statements in English?

False - ANSWERS-Are programmers comments required to create a runnable program or a form of external documentation? (T/F) To make names easier to read, separate long names by using underscores or capitalization for each new word. - ANSWERS-The following is valid advice for naming variables? Prompt - ANSWERS-A message that asks a user for input is a ______? False - ANSWERS-True or False: Computer science is the study of computers CPU - ANSWERS-The "brain" of the computer is the RAM (Random Access Memory) - ANSWERS-Main memory is also called main memory - ANSWERS-All information that a computer is currently working on is stored in Syntax - ANSWERS-_______ of a language is its form Semantics - ANSWERS-_______ of a language is its meaning Compiler - ANSWERS-A complex computer program that takes another program written in a high-level language and translates it into an equivalent program in the machine language of some computer

compiler - ANSWERS-used to translate high-level language into machine language main - ANSWERS-by convention, the statements of a program are often placed in a function called comments - ANSWERS-Are intended for human readers, ignored by Python, and begin with a # sign parameters - ANSWERS-The items listed in the parentheses of a function definition are called False - ANSWERS-The best way to write a program is to immediately type in some code and then debug it until it works True - ANSWERS-An algorithm can be written without using a programming language False - ANSWERS-Programs no longer require modification after they are written and debugged True - ANSWERS-Python identifiers must start with a letter or underscore False - ANSWERS-keywords make good variable names True - ANSWERS-expressions are built from literals, variables, and operators True - ANSWERS-in Python, x = x + 1 is a legal statement

False - ANSWERS-Python does not allow the input of multiple values with a single statement True - ANSWERS-A counted loop is designed to iterate a specific number of times False - ANSWERS-In a flowchart, diamonds are used to show statements, and rectangles are used for decision points Specification, Testing/Debugging, and Maintenance - ANSWERS-What are the steps in the software development process? F = 9/5(C) + 32 - ANSWERS-Formula for converting Celsius into Fahrenheit specification - ANSWERS-The process of describing exactly what a computer program will do to solve a problem is called number - ANSWERS-Legal Identifiers cannot start with a statements - ANSWERS-What is NOT used in an expression? counted loop - ANSWERS-The template for in range() describes a sticky-note - ANSWERS-What is the most accurate model of assignment in Python?

rational - ANSWERS-What isn't a Python data type? sqrt() - ANSWERS-What is not a built-in operation? an import statement - ANSWERS-In order to use functions in the math library, a program must include 24 - ANSWERS-The value of 4! is float - ANSWERS-The most appropriate data type for storing the value of pi is 32 - ANSWERS-The number of distinct values that can be represented using 5 bits is ints to floats - ANSWERS-in a mixed-type expression involving ints and floats, Python will convert from ____ to _____ abs - ANSWERS-what is not a Python type-conversion? accumulator - ANSWERS-the pattern used to compute factorial is uses memory - ANSWERS-In modern Python, an int value that grows larger than the underlying hardware int does what? graphics window - ANSWERS-Using graphics.py allows graphics to be drawn into a upper-left - ANSWERS-traditionally, the ___________ corner of a graphics window has coordinates (0,0)

pixel - ANSWERS-A single point on a graphics screen is called a constructor - ANSWERS-A function that creates a new instance of a class is called true - ANSWERS-Instance variables are used to store data inside an object false - ANSWERS-The statement myShape.move(10,20) moves myShape to the point (10,20) true - ANSWERS-Aliasing occurs when two variables refer to the same object clone - ANSWERS-The _____ method is provided to make a copy of a graphics object false - ANSWERS-A graphics window always has the title "Graphics Window" getMouse() - ANSWERS-The method in the graphics library used to get a mouse click is methods - ANSWERS-The set of messages that an object responds to are called the ______ of the object dot-notation - ANSWERS-A method is invoked using what? accessor - ANSWERS-A method that returns the value of an object's instance variable is called

true - ANSWERS-In Python "4" + "5" is "45" mutable - ANSWERS-Python lists are _______, but strings are not true - ANSWERS-ACSII is a standard for representing characters using numeric codes True - ANSWERS-The split method breaks a string into a list of substrings, and join does the opposite append - ANSWERS-The _______ method can be used to add an item to the end of a list false - ANSWERS-The process of associating a file with an object in a program is called "reading" the file indexing - ANSWERS-Accessing a single character out of a string is called s[-1] - ANSWERS-What is the same as s[0:-1] ord - ANSWERS-What function gives the Unicode value of a character? str - ANSWERS-What cannot be used to convert a string of digits into a number? Unicode - ANSWERS-A successor to ASCII that includes characters from (nearly) all written language is

upper - ANSWERS-converts all the characters of a string to upper case {} - ANSWERS-The string "slots" that are fulled in by the format method are marked by read, readline, readlines - ANSWERS-What are the file-reading methods in Python? batch - ANSWERS-The term for a program that does its I/O with files is open - ANSWERS-Before reading or writing to a file, a file object must be created via software - ANSWERS-Computer programs are also known as: input, processing, and output - ANSWERS-The major computer operations include: programming languages - ANSWERS-Visual Basic, C++, and Java are all examples of computer ... sytax - ANSWERS-A programming language's rules are it's: translate programming language statements into machine language - ANSWERS-The most important task of a compiler or interpreter is to: memory - ANSWERS-Temporary, internal storage

  1. Understand the problem

input and output - ANSWERS-The parallelogram is the flowchart symbol representing processing - ANSWERS-In a flowchart, a rectangle represents: diamond - ANSWERS-In flowcharts, the decision symbol is a: a generic sentinel value - ANSWERS-The term "eof" represents: True - ANSWERS-When you use an IDE, as opposed to a simple text editor to develop a program, some help is provided (T/F) False - ANSWERS-When you write a program that will run in a GUI environment as opposed to a command-line environment, all the syntax is the same (T/F). The programmer's focus differs - ANSWERS-As compared to procedural programming, with object-oriented programming, ______. It is electronic - ANSWERS-Which is not part of the definition of a computer? Any computer can carry out the same tasks as any other computer - ANSWERS-The statement "All computers have the same power" means: monitor - ANSWERS-Which of the following is not one of the functional building blocks of a computer system: Secondary memory - ANSWERS-Magnetic or optical media are generally used for:

5 - ANSWERS-What would Python print as a result of this interaction:

print(2 + 3) hello() - ANSWERS-Suppose we interactively define a new function as follows: def hello(): print("Hello") print("Computers are fun") What would you type to invoke (run) this function? It causes the program to do something 10 times. - ANSWERS-What is the effect of the following Python statement? for i in range(10): 0.71136 - ANSWERS-What is your first number printed by the following program, assuming that the user enters 0.24 as the input? def main(): x = eval(input("Enter a number between 0 and 1:")) for i in range(10): x = 3.9 * x * (1 - x) print(x)

Input Process Output - ANSWERS-The program pattern IPO stands for: print - ANSWERS-The Python reserved word for performing output to the screen is: the value contains 10 - ANSWERS-Suppose a program executes the following statement:

value = eval(input("Enter a number: ")) In response to the prompt, the user types 5 + 5. What is the result? x = x + 5 - ANSWERS-Suppose that the variable x currently has the value 20. What statement would cause the value of x to become 25? an expression that returns the result of evaluating what the user types - ANSWERS-The fragment of code eval(input("Enter a number: ")) is best describes as: 10 and 10 - ANSWERS-Suppose the variable x has the value 5 and y has the value 10. After executing these statements: x = y y = x

what will the values of x and y be, respectively?

10 and 5 - ANSWERS-Suppose the variable x has the value 5 and y has the value 10. After executing these statements:

x, y = y, x what will the values of x and y be, respectively? 2 6 10 14 - ANSWERS-What is the output from the following program fragment? for i in [1, 3, 5, 7]

print(2 * i, end=" ") [0, 1, 2, 3, 4] - ANSWERS-What is the result of evaluating the expression list(range(5))? for i in range(5): - ANSWERS-what is the output from the following program fragment? for i in [1, 3, 5, 7] print(2 * i, end=" ") 32 - ANSWERS-Consider the following program: def main(): num = eval(input("Enter a number: ")

Method & procedure - ANSWERS-The following are terms used as a synonym for module in some programming languages. Modularization allows you to more easily reuse your work - ANSWERS-Why use modularization?