2.11 LAB: Pizza party Given the number of people attending a pizza party, output the number of needed pizzas and total cost. For the calculation, assume that people eat 2 slices on average and each pizza has 12 slices and costs $14.95. Output each floating-point value with two digits after the decimal point, which can be achieved as follows: print (f'Cost: ${cost:.2f}') Hint: Use the ceil() function from the math module to round up the number of pizzas so that enough pizzas are ordered. Ex: If the input is: 4 the output is: Pizzas: 1 Cost: $14.95 411776.2636306.qx3zqy7 LAB 2.11.1: LAB: Pizza party ACTIVITY main.py Type your code here. *** 1 import math 2 3 4 | 0/10 Load default template...

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
**2.11 LAB: Pizza Party**

**Objective:**

Given the number of people attending a pizza party, output the number of needed pizzas and total cost. For the calculation, assume that people eat 2 slices on average and each pizza has 12 slices and costs $14.95.

**Output Specification:**

Output each floating-point value with two digits after the decimal point, which can be achieved as follows:

```python
print(f'Cost: ${cost:.2f}')
```

**Hint:** Use the `ceil()` function from the math module to round up the number of pizzas so that enough pizzas are ordered.

**Example:**

If the input is:

```
4
```

The output should be:

```
Pizzas: 1
Cost: $14.95
```

**Template:**

Below is the coding environment where you can implement the solution. The task involves writing a Python script that performs the specified calculations and outputs the formatted results.

```python
import math

''' Type your code here. '''
```

**Explanation:**

1. **Import Math Module:**
   - The program starts by importing the `math` module which is necessary for using the `ceil()` function.
   
2. **Read Input:**
   - The number of people attending the party is taken as input.

3. **Calculate Slices Needed:**
   - Each person eats 2 slices on average.
   - So, the total slices needed would be twice the number of people.

4. **Calculate Pizzas Needed:**
   - Each pizza has 12 slices.
   - Using the `ceil()` function, calculate the number of whole pizzas needed by dividing the total slices needed by the slices per pizza and rounding up.

5. **Calculate Total Cost:**
   - Multiply the number of pizzas by $14.95 to get the total cost.

6. **Format and Output:**
   - Print the number of pizzas and the total cost formatted to two decimal places.

**Additional Information:**

In the screenshot, there is a section labeled "2.11.1: LAB: Pizza party" which indicates the lab activity. Below it, an editable Python script area is provided, prompting users to type their code. There is also a scoring indicator (0/10), implying that the task is part of a graded assignment or assessment. 

This activity is intended to teach students not only how to perform mathematical calculations in Python
Transcribed Image Text:**2.11 LAB: Pizza Party** **Objective:** Given the number of people attending a pizza party, output the number of needed pizzas and total cost. For the calculation, assume that people eat 2 slices on average and each pizza has 12 slices and costs $14.95. **Output Specification:** Output each floating-point value with two digits after the decimal point, which can be achieved as follows: ```python print(f'Cost: ${cost:.2f}') ``` **Hint:** Use the `ceil()` function from the math module to round up the number of pizzas so that enough pizzas are ordered. **Example:** If the input is: ``` 4 ``` The output should be: ``` Pizzas: 1 Cost: $14.95 ``` **Template:** Below is the coding environment where you can implement the solution. The task involves writing a Python script that performs the specified calculations and outputs the formatted results. ```python import math ''' Type your code here. ''' ``` **Explanation:** 1. **Import Math Module:** - The program starts by importing the `math` module which is necessary for using the `ceil()` function. 2. **Read Input:** - The number of people attending the party is taken as input. 3. **Calculate Slices Needed:** - Each person eats 2 slices on average. - So, the total slices needed would be twice the number of people. 4. **Calculate Pizzas Needed:** - Each pizza has 12 slices. - Using the `ceil()` function, calculate the number of whole pizzas needed by dividing the total slices needed by the slices per pizza and rounding up. 5. **Calculate Total Cost:** - Multiply the number of pizzas by $14.95 to get the total cost. 6. **Format and Output:** - Print the number of pizzas and the total cost formatted to two decimal places. **Additional Information:** In the screenshot, there is a section labeled "2.11.1: LAB: Pizza party" which indicates the lab activity. Below it, an editable Python script area is provided, prompting users to type their code. There is also a scoring indicator (0/10), implying that the task is part of a graded assignment or assessment. This activity is intended to teach students not only how to perform mathematical calculations in Python
## 2.11 LAB: Pizza Party

### Objective

Given the number of people attending a pizza party, output the number of needed pizzas and the total cost. For the calculation, assume that people eat 2 slices on average and each pizza has 12 slices and costs $14.95.

### Instructions

1. **Calculate Slices Needed:** Determine the total number of pizza slices required by multiplying the number of people by the average number of slices consumed per person (2 slices).
2. **Calculate Pizzas Needed:** Determine the number of pizzas required by dividing the total number of slices needed by the number of slices per pizza (12 slices) using the `ceil()` function from the math module to round up to ensure enough pizzas are ordered.
3. **Calculate Total Cost:** Calculate the total cost by multiplying the number of pizzas by the cost per pizza ($14.95).

### Formatting Output

Output each floating-point value with two digits after the decimal point, which can be achieved using the following code snippet:

```python
print(f'Cost: ${cost:.2f}')
```

### Example

**Ex:** If the input is:

```
4
```

**The output is:**

```
Pizzas: 1
Cost: $14.95
```

### Code Template

Below is the code template for you to start with:

```python
import math

''' Type your code here. '''
```

### Implementation Notes

1. Use the `input()` function to get the number of people.
2. Use mathematical operations to compute the total number of pizzas and the total cost.
3. Use string formatting to ensure the cost is displayed with two decimal places.

### Lab Activity

This lab activity is scored out of 10 points. Make sure to test your solution with different inputs to verify its correctness.

---

Happy coding!
Transcribed Image Text:## 2.11 LAB: Pizza Party ### Objective Given the number of people attending a pizza party, output the number of needed pizzas and the total cost. For the calculation, assume that people eat 2 slices on average and each pizza has 12 slices and costs $14.95. ### Instructions 1. **Calculate Slices Needed:** Determine the total number of pizza slices required by multiplying the number of people by the average number of slices consumed per person (2 slices). 2. **Calculate Pizzas Needed:** Determine the number of pizzas required by dividing the total number of slices needed by the number of slices per pizza (12 slices) using the `ceil()` function from the math module to round up to ensure enough pizzas are ordered. 3. **Calculate Total Cost:** Calculate the total cost by multiplying the number of pizzas by the cost per pizza ($14.95). ### Formatting Output Output each floating-point value with two digits after the decimal point, which can be achieved using the following code snippet: ```python print(f'Cost: ${cost:.2f}') ``` ### Example **Ex:** If the input is: ``` 4 ``` **The output is:** ``` Pizzas: 1 Cost: $14.95 ``` ### Code Template Below is the code template for you to start with: ```python import math ''' Type your code here. ''' ``` ### Implementation Notes 1. Use the `input()` function to get the number of people. 2. Use mathematical operations to compute the total number of pizzas and the total cost. 3. Use string formatting to ensure the cost is displayed with two decimal places. ### Lab Activity This lab activity is scored out of 10 points. Make sure to test your solution with different inputs to verify its correctness. --- Happy coding!
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY