Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

please answer these in PYTHON USING FUNCTIONS . ************ need basic python programs only!!! ****** WITHOUT using IMPORT LIBRARIES, LISTS, TUPLES. please!!!!!!! Q1) Write a

please answer these in PYTHON USING FUNCTIONS. ************ need basic python programs only!!! ****** WITHOUT using IMPORT LIBRARIES, LISTS, TUPLES. please!!!!!!!

Q1) 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.

Q2) write a program that displays the results of multiplying the numbers in each set of five numbers entered by the user. The user should be able to provide as many sets of five numbers as desired i.e., the user should be asked (and can respond Yes or No) whether another set is to be entered. The program should also display the overall sum total of the results of all the multiplications. The prior algorithm should be restructured so that there is a separate function to handle just the entry of the set of numbers and their multiplication. The prior algorithm should be extended so that the set size is more flexible (i.e., not restricted to five numbers) and is specified by the user. Instead of asking the user whether another set is to be entered, the algorithm should ask how many numbers should be in the set to be multiplied. The user will enter 0 to signal that no more sets of numbers are to be provided.

Q3) 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.

Q4) 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

Oracle Database 11g SQL

Authors: Jason Price

1st Edition

0071498508, 978-0071498500

More Books

Students also viewed these Databases questions

Question

What is meant by Career Planning and development ?

Answered: 1 week ago

Question

What are Fringe Benefits ? List out some.

Answered: 1 week ago

Question

=+With whom does the firm have to negotiate?

Answered: 1 week ago

Question

=+Are there shop stewards?

Answered: 1 week ago