Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Basic python programs ( beginner level ) using functions. WITHOUT USING IMPORT LIBRARIES! QUESTION 1: Write a program that compares two pizza offers and identifies

Basic python programs ( beginner level ) using functions. WITHOUT USING IMPORT LIBRARIES!

QUESTION 1:

Write a program that compares two pizza offers and identifies the one with the better value, i.e., lower cost per square inch of pizza. The user should be able to input the size (i.e., diameter in inches) and cost of each pizza. Note that the area of a circle is 3.14 times the square of its radius (which is half of the diameter.) Avoid writing repetitive code for the computation.

QUESTION 2:

The program should ask users for their last name, validate it (i.e., check it against business rules), and then display it as confirmation with only the first letter capitalized, e.g., John. If the name is not valid per our business rules, the display should be an appropriate error message instead and the user should be prompted for an input until a valid input is obtained. Each of these two rules for last names at our business should be structured as a separate function: Names must be no longer than 20 characters but must be at least two characters. Names may have an apostrophe (e.g., ORourke) and/or a hyphen (e.g., Smith-Barnes) but no other punctuation, no spaces, and no numbers. For example, we dont allow Smith Jr. (has space and period) or Smith III (has space). The program should also display how many times each of the two rules was violated before a valid input was obtained.

QUESTION 3:

A widget shop sells two types of widgets. Widget A is priced at $17 each and Widget B at $29 each. A volume discount is provided based on a two-digit code stored in the program with the first digit showing the reduction in unit price for every unit of Widget A ordered beyond 10 units. Similarly, the second digit shows the reduction for every unit of Widget B beyond 5 units. The discount code currently is set to 23, i.e., $2 off the price of Widget A and $3 off the price of Widget B if the volume conditions are met. (The discount code could be changed from time to time.) Sales tax is charged at 7.5% after discounts unless the order is for out of state, in which case it is 5%. Shipping costs are $1.15 per widget in state and $2 per widget out of state. There is also a fixed handling cost of $12.50 for an entire order. (Sales tax is not charged on shipping and handling costs.) Write a program that asks users for their name and the order quantity of each type of widget and whether the order is for out of state. (Most orders are in state.) The program should validate each order quantity to ensure it is a non-negative integer. It should display the users name in all messages, e.g., error messages, order summary, etc. It should show the total cost to the user. (The total cost should be rounded to two places after the decimal.) The program should be modular, i.e., there should be separate functions to handle input of quantity, discount, tax, shipping, and cost computations.

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

Database Reliability Engineering Designing And Operating Resilient Database Systems

Authors: Laine Campbell, Charity Majors

1st Edition

978-1491925942

More Books

Students also viewed these Databases questions

Question

Developing and delivering learning that is integrated with the job.

Answered: 1 week ago

Question

Use of assessments to determine trainees learning styles.

Answered: 1 week ago