Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
HOMEWORK HELP
#1
Hey guys, I have been given a list of questions to answer using this code. Ive answered some of them but some I have no answer for and would appreciate help and explaining.
(a)List all of the function arguments in this program. (no answer)
(b) List all of the function parameters in this program. (line 10, 22, 25, 28)
© List all of the variables that are not arguments or parameters. (line 7, 18)
(d) What is the scope of the folowing variables: (no answer)
i. number_of_blankets
ii. total
iii. customer1
iv. total_before_tax
(e) How many function denitions are in this program? (line 1, line 10)
(f) How many function calls are in this program? (line 18?)
(g) What are the values referred to by customer1 and customer2 when the program ends? (blanket_total(1,5) & blanket_total(3,4)







1 def add_tax ( subtotal ):
2 ’’’
3 Adds 5% tax to the subtotal input
4 subtotal is the amount before tax
5 returns total the amount including tax
6 ’’’
7 total = subtotal + 0.05* subtotal
8 return total
9
10 def blanket_total ( number_of_blankets , price_per_blanket ):
11 ’’’
12 Computes the total amount due for the purchase of a number_of_blankets ,
13 including 5% tax
14 number_of_blankets is the number of blankets purchased
15 price_per_blanket is the price for each blanket
16 returns the total for the customer
17 ’’’
18 total_before_tax = number_of_blankets * price_per_blanket
19 return add_tax ( total_before_tax )
20
21 # compute the total for a customer who purchases 1 blanket at $5 per blanket
22 customer1 = blanket_total (1 ,5)
23
24 # compute the total for a customer who purchases 3 blankets at $4 per blanket
25 customer2 = blanket_total (3 ,4)
26
27 # compute the total for a customer who purchases 5 blankets at $6 per blanket
28 customer3 = blanket_total (5 ,6)
Reply
#2
a) https://docs.python.org/3/tutorial/contr...-functions
d) https://docs.python.org/3/tutorial/class...namespaces
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020