2. Writing Simple Programs Flashcards
True or False
The best way to write a program is to immediately type in some code and then debug it until it works.
False
We need a systematic approach.
True or False
An algorithm can be written without using a programming language.
True
Pseudocode is just precise English that describes what a program does. It is meant to communicate algorithms without all the extra mental overhead of getting the details right in any particular programming language.
True or False
Programs no longer require modification after they are written and debugged.
False
Most programs are never really finished; they keep evolving over years of use.
True or False
Python identifiers must start with a letter or underscore.
True
Every identifier must begin with a letter or underscore which may be followed by any sequence of letters, digits, or underscores. This implies that a single identifier cannot contain any spaces.
True or False
Keywords make good variable names.
False
These names are called reserved words or keywords and cannot be used as ordinary identifiers.
True or False
Expressions are built from literals, variables, and operators.
True
Expressions are the fragments of a program that produce data. An expression can be composed of literals, variables and operators.
True or False
In Python, x = x + 1 is a legal statement.
True
True or False
Python does not allow the input of multiple values with a single statement.
False
Python also allows simultaneous assignment, which is useful for getting multiple input values with a single prompt.
, , … = , , …,
True or False
A counted loop is designed to iterate a specific number of times.
True
One important use of a for statement is in implementing a counted loop, which is a loop designed specifically for the purpose of repeating some portion of the program a specific number of times. A counted loop in Python is created by using the built-in range function to produce a suitably sized sequence of numbers.
for <var> in :
</var>
True or False
In a flowchart, diamonds are used to show statement sequences, and rectangles are used for decision points.
False
Rectangles are used to show statement sequences, and diamonds are used for decision points.
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
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
Program Specification: Deciding exactly what the program will do.
Which of the following is not a legal identifier?
a) spam
b) spAm
c) 2spam
d) spam 4U
d) spam 4U
Which of the following are not used in expressions?
a) variables
b) statements
c) operators
d) literals
b) statements
statements are built from identifiers and expressions.
Fragments of code that produce or calculate new data values are called
a) identifiers
b) expressions
c) productive clauses
d) assignment statements
b) expressions
Expressions are the fragments of a program that produce data.