Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

PYTHON Specification for Practice Problem The postage for each mailed item depen

ID: 3804220 • Letter: P

Question

PYTHON

Specification for Practice Problem The postage for each mailed item depends on the base cost of the item: if the base cost is less than 100, then an amount lowpastagne is charged: otherwise, highposage is charged The total cost of an kem is the sum of its base cost and This program inputs the quantity and base cost of 2 items as integers, and outputs the sum of the tocal costs for them, agai Specification forPractice Problem 2 This program asks the user to enter the month asaninoeger between land 12 and he year. It then displays the number of days in that month. uses the following aiteria identify leap the year is divisible by 100 then itisa leap year if and only it is also divisible by 400. the year is not divisible by 100, then it is leap year if and only if it is divisible by 4.

Explanation / Answer


def postage():
   base_cost1=input("Enter base cost for item 1")
   Quan1=input("Enter Quantity for item 1")
   base_cost2=input("Enter base cost for item 2")
   Quan2=input("Enter Quantity for item 2")

   total_cost1=0
   total_cost2=0
   lowpost=50
   highpost=100
   if base_cost1<100:
       total_cost1=base_cost1+lowpost
   else:
       total_cost1=base_cost1+highpost
   if base_cost2<100:
       total_cost2=base_cost2+lowpost
   else:
       total_cost2=base_cost2+highpost

   total_cost2=total_cost2*Quan2
   total_cost1=total_cost1*Quan1

   print "Total cost of Item 1 is ",total_cost1
   print "Total cost of Item 2 is ",total_cost2
   Total=total_cost1+total_cost2
   print "Total cost of both items is ",Total


postage()


==================================================

Output:

akshay@akshay-Inspiron-3537:~/Chegg$ python postage.py
Enter base cost for item 1 100
Enter Quantity for item 1 2
Enter base cost for item 2 150
Enter Quantity for item 2 2
Total cost of Item 1 is 400
Total cost of Item 2 is 500
Total cost of both items is 900


=======================================================

def is_leap_year(year):
    return (year % 4 == 0) and (year % 100 != 0) or (year % 400 == 0)


def days_in_month(month, year):

    print "Number of days are "
    if month == 9 or month == 4 or month == 6 or month == 11:
        print 30
    elif month == 1 or month == 3 or month == 5 or month== 7 or month == 8 or month == 10 or month== 12:
        print 31
    elif month == 2 and is_leap_year(year) == True:
        print 29
    elif month == 2 and is_leap_year(year) == False:
        print 28
    else:
        print 'Blank'


print "Enter year "
year=input()
print "Enter Month "
month=input()

days_in_month(month,year)

=========================================================

Output:

akshay@akshay-Inspiron-3537:~/Chegg$ python leap.py
Enter year
2004
Enter Month
2
Number of days are
29