Chapter 2: Input, Processing, And Output Flashcards

1
Q

Who is a programmer’s customer?

A

Clients

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is a software requirement?

A

It is the first and inital step in developing programs.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is an algorithm?

A

The set of rules or instruction which may be performed in order to complete the task.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is pseudocode?

A

pseudocode is an informal description of algorithm.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is a flowchart?

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What do each of the following symbols mean in a flowchart?
Oval
Parallelogram
Rectangle

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Write a statement that displays your name.

A

print(‘Name’)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Write a statement that displays the following text:
Python’s the best!

A

Use double quation marks to display a string of charaters

print(“Python’s the best!”)

or

print(‘Python's the best!’)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Write a statement that displays the following text:
The cat said “meow.”

A

print(‘The cat said “meow.”’)

or

print(“The cat said "meow."”)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Write a statement that displays:

I’m reading “Hamlet” tonight.

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Write a comment saying:

The is a comment

A

This is a comment

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Legal or Not Legal for naming variables?

A
  • legal
  • legal
  • illegal variables cannot start with digits
  • legal
  • illegal variables can only have letters, digits, and underscores
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is a variable?

A

variables are memory locations of the computer which are used for storing the data values temparory , during the execution of an application.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Which of the following are illegal variable names in Python, and why?

  • x
  • 99bottles
  • july2009
  • theSalesFigureForFiscalYear
  • r&d
  • grade_report
A

The 5th and 3rd variable is incorrect

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Is the variable name Sales the same as sales? Why or why not?

A

These are different variables. One is capital and one is lower case.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Is the following assignment statement valid or invalid? If it is invalid, why?

72 = amount

A

the statement is illegal. The variable comes first before the value.

amount = 72 # valid

72 = amount # invalid

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

What will the following code display?

val = 99

print(‘The value is’, ‘val’)

A

The value is val

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

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?

A
  1. integer
  2. float
  3. float
  4. integer
  5. string
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

What will be displayed by the following program?

my_value = 99

my_value = 0

print(my_value)

A

0

The first variable got overwritten or redefine.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

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.

A

c_last_name = input(“Enter the customer’s last name”)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

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.

A

sales_for_the_week = float(input(“Enter the amount of sales for the week: “) )

22
Q

Python Math Operators

A
23
Q

What value will be assigned to result after the following statement executes?

result = 9 // 2

A

4

24
Q

What value will be assigned to result after the following statement executes?

result = 9 % 2

A

1

25
Q

What does the argument end=’ ‘ do to the function, as shown in the following code:

print(‘One’, end=’ ‘)

print(‘Two’, end=’ ‘)

print(‘Three’)

A

It will print the following code:

One Two Three

26
Q

What does the argument end=’‘ do to the function, as shown in the following code:

print(‘One’, end=’’)

print(‘Two’, end=’’)

print(‘Three’)

A

It will print the following code:

OneTwoThree

27
Q

What is the Separator argument use in print functions to seperate multiple arguments ?

A

sep=’ ‘

28
Q

print this sentence is two different ways:

One Two Three

A

and

**print('One', 'Two', 'Three')**
#and

print(‘One Two Three’)

print(‘One’, ‘Two’, ‘Three’, sep=’ ‘)

29
Q

Print the following code in 2 different ways:

OneTwoThree

A

and

print(‘OneTwoThree’)

print(‘One’, ‘Two’, ‘Three’, sep=’’)

30
Q

print the sentence in two different ways:

One*Two*Three

A

and

print(“One*Two*Three”)

print(‘One’, ‘Two’, ‘Three’, sep=’*’)

31
Q

Escape Characters

A
32
Q

What is the format specifier and what does it do?

A

The format specifier is a string that contains special characters specifying how #the numeric value should be formatted.

format( number, ‘f)orformat(number, ‘d)

33
Q

print the following number and round it to the nearest tenths:

12345.6789

A

print(format(12345.6789, ‘.1f’))

34
Q

How to format a number in Scientific Notation?

A

format( , ‘e’)

35
Q

How to format a number where it has commas?

A

format( number , ‘,f’) or format( number , ‘,d’)

36
Q

How to format a number to do a certain amount of spaces?

A

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’))
37
Q

How to format a number into a decimal?

A

format( decimal , % ’)

38
Q

How to format an integer to have commas?

A

output—> 123456

format( integer, ‘d’)

Example

  • print(format(123456, ‘10d’))
  • print(format(123456, ‘20d’))
  • print(format(123456, ‘10,d’))
39
Q

A __________ is a single function that the program must perform in order to satisfy the customer.

A

software requirement

40
Q

An informal language that has no syntax rules and is not meant to be compiled or executed is called __________.​

A

pseudocode

41
Q

A __________ is a sequence of characters.​

A

string

42
Q

A __________ is a name that references a value in the computer’s memory.

A

variable

43
Q

A __________ is any hypothetical person using a program and providing input for it.

A

user

44
Q

A string literal in Python must be enclosed in _____.

A

either single-quotes or double-quotes.

45
Q

A(n) __________ makes a variable reference a value in the computer’s memory.​

A
46
Q

Round 12345.6789 to the nearest hundrends

print the following code:

A

Answer

format(12345.6789, ‘.2f’)

47
Q
  • print the number 12345.6789 in scienctic notation.
  • print the number 12345.6789 in scientic notation and round to the nearest hundrendths.
A

The output—> 1.234568e+04

print(format(12345.6789, ‘e’))

print(format(12345.6789, ‘.2e’))

48
Q
  • 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.
A

Output—-> 12,345.68

print(format(12345.6789, ‘,.2f’))

print(format(12345.6789, ‘,f’))

49
Q
  • Convert the number .5 into a percentage.
A

Output—> 50.0000%

print(format(0.5, ‘%’))

print(format(0.5, ‘.0%’))

50
Q

In the expression 12 + 7, the values on the right and left of the + symbol are called_________.

A

operands

51
Q

what operator performs integer division?

A

//

52
Q

what operator raises a number to a power?

A

**