Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

PYTHON: Consider the code from the previous example with an additional print command at the very end, and explain whether the value of result would

PYTHON:

Consider the code from the previous example with an additional print command at the very end, and explain whether the value of result would actually be output by that command.

def AbsDiff(input_value, std_value=24): ''' std_value and input_value are int Computes absolute difference and returns it as int ''' if input_value > std_value: result = input_value - std_value else: result = std_value - input_value return result

std_l = 24 in_l = int(input("Enter length: ")) l_diff = AbsDiff(input_value=in_l) in_w = int(input("Enter width: ")) w_diff = AbsDiff(input_value=in_w, std_value=18) print("Length var:", l_diff, "Width var:", w_diff) print(result)

Consider the following code, and outline what changes would be needed to the prt_rules function if it were to be defined outside of get_qty instead of nested within it:

def get_qty(product, ship=False): min_qty = 0 if ship: min_qty = 5 def prt_rules(): print("Orders must be integer values") print("Cannot order more than", max_qty) print("Order must be at least", min_qty) do_over = True while do_over: prt_rules() invalue = input("Enter order quantity for " + product + ": ") if invalue.isdigit(): qty = int(invalue) else: continue if min_qty <= qty <= max_qty: do_over = False return qty

print("Welcome!") max_qty = 50 qty_A = get_qty("A", True) qty_B = get_qty(product="B") total = qty_A * 10 + qty_B * 15 print("Total order cost: $",total)

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 Management With Website Development Applications

Authors: Greg Riccardi

1st Edition

0201743876, 978-0201743876

More Books

Students also viewed these Databases questions

Question

State how to give negative criticism and achieve positive results.

Answered: 1 week ago