You are on page 1of 5

Thareja: Python Programming

Solutions to Review Questions: Chapter 1

41.

Step 1: Start
Step 2: Input Basic, HRA, TA, DA
Step 3: Set Gross_salary = Basic + HRA + TA+ DA
Step 4: Set tax = 0.10 * Gross_salary
Step 5: Set salary = Gross_salary – tax
Step 6: Print salary
Step 7: End

©Oxford University Press. All rights reserved. 1


Thareja: Python Programming

42.
a) and b) are too general. Try it yourself.
c)
Step 1: Read number of items as n
Step 2: Set I = 0
Step 3: Set total = 0
Step 4: Repeat step 5 – 9 while I <n
Step 5: Read quantity as q and price as p
Step 6: Set item_price = q * p
Step 7: Set price = price + item_price
Step 8: Set I = I + 1
Step 9: Print price
Step 10: End

©Oxford University Press. All rights reserved. 2


Thareja: Python Programming

d)

Step 1: Read number as x


Step 2: If x < 0
Print “Negative”
Else
Print “Positive”
Step 3: End

©Oxford University Press. All rights reserved. 3


Thareja: Python Programming

e) Refer to solution 42(c)


f)
Step 1: Read length as l, breadth as b
Step 2: Calculate area = l * b
Step 3: Print area
Step 4: End

g) Refer to solution 42(f)

©Oxford University Press. All rights reserved. 4


Thareja: Python Programming

h)
Step 1: Set I = 0
Step 2: Set sum = 0
Step 3: Repeat Steps 4 - 6 while I < 10
Step 5: Set sum = sum + i
Step 6: Set I = I + 1
Step 7: Print sum
Step 8: End

©Oxford University Press. All rights reserved. 5

You might also like