0% found this document useful (0 votes)
17 views

Lab 1

This document provides instructions for 4 problems in CS-UY 1114 Lab 1 on IO, Types, and Operators in Python. Students must get checked out by their lab CA before leaving, use only taught Python structures, and set up Python if needed. Problem 1 involves identifying constants, data types, and variable names. Problem 2 converts a scone recipe between metric and US customary units. Problem 3 calculates the volume of an ice cream cone. Problem 4 converts time inputs between days, hours, minutes, seconds and total seconds. Problem 5 converts a decimal number to Roman numerals.

Uploaded by

Nathan Wang
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views

Lab 1

This document provides instructions for 4 problems in CS-UY 1114 Lab 1 on IO, Types, and Operators in Python. Students must get checked out by their lab CA before leaving, use only taught Python structures, and set up Python if needed. Problem 1 involves identifying constants, data types, and variable names. Problem 2 converts a scone recipe between metric and US customary units. Problem 3 calculates the volume of an ice cream cone. Problem 4 converts time inputs between days, hours, minutes, seconds and total seconds. Problem 5 converts a decimal number to Roman numerals.

Uploaded by

Nathan Wang
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

CS-UY 1114: Lab 1

IO, Types, and Operators

You must get checked out by your lab CA prior to leaving early. If you leave without being
checked out, you will receive 0 credits for the lab.

Restrictions

The Python structures that you use in this lab should be restricted to those you have learned in
lecture so far. Please check with your course assistants in case you are unsure whether
something is or is not allowed!

If you do not have Python running on your computer please go back to Lab 0 and set it up
before moving on

For Problem 1, write your answers on paper or in a text editor on your computer.

Problem 1: Constantly Variable

Part 1A: Constant or Not:

State whether each of the following variables is a constant or not.

1. INCHES_IN_ONE_FOOT = 12
2. anotherVariable = 16.5
3. fEET_iN_oNE_mILE = “five thousand two hundred and eighty feet”
4. THINGS_MORE_FUN_THAN_LAB = 0
5. descriptive_variable_name = True
Part 1B: Data Types:

State the data type for each variable shown in Part 1A.

Create a new python file for each of the following questions.

Problem 2: Baking Scones?

You have been wanting to bake scones and have found a recipe, but the recipe uses the metric
system and you only have measuring cups. Let's convert the metric measures to customary
measurements.

The following are the metric measures for 10 scones:

75 g salted butter
350 g flour
150 ml milk

Here are some conversion factors you can use:

75 grams butter = 1/3 cup of butter


150 gram flour = 1 cup flour
100 ml milk = 1/2 cup milk

Your program should take user input for the number of scones they want to make and print the
quantity of each ingredient in customary measurements.

Your code should output the following (disregard small floating point differences):
Enter the number of scones you want to make: 25
To make 25 scones use 0.8333333333333334 cups butter,
5.833333333333333 cups flour, and 1.875 cups milk

Problem 3: Screaming for Ice Cream!

Write a program that will:

1. Take user input for number of ice cream scoops, radius of the ice cream cone, and height of
the ice cream cone.
2. Calculate and print the total volume of the ice cream cone. Use 3.1416 as an
approximation for PI.

We will be assuming we have perfectly spherical ice cream scoops and a perfect ice cream
cone!

The formula for sphere volume is as follows and will be used for each ice cream scoop:
The formula for cone volume is as follows and will be used for the ice cream cone:

Your code should output the following

Enter the number of ice cream scoops you want: 3


Enter the radius of ice cream cone: 3.5
Enter the height of ice cream cone: 8.9
Your 3 scoop ice cream cone has a total volume of 652.95538

Problem 4: Time in seconds

This program will ask the user for four inputs: a number of days, number of hours, number of
minutes, and number of seconds. This may look something like:

How many days do you have?


How many hours do you have?
How many minutes do you have?
How many seconds do you have?
You may assume that the user will always input a positive whole number. After getting the
four inputs, the function should calculate how many seconds in total are in the given number of
days, hours, minutes and seconds, and output the result. The final output of the program
should be something like this:

How many days do you have? 3


How many hours do you have? 7
How many minutes do you have? 41
How many seconds do you have? 16
3 Days 7 Hours 41 Minutes and 16 Seconds results in a total of
286876 Seconds.

Problem 5: All Roads Lead To Rome

This problem will convert a decimal number to Roman Numerals.

1. Ask the user to input a decimal integer less than 100.


2. Convert the input to Roman numbers and print to the screen.

Roman numerals and decimals follow the table below.

For this problem there is no need to consider subtractions.


i.e., 4 = IIII, 9 = VIIII instead of IV and IX respectively.

Hint: Use div and mod. Do not use conditionals to solve the problem

You might also like