# 01-CS-UY 1114：Lab 1

AI悦创原创PythonPython一对一教学Python一对一辅导Python 辅导编程一对一教学少儿编程一对一NYU编程辅导NYU Python辅导PythonPython一对一教学Python一对一辅导Python 辅导编程一对一教学少儿编程一对一NYU编程辅导NYU Python辅导大约 6 分钟...约 1829 字

## IO and Types

You must get checked out by your lab CA prior to leaving early. If you leave without being checked out, you will receive 0 credit 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

Answer Problem 1 on a piece of paper or on a text editor on your computer.

## Problem 1: Variables

### Part 1A: Variable Naming Conventions

Which of the following follow the snakecase naming convention? Select all that apply.

``````1. firstVariable = 3
2. second_variable = "word"
3. Third_var = 4.0
4. var4 = False
5. fifth_Variable = 'b'
``````

### Part 1B: Variable Types

State the data type of each variable in Part 1A

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

## Problem 2: Baking Scones

You have been wanting to bake scones and have found a recipe, but the recipe is in metric 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 # 75克咸黄油
350 g flour # 350克面粉
150 ml milk  # 150毫升牛奶
``````

Here are some conversion factors you can use:

``````75 grams butter = 1/3 cup of butter  # 75克黄油= 1/3杯黄油
150 gram flour = 1 cup flour  # 150克面粉= 1杯面粉
100 ml milk = 1/2 cup milk  # 100毫升牛奶= 1/2杯牛奶
``````

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 scone you want to make: 25  # 输入你想做的司康饼的数量:25
To make 25 scones use 0.8333333333333334 cups butter, 5.833333333333333 cups  # 制作25个司康饼需要0.8333333333333334杯黄油，5.8333333333333333333杯
flour, and 1.875 cups milk # 面粉，1.875杯牛奶
``````

## Problem 3: I Scream, You Scream, We All Scream for Ice Cream

The weather is still dreadfully hot and I love ice cream so lets 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

1. 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!

Look at the following image for reference on what we mean by a cone with multiple scoops.

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
``````
``````输入你想要的冰淇淋勺的数量:3

``````

## 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.
``````
``````你还有多少天?3.

3天7小时41分16秒等于286876秒。
``````

AI悦创·编程一对一

AI悦创·推出辅导班啦，包括「Python 语言辅导班、C++ 辅导班、java 辅导班、算法/数据结构辅导班、少儿编程、pygame 游戏开发、Web、Linux」，全部都是一对一教学：一对一辅导 + 一对一答疑 + 布置作业 + 项目实践等。当然，还有线下线上摄影课程、Photoshop、Premiere 一对一教学、QQ、微信在线，随时响应！微信：Jiabcdefh

C++ 信息奥赛题解，长期更新！长期招收一对一中小学信息奥赛集训，莆田、厦门地区有机会线下上门，其他地区线上。微信：Jiabcdefh

• 0
• 0
• 0
• 0
• 0
• 0

• 按正序
• 按倒序
• 按热度