Chapter 2 Writing Sample Programs Flashcards
What are the 6 steps in the process of creating a program?
- Analyze the problem
- Determine Specifications
- Create a design
- Implement the design
- Test/Debug the program
- Maintain the program
What are some standards that Identifiers (Names) must follow when programming?
The must all begin with a letter or and underscore character, and they can be followed by any sequence of letters or numbers. There can be no spaces in these names.
What are the fragments of program code that produce or calculate new data values?
Expressions
What are strings?
Textual Data
A simple identifier can also be an expression. We use identifiers as variables to give names to values
ex:
»> X=5
T or F
A variable doesn’t need to be assigned a value before it is used within a program
False. A variable must be defined for it to have an effect. If it is not you will receive a name error.
T or F
Spaces are irrelevant within an expression
True. While spaces won’t effect if your code works or not, spaces can make a difference in how easily you can read an expression.
Give an example of Concatenation is.
Concatenation is the combining of strings (adding)
EX:
»> “Bat” + “Man”
What is a bare print?
A bare print has no parameters, so it produces a blank line of output. “\n”
What would the following function do?
print ( “The answer is “, end=” “ )
print (3+4)
The function would print ‘ The answer is 7 ‘
The end=” “ allows for the output from the second statement to be placed there.
Give an example of an assignment statement.
identifier= expression
=
Name = Ashlyn
T or F
A variable can only be assigned a value once.
False! A variable can be redefined as much as you want to change it. The variable will take the values that was assigned most recently. Variables are called variables because they are ( can ) constantly changing.
What is a name for the process of automatic memory management?
Garbage Collecting
How can you allow a variable to be based off of an input?
= input()
How can you allow for input to be entered into a variable if you need numbers?
= eval (input ())