Fundamentals of Computer Science Midterm
What are the 6 steps for problem solving you way through writing a program?
1. Problem Analysis: Studying the problem to be solved. 2. Program Specification: Deciding exactly what the program will do. 3. Design: Writing an algorithm in pseudocode. 4. Implementation: Translating the design into a programming language. 5. Testing/Debugging: Finding and fixing errors in the program. 6. Maintenance: Keeping the program up to date with evolving needs.
What is a computer?
A universal information-processing machine that can carry out any process that can be described in sufficient detail.
What are the basics components that make up a computer system?
Central processing unit (CPU), main memory, secondary memory, and input and output devices.
A chaotic function can't be computed by a computer. (t/f)
False
A function that creates a new instance of a class is called an accessor. (t/f)
False
A graphics window always has the title "Graphics Window." (t/f)
False
A loop is used to skip over a section of a program. (t/f)
False
A programming environment refers to a place where programmers work. (t/f)
False
Computer science is the study of computers.
False
In Python, 4+5 produces the same result type as 4. 0+5. 0. (t/f)
False
In a flowchart, diamonds are used to show statement sequences, and rectangles are used for decision points. (t/f)
False
Keywords make good variable names. (t/f)
False
Operations like addition and subtraction are defined in the math library (t/f)
False
Programs no longer require modification after they are written and de-bugged. (t/f)
False
Python does not allow the input of multiple values with a single statement. (t/f)
False
Secondary memory is also called RAM. (t/f)
False
Since floating-point numbers are extremely accurate, they should generally be used instead of ints. (t/f)
False
The best way to write a program is to immediately type in some code and then debug it until it works. (t/f)
False
The copy method is provided to make a copy of a graphics object. (t/f)
False
The method in the graphics library used to get a mouse click is readMouse. (t/f)
False
The sqrt function computes the squirt of a number. (t/f)
False
The statement myShape . move ( 10 , 20) moves myShape to the point (1 0,20). (t/f)
False
The syntax of a language is its meaning, and semantics is its form. (t/f)
False
Type conversion functions such as float are a safe alterative to eval for getting a number as user input. (t/f)
False
Using graphics.py allows graphics to be drawn in a Python shell window. (t/f)
False
Are floats always exact?
Floats have a finite amount of precision and cannot represent most numbers exactly
What are identifiers?
Identifiers are names; they begin with an underscore or letter which can be followed by a combination of letter, digit, or underscore characters. Identifiers in Python are case-sensitive.
In a mixed-type expression involving ints and floats, what data type will be converted to the other?
Python first converts the ints into floats and then uses float arithmetic
What is the CPU?
The CPU is the brain of the computer. It performs simple arithmetic and logical operations.
What does the eval function do?
The eval function can be used to evaluate user input, but it is a security risk and should not be used with input from unknown or untrusted sources.
What is programming?
The process of creating software
What is computer science?
The study of what can be computed
What is a data type?
The way a computer represents a particular kind of information
A algorithm can be written without using a programming language. (t/f)
True
A counted loop is designed to iterate a specific number of times. (t/f)
True
A function definition is a sequence of statements that defines a new command. (t/f)
True
A hardware float can represent a larger range of values than a hardware int. (t/f)
True
A single point on a graphics screen is called a pixel. (t/f)
True
A variable is used to give a name to a value so it can be referred to in other places. (t/f)
True
Al information that a computer is currently working on is stored in main memory. (t/f)
True
Aliasing occurs when two variables refer to the same object. (t/f)
True
Computers represent numbers using base-2 (binary) representations. (t/f)
True
Expressions are built from literals, variables, and operators. (t/f)
True
In Python, x = x + 1 is a legal statement. (t/f)
True
Information that is stored and manipulated by computers is called data. (t/f)
True
Instance variables are used to store data inside an object. (t/f)
True
Python identifiers must start with a letter or underscore. (t/f)
True
The CPU is the "brain" of the computer. (t/f)
True
The float data type is identical to the mathematical concept of a real number. (t/f)
True
The number of possible arrangements of n items is equal to n!. (t/f)
True
Traditionally the upper-left comer of a graphics window has coordinates (0,0). (t/f)
True
What is a counted loop?
a loop designed specifically for the purpose of repeating some portion of the program a specific number of times. It is created using the built-in range function to produce a suitably sized sequence of numbers.
What is an algorithm?
a sequence of steps for solving a particular problem
What is the correct formula for converting Celsius to Fahrenheit? a) F = 9/5(0) + 32 b) F = 5/9(0)- 32 c) F = B2 - 4AO d) F = 23
a) F = 9/5(0) + 32
Which of the following is not an example of secondary memory? a) RAM b) hard drive c) USB flash drive d) DVD
a) RAM
Which of the following is not true of comments? a) They make a program more efficient. b) They are intended for human readers. c) They are ignored by Python. d) In Python, they begin with a pound sign (#).
a) They make a program more efficient.
The pattern used to compute factorials is a) accumulator b) input, process, output c) counted loop d) plaid
a) accumulator
In modern Python, an int value that grows larger than the underlying hardware int a) causes an overflow b) converts to float c) breaks the computer d) uses more memory
a) causes an overflow
Which of the following is the most accurate model of assignment in Python? a) stick-note b) variable-as-box c) simultaneous d) plastic-scale
a) stick-note
The value of 4! is a) 9 b) 24 c) 41 d) 120
b) 24
What is the fndamental question of computer science? a) How fast can a computer compute? b) What can be computed? c) What is the most effective programming language? d) How much money can a programmer make?
b) What can be computed?
A statement is a) a translation of machine language b) a complete computer command c) a precise description of a problem d) a section of an algorithm
b) a complete computer command
Fragments of code that produce or calculate new data values are called a) identifiers b) expressions c) productive clauses d) assignment statements
b) expressions
The most appropriate data type for storing the value of pi is a) int b) float c) irrational d) string
b) float
Computer languages designed to be used and understood by humans are a) natural languages b) high-level computer languages c) machine languages d) fetch-execute languages
b) high-level computer languages
By convention, the statements of a program are often placed in a function called a) import b) main c) program d) IDLE
b) main
A method that changes the state of an object is called a(n) a) stator b) mutator c) constructor d) changor
b) mutator
The items listed in the parentheses of a function definition are called a) parentheticals b) parameters c) arguments d) both b) and c) are correct
b) parameters
Which of the following is not a part of the IPO pattern? a) input b) program c) process d) output
b) program
Which of the following are not used in expressions? a) variables b) statements c) operators d) literals
b) statements
Which of the following is not a legal identifier? a) spam b) spAm c) 2spam d) spam4U
c) 2spam
The number of distinct values that can be represented using 5 bits is a) 5 b) 10 c) 32 d) 50
c) 32
One difference between a compiler and an interpreter is a) a compiler is a program b) a compiler is used to translate high-level language into machine language c) a compiler is no longer needed after a program is translated d) a compiler processes source code
c) a compiler is no longer needed after a program is translated
Which of the following is not a step in the software development process? a) specification b) testing/Debugging c) fee setting d) maintenance
c) fee setting
Which of the following is not a built-in Python data type? a) int b) float c) rational d) string
c) rational
What command would set the coordinates of win to go from (0,0) in the lower-left corner to (10, 10) in the upper-right? a) win.setcoords (Point (O,O) , Point ( 10 , 10) ) b) win.setcoords((O,O) , ( 10,10) ) c) win.setcoords (O , 0, 10 , 10) d) win.setcoords (Point ( 10 , 10) , Point (O,O))
c) win.setcoords (O , 0, 10 , 10)
What graphics class would be best for drawing a square? a) Square b) Polygon c) Line d) Rectangle
d) Rectangle
The template for <variable> in rage ( <expr>) describes a) a general for loop b) an assignment statement c) a flowchart d) a counted loop
d) a counted loop
Which of the following is not a Python type-conversion function? a) float b) round c) int d) abs
d) abs
A method that returns the value of an object's instance variable is called a(n) a) mutator b) function c) constructor d) accessor
d) accessor
In order to use functions in the math library a program must include a) a comment b) a loop c) an operator d) an import statement
d) an import statement
In Python, getting user input is done with a special expression called a) for b) read c) simultaneous assignment d) input
d) input
In a mixed-type expression involving ints and floats, Python will convert a) floats to ints b) ints to strings c) both floats and ints to strings d) ints to floats
d) ints to floats
A problem is intractable when a) you cannot reverse its solution b) it involves tractors c) it has many solutions d) it is not practical to solve
d) it is not practical to solve
A algorithm is like a a) newspaper b) Venus flytrap c) drum d) recipe
d) recipe
The process of describing exactly what a computer program will do to solve a problem is called a) design b) implementation c) programming d) specification
d) specification
Which of the following is not a built-in operation? a)+ b)% c) abs () d) sqrt()
d) sqrt()
What techniques do computer scientists use?
design, analysis, and experimentation
What is syntax?
form
what data type does float represent?
fractional values
What are programs composed of?
identifiers and expressions
What pattern do many simple programs follow?
input, process, output (IPO) pattern
What components can compose an expression?
literals: A literal is a representation of a specific value. For example, 3 is a literal representing the number three. variables: A variable is an identifier that stores a value. operators: Operators are used to combine expressions into more complex expressions. For example, in x + 3 * y the operators + and * are used.
What are definite loops?
loops that execute a known number of times
Where is the information (data and programs) that the CPU acts on stored?
main memory (RAM)
What is semanics?
meaning
What does the output statement print display?
the values of a series of expressions
What does a data type determine?
what values it can have and what operations it supports
What is a mathematical model called chaotic?
when very small changes in the input lead to large changes in the results, making them seem random or unpredictable.
What data type does int represent?
whole numbers