quiz 2

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

What is a set of well-defined logical steps that must be taken to perform a task.

Algorithm

. What is pseudocode?

An informal language that has no syntax rules, and is not meant to be compiled or executed. Instead, programmers use pseudocode to create models, or "mock-ups" of programs.

) This symbol marks the beginning of a comment in Python.

#

This operator performs division, but instead of returning the quotient it returns the remainder.

%

3. Computer programs typically perform what three steps?

(STEP 1) Input is received. (STEP 2) Some process is performed on the input. (STEP 3) Output is produced.

This is an operator that raises a number to a power

**

This operator performs integer division

//

Which of the following statements will cause an error?

17=x

6. What is a magic number? Why are magic numbers problem

6. A magic number is an unexplained value that appears in a program's code. Magic numbers can be problematic, for a number of reasons. First, it can be difficult for someone reading the code to determine the purpose of the number. Second, if the magic number is used in multiple places in the program, it can take painstaking effort to change the number in each location, should the need arise. Third, you take the risk of making a typographical mistake each time you type the magic number in the program's code

7. Assume a program uses the named constant PI to represent the value 3.14159. The program uses the named constant in several statements. What is the advantage of using the named constant instead of the actual value 3.14159 in each statement

7. The named constant makes the program more self-explanatory. In a math statement, it is evident that PI represents the value of pi. Another advantage to using the named constant is that widespread changes can easily be made to the program. Let's say the value of pi appears in several different statements throughout the program. If you need to change the number of decimal places of precision used with the number, the initialization value in the declaration of the named constant is the only value that needs to be modified. For example, to use only two decimal places of precision, the declaration can be changed to: PI = 3.14 The new value of 3.14 will then be used in each statement that includes the PI constant. Another advantage to using the named constant is that it helps to prevent the typographical errors that are common when using magic numbers. For example, if you accidentally type 31.4159 instead of 3.14159 in a math statement, the program will calculate the wrong value. However, if you misspell PI, the Python interpreter will display a message indicating that the name is not defined.

) A magic number is -------------

An unexplained value that appears in a programs code

) A(n) ----------- makes a variable reference a value in the computer's memory

Assignment statement

Short notes placed in different parts of a program explaining how those parts of the program work are called

Comments

What is a string literal in Python must be enclosed in

Either single quotes or double

1. Programmers must be careful not to make syntax errors when writing pseudocode programs

F

3. Variable names can have spaces in them

F

5. If you print a variable that has not been assigned a value, the number 0 will be displayed.

F

What is a diagram that graphically depicts the steps that take place in a program?

Flowchart

1. What does a professional programmer usually do first to gain an understanding of a problem

Interview the customer

What error does not prevent the program from running, but causes it to produce incorrect result

Logic

What is an informal language that has no syntax rules and is not meant to be compiled or executed ?

Pseudocode

What is a single function that the program must perform in order to satisfy the customer

Software requirement

What is a sequence of characters

String

2. In a math expression, multiplication and division take place before addition and subtraction

T

4. In Python, the first character of a variable name cannot be a number.

T

) What is any hypothetical person using a program and providing input for it

User

What is a name that references a value in the computer's memory

Variable

4. If a math expression adds a float to an int, what will the data type of the result be

float

Suppose the following statement is in a program: price = 99.0. After this statement executes, the price variable will reference a value of which data type

float

) Which built-in function can be used to convert an int value to a float?

float()

5. What is the difference between floating-point division and integer division

floating point division returns a floating point number that may include fractions. Integer division returns an integer and ignores any fractional part of the division result.

) Which built-in function can be used to read input that has been typed on the keyboard

input()

) A is a name that represents a value that does not change during the program's execution

named constant

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

operands


Set pelajaran terkait

what is life, chapter 1 lesson 1 - science

View Set

Childress study guide final fall semester

View Set

Unit 1: The Biology of Psychology

View Set

Chapter 11: Health Assessment Prep U

View Set

World History Chapter 4 Section 3

View Set