Download Introduction to Computer Programming Study Guide #1

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts
no text concepts found
Transcript
Introduction to Computer Programming Study Guide #1
1 Fill in the blank
1.1 Computers process data under the control sets of instructions called computer _________
1.2 The six key logical units of the computer are_____,_____,_____,_____,____,_____
1.3 The three classes of languages are called ______________,___________,_____________
2 State whether each of the following is true or false. If false, explain why.
2.1 Hardware refers to the instructions that command computers to perform actions and make decisions.
2.2 Software systems called batches manage the transitions between jobs.
2.3 Objects are reusable software components that model items in the real world.
3 Fill in the blank
3.1 The __________ statement instructs the computer to display information on the screen
3.2 A ____________ is a Python data type that contains a sequence of characters
3.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.
4.1 The Python function get_input requests input from the user.
4.2 The != is an example of a relational operator.
4.3 A variable name identifies the kind of information stored in an object.
4.4 If parentheses are nested, the expression in the innermost pair is evaluated first.
5 Fill in the blank
5.1 The if/elif/else structure is a _________________structure.
5.2 A _________ is a graphical representation of a program.
6 State whether each of the following is true or false. If false, explain why.
6.1 Pseudocode is a simple programming language.
6.2 A repetition structure performs the statements in its body while some condition remains true.
6.3 The exponentiation operator associates from left to right.
6.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.
7.1 x = 7 + 3 * 6 / 2 – 1
7.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
3's
4's
5's
6's
7's
8's
9's
10's
11's
12's
34
58
72
119
140
148
163
102
88
49
27
13 Review the concepts of string concatenation and string repetition. Review the string manipulation methods
listed in the notes from chapter 2.