0% found this document useful (0 votes)
74 views3 pages

Write A Python Program To Find Average of Three Numbers Entered by The User

This document contains 5 Python programs written by Agamjot Singh, a CSE student with SID 22103008. The programs include: 1) calculating the average of 3 numbers, 2) computing income tax based on inputted gross income and dependents, 3) converting seconds to minutes and seconds, 4) adding three values with mixed data types and producing a string result, 5) printing the sine and cosine of angles from 0 to 345 degrees in 15 degree increments rounded to 4 decimal places.

Uploaded by

Agamjot Singh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
74 views3 pages

Write A Python Program To Find Average of Three Numbers Entered by The User

This document contains 5 Python programs written by Agamjot Singh, a CSE student with SID 22103008. The programs include: 1) calculating the average of 3 numbers, 2) computing income tax based on inputted gross income and dependents, 3) converting seconds to minutes and seconds, 4) adding three values with mixed data types and producing a string result, 5) printing the sine and cosine of angles from 0 to 345 degrees in 15 degree increments rounded to 4 decimal places.

Uploaded by

Agamjot Singh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Name: Agamjot Singh

SID: 22103008
Branch: CSE

1. Write a Python program to find average of three numbers entered by the user.

Code:

a=int(input('Enter Number 1:'))


b=int(input('Enter Number 2:'))
c=int(input('Enter Number 3:'))
print('The average of the three numbers is:',(a+b+c)/3)

Output:

2. Write a python program to compute a person's income tax. Assume following

tax laws:

• All taxpayers are charged a flat tax rate of 20%.

• All taxpayers are allowed a $10,000 standard deduction.

• For each dependent, a taxpayer is allowed an additional $3,000 deduction.

• Gross income must be entered to the nearest penny.

Gross Income and the number of dependents must be asked from the user.

Hint:

Taxable income = GrossIncome - Standard deduction - (Dependent deduction

* No. of dependents)

Tax = Taxable Income * Tax Rate

Code:

a=int(input('Enter your Gross Income:'))


b=int(input('Enter the number of Dependants:'))
c=(a-10000-(b*3000))
print('Tax:',c*0.2)
Output:

3. Write a program that asks the user for a number of seconds and prints out
Name: Agamjot Singh
SID: 22103008
Branch: CSE

how many minutes and seconds that is. For instance, 200 seconds is 3

minutes and 20 seconds. [Hint: Use the //operator to get minutes and the %

operator to get seconds.]

Code:

a=int(input('Enter the number of seconds:'))


b=a//60
c=a-(b*60)
print('Seconds converted to minutes is '+ str(b) +"minutes" +str(c)
+"seconds")
Output:

4. Write a python program to add three numbers 25+’25’+25.0 and produce

result 75 as string.

Code:

a=25
b='25'
c=25.0
b=int(b)
d=(a+b+c)
d=str(d)
print('Sum is:' +str(d))
print(type(d))

Output:

5. Write a program that prints out the sine and cosine of the angles ranging

from 0 to 345◦ in 15◦ increments. Each result should be rounded to 4

decimal places. Sample output is shown below:

Code:

import math
Name: Agamjot Singh
SID: 22103008
Branch: CSE

for x in range(0,360,15):
d=math.sin(x*3.14/180)
e=math.cos(x*3.14/180)
print(str(x) + "---" + str(round(d,4)) +str(round(e,4)))

Output:

You might also like