Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Create a program using floored division and the modulo operator Description Suppose you are working for an online bookseller, who specializes in coffee table books

image text in transcribedimage text in transcribed

Create a program using floored division and the modulo operator Description Suppose you are working for an online bookseller, who specializes in coffee table books with colorful pictures. You have customers who routinely order multiple books at a time. You need to figure out, given a customer's order, how many standard full boxes will need to be shipped, and how many books are left over to be shipped in a smaller box. Objectives The objectives of this lab are as follows: to become familiar with floored division and the modulo operator to practice arithmetic expressions and assignment to variables to think about types and use type conversion to review input and output operators A standard shipping box is 18 inches long x 12 inches wide x 10.5 inches tall. A standard size hardcover coffee table book is 16 inches long x 10 inches wide x 1.2 inches thick. Books are stacked into the shipping boxes one on top of the other, with one inch padding on each side. In other words, one book plus side padding will exactly fit into the bottom of the box. Your program will ask the user for the number of books the customer is ordering, and then compute how many standard boxes will need to be shipped. Use one variable to keep track of the number of boxes. Think about how you would solve this problem without a computer, and write down the steps you need (the algorithm). Then translate that algorithm into a Python program. Much of the program is already given to you. You should use floor division and the modulo operator to solve this problem. Ex: If the input is 15, the output is: Ex: If the input is 15, the output is: We will need 1 standard boxes. There will be 7 books left to ship in a smaller box. Ex: If the input is 25, the output is: We will need 3 standard boxes. There will be 1 books left to ship in a smaller box. 301826.1771416 LAB ACTIVITY 3.12.1: Lab 3B: Pack a box (floor division) 0/25 main.py 1 # compute number of boxes for given number of books 2 3 box_height = 10.5 4 book_thickness = 1.2 5 6 # compute the number of books per standar box. 7 books_per_box = 10.5 // 1.2 8 9 # now ask the user for the number of books the customer ordered 10 books_ordered = int(input("Input the number of books in the order: ")) 11 12 # compute the number of boxes needed. Store it in the variable called "num_boxes" 13 num_boxes = int(books_ordered // books_per_box) 14 print("We will need", num_boxes, "Standard boxes.", end='') 15 16 #compute how many books are left over, and then print the final message 17 books_left =int(books_ordered % books_per_box) 18 print("There will be", books_left, "books left to ship in a smaller box. ") 19

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Introduction To Constraint Databases

Authors: Peter Revesz

1st Edition

1441931554, 978-1441931559

More Books

Students also viewed these Databases questions

Question

Brief the importance of span of control and its concepts.

Answered: 1 week ago

Question

What is meant by decentralisation?

Answered: 1 week ago

Question

Write down the Limitation of Beer - Lamberts law?

Answered: 1 week ago

Question

Discuss the Hawthorne experiments in detail

Answered: 1 week ago

Question

Explain the characteristics of a good system of control

Answered: 1 week ago