Introduction to Computer Programming Study Guide #1



Introduction to Computer Programming Study Guide #1

1. Fill in the blank

1. Computers process data under the control sets of instructions called computer _________

2. The six key logical units of the computer are_____,_____,_____,_____,____,_____

3. The three classes of languages are called ______________,___________,_____________

2. State whether each of the following is true or false. If false, explain why.

1. Hardware refers to the instructions that command computers to perform actions and make decisions.

2. Software systems called batches manage the transitions between jobs.

3. Objects are reusable software components that model items in the real world.

3. Fill in the blank

1. The __________ statement instructs the computer to display information on the screen

2. A ____________ is a Python data type that contains a sequence of characters

3. _____________ are used to document a program and improve its readability

4. State whether each of the following is true or false. If false, explain why.

1. The Python function get_input requests input from the user.

2. The != is an example of a relational operator.

3. A variable name identifies the kind of information stored in an object.

4. If parentheses are nested, the expression in the innermost pair is evaluated first.

5. Fill in the blank

1. The if/elif/else structure is a _________________structure.

2. A _________ is a graphical representation of a program.

6. State whether each of the following is true or false. If false, explain why.

1. Pseudocode is a simple programming language.

2. A repetition structure performs the statements in its body while some condition remains true.

3. The exponentiation operator associates from left to right.

4. The symbol = tests for equality.

7. State the order of evaluation of the operators in each of the following Python statements and show the value of x after each statement.

1. x = 7 + 3 * 6 / 2 – 1

2. x = ( 3 * 9 * ( 3 + ( 9 * 3 / ( 3 ) ) )

8. Write a program that requests the user to enter two numbers and prints the sum, product, difference, and quotient of the two numbers.

9. Write a program that reads in the radius of a circle and prints the circle’s diameter, circumference, and area. Use the constant value 3.14159 for PI. Do these calculations in output statements.

10. Write a program that reads in two integers and determines and prints whether the first is a multiple of the second. (Hint: Use the modulus operator)

11. Drivers are concerned with the mileage obtained by their automobiles. One driver has kept track of several tankfuls of gasoline by recording miles driven and gallons used for each thankful. Develop a Python program that prompts the user to input the miles driven and gallons used for each tankful. The program should calculate and display the miles per gallon obtained for each tankful. After processing all input information, the program should print the combined miles per gallon obtained for all tankfuls (= total miles driven divided by total gallons used). The output should be similar to the following.

Enter the gallons used (-1 to end): 12.8

Enter the miles driven: 287

The miles / gallon for this tank was 22.421875

Enter the gallons used (-1 to end): 10.3

Enter the miles driven: 200

The miles / gallon for this tank was 19.417475

Enter the gallons used (-1 to end): 5

Enter the miles driven: 120

The miles / gallon for this tank was 24.00000

Enter the miles driven: -1

The overall average miles / gallon was 21.601423

12. Write a program that simulates the roll of two six-sided dice 1000 times. Keep track of the number of 2’s, 3’s, 4’s, 5’s, 6’s, 7’s, 8’s, 9’s, 10’s, 11’s, and 12’s. Output the sum of the two dice rolls and the number times each was rolled in a tabular format.

2's 34

3's 58

4's 72

5's 119

6's 140

7's 148

8's 163

9's 102

10's 88

11's 49

12's 27

13. Review the concepts of string concatenation and string repetition. Review the string manipulation methods listed in the notes from chapter 2.

................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download