$29
CMPSC 101
Homework 1 – Basic output and computation
Instructions: For problems 6-8 write Python scripts (.py files). Use variables where necessary and give meaningful
names to variables. All script files should have a comment block at the top. Each Python instruction in the script must
be preceded by a comment explaining the instruction. Upload a .pdf file containing your solution along with your .py
files. If you solve on paper, please upload a good quality scan using CamScanner/Office Lens/iScanner.
Problem 1. Write a python statement that displays the following text: [10 points]
“I don’t care,” she said. “What do you think?”
Problem 2. Create two variables to store your first name and last name. Display your full name
by referencing those variables. [10 points]
Problem 3. What will be the output of the following code? [10 points]
num = 113
print(‘The value is’, ‘num’)
Problem 4. Given the assignment x = 97, what will be the output of each of the following Python
statements? [10 points]
(a) print(“x”)
(b) print(‘x’)
(c) print(x)
(d) print(“x + 1”)
(e) print(‘x’ + 1)
Problem 5. For the given assignment statements, what will be the Python data type of the
variables? [10 points]
(a) val1 = 15.00
(b) val2 = 9
(c) val3 = ‘7’
(d) val4 = 3.7
(e) val5 = ‘abc’
Problem 6. Draw a flowchart and write a program that displays the perimeter of a circle that has
a radius of 8.1 using the formula 𝑝𝑒𝑟𝑖𝑚𝑒𝑡𝑒𝑟 = 2 × 𝑃𝐼 × 𝑟𝑎𝑑𝑖𝑢𝑠. Use PI = 3.14. [25 points]
Problem 7. The distance between two cities is 500 miles. Draw a flowchart and write a program
to display the distance in kilometers. Assume 1 mile = 1.6 kilometers. [25 points]
Problem 8 (bonus). Write a program to compute the surface area and volume of a cylinder. The
program should prompt the user to input the radius and length of the cylinder, and should output
the surface area and volume based on the formulas 𝑎𝑟𝑒𝑎 = 𝑃𝐼 × 𝑟𝑎𝑑𝑖𝑢𝑠 × 𝑟𝑎𝑑𝑖𝑢𝑠 and
𝑣𝑜𝑙𝑢𝑚𝑒 = 𝑎𝑟𝑒𝑎 × 𝑙𝑒𝑛𝑔𝑡ℎ. Use PI = 3.14. [20 points]