Chapter 2: Input, Processing, And Output Flashcards
Who is a programmer’s customer?
Clients
What is a software requirement?
It is the first and inital step in developing programs.
What is an algorithm?
The set of rules or instruction which may be performed in order to complete the task.
What is pseudocode?
pseudocode is an informal description of algorithm.

What is a flowchart?

What do each of the following symbols mean in a flowchart?
• Oval
• Parallelogram
• Rectangle
• The ovals, which appear at the top and bottom of the flowchart, are called terminal
symbols. The Start terminal symbol marks the program’s starting point and the End
terminal symbol marks the program’s ending point.
• Parallelograms are used as input symbols and output symbols. They represent steps in
which the program reads input or displays output.
• Rectangles are used as processing symbols. They represent steps in which the program
performs some process on data, such as a mathematical calculation.
Write a statement that displays your name.
print(‘Name’)
Write a statement that displays the following text:
Python’s the best!
Use double quation marks to display a string of charaters
print(“Python’s the best!”)
or
print(‘Python's the best!’)
Write a statement that displays the following text:
The cat said “meow.”
print(‘The cat said “meow.”’)
or
print(“The cat said "meow."”)
Write a statement that displays:
I’m reading “Hamlet” tonight.
print(“"”I’m reading “Hamlet” tonight.”””)
or
print(“I’m reading "Hamlet" tonight”)
Triple quotes you can put double and single quations in a statement.
Write a comment saying:
The is a comment
This is a comment
Legal or Not Legal for naming variables?

- legal
- legal
- illegal variables cannot start with digits
- legal
- illegal variables can only have letters, digits, and underscores
What is a variable?
variables are memory locations of the computer which are used for storing the data values temparory , during the execution of an application.
Which of the following are illegal variable names in Python, and why?
- x
- 99bottles
- july2009
- theSalesFigureForFiscalYear
- r&d
- grade_report
The 5th and 3rd variable is incorrect
Is the variable name Sales the same as sales? Why or why not?
These are different variables. One is capital and one is lower case.
Is the following assignment statement valid or invalid? If it is invalid, why?
72 = amount
the statement is illegal. The variable comes first before the value.
amount = 72 # valid
72 = amount # invalid
What will the following code display?
val = 99
print(‘The value is’, ‘val’)
The value is val
Look at the following assignment statements:
value1 = 99
value2 = 45.9
value3 = 7.0
value4 = 7
value5 = ‘abc’
After these statements execute, what is the Python data type of the values referenced by each variable?
- integer
- float
- float
- integer
- string
What will be displayed by the following program?
my_value = 99
my_value = 0
print(my_value)
0
The first variable got overwritten or redefine.
You need the user of a program to enter a customer’s last name. Write a statement that prompts the user to enter this data and assigns the input to a variable.
c_last_name = input(“Enter the customer’s last name”)
You need the user of a program to enter the amount of sales for the week. Write a statement that prompts the user to enter this data and assigns the input to a variable.
sales_for_the_week = float(input(“Enter the amount of sales for the week: “) )
Python Math Operators

What value will be assigned to result after the following statement executes?
result = 9 // 2
4
What value will be assigned to result after the following statement executes?
result = 9 % 2
1
What does the argument end=’ ‘ do to the function, as shown in the following code:
print(‘One’, end=’ ‘)
print(‘Two’, end=’ ‘)
print(‘Three’)
It will print the following code:
One Two Three
What does the argument end=’‘ do to the function, as shown in the following code:
print(‘One’, end=’’)
print(‘Two’, end=’’)
print(‘Three’)
It will print the following code:
OneTwoThree
What is the Separator argument use in print functions to seperate multiple arguments ?
sep=’ ‘
print this sentence is two different ways:
One Two Three
and
**print('One', 'Two', 'Three')** #and
print(‘One Two Three’)
print(‘One’, ‘Two’, ‘Three’, sep=’ ‘)
Print the following code in 2 different ways:
OneTwoThree
and
print(‘OneTwoThree’)
print(‘One’, ‘Two’, ‘Three’, sep=’’)
print the sentence in two different ways:
One*Two*Three
and
print(“One*Two*Three”)
print(‘One’, ‘Two’, ‘Three’, sep=’*’)
Escape Characters

What is the format specifier and what does it do?
The format specifier is a string that contains special characters specifying how #the numeric value should be formatted.
format( number, ‘f‘)orformat(number, ‘d‘)
print the following number and round it to the nearest tenths:
12345.6789
print(format(12345.6789, ‘.1f’))
How to format a number in Scientific Notation?
format( , ‘e’)
How to format a number where it has commas?
format( number , ‘,f’) or format( number , ‘,d’)
How to format a number to do a certain amount of spaces?
Output—-> The number is 12345.68
format(number, ‘spaces.f’) or format(number, ‘spaces.d’)
Example
- print(‘The number is’, format(12345.6789, ‘12.2f’))
How to format a number into a decimal?
format( decimal , ‘ % ’)
How to format an integer to have commas?
output—> 123456
format( integer, ‘d’)
Example
- print(format(123456, ‘10d’))
- print(format(123456, ‘20d’))
- print(format(123456, ‘10,d’))
A __________ is a single function that the program must perform in order to satisfy the customer.
software requirement
An informal language that has no syntax rules and is not meant to be compiled or executed is called __________.
pseudocode
A __________ is a sequence of characters.
string
A __________ is a name that references a value in the computer’s memory.
variable
A __________ is any hypothetical person using a program and providing input for it.
user
A string literal in Python must be enclosed in _____.
either single-quotes or double-quotes.
A(n) __________ makes a variable reference a value in the computer’s memory.
Round 12345.6789 to the nearest hundrends
print the following code:
Answer
format(12345.6789, ‘.2f’)
- print the number 12345.6789 in scienctic notation.
- print the number 12345.6789 in scientic notation and round to the nearest hundrendths.
The output—> 1.234568e+04
print(format(12345.6789, ‘e’))
print(format(12345.6789, ‘.2e’))
- print the number 12345.6789.Make the number with commas and round it to the nearest tenths.
- print the number 12345.6789.Make the number with commas and do not round.
Output—-> 12,345.68
print(format(12345.6789, ‘,.2f’))
print(format(12345.6789, ‘,f’))
- Convert the number .5 into a percentage.
Output—> 50.0000%
print(format(0.5, ‘%’))
print(format(0.5, ‘.0%’))
In the expression 12 + 7, the values on the right and left of the + symbol are called_________.
operands
what operator performs integer division?
//
what operator raises a number to a power?
**