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

Pythoncodes Class9

The document provides a series of Python programming exercises that involve user input and basic calculations. Tasks include checking if three angles form a triangle, converting temperatures, calculating areas, determining if a shape is a square, and applying discounts based on billing amounts. Additional exercises cover boolean operations, leap year checks, and string manipulations.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views3 pages

Pythoncodes Class9

The document provides a series of Python programming exercises that involve user input and basic calculations. Tasks include checking if three angles form a triangle, converting temperatures, calculating areas, determining if a shape is a square, and applying discounts based on billing amounts. Additional exercises cover boolean operations, leap year checks, and string manipulations.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 3

Unit-4 Introduction to Python

Part C Page no.-344

1. Input three numbers and check whether they form a triangle or not.
angle1 = int(input(“input the first angle”))
angle2 = int(input(“input the 2nd angle”))
angle3 = int(input(“enter the 3rd angle”))
sum= angle1+angle2+angle3
if sum==180:
print(“angles can make a triangle”)
else:
print(“angles cannot make a triangle”)

2. Input the temperature in Fahrenheit and convert in degrees.


f=int(input(“enter the temperature”))
c=((f/9)*5)-32
print (c)

3. Input time in seconds and change it into minutes.

s=float(input(“enter time in sec”))


m=s/60
print(“The time in minutes is”, m)

4. Find the result of 22/7*5*5 i.e. the area of circle having radius 5.

r=5
area=3.14*r*r
print(“The area is”, area)

5. Input length and breadth and display whether it is square or not.

L=int(input(“enter length”))
b=int(input(“enter breadth”))
if (L== b):
print(“it is a square”)
else:
print(“it is not a square”)
6. Input a number between 1 and 7 and display the weekly based on the number.

a=int(input(“enter a number between 1-7”))


if (a==1):
print(“Monday”)
elif(a==2):
print(“Tuesday”)
elif(a==3):
print(“Wednesday”)
elif(a==4):
print(“thursday”)
elif(a==5):
print(“friday”)
elif(a==6):
print(“Saturday”)
elif(a==7):
print(“sunday”)
else:
print(“Error”)
s=int(input(“Enter the salary”))
b=int(input(“Enter the years of service))

7)Take a Boolean value ‘false’ and a float number “15.6” and perform the AND
operation on both.

b=False
f=15.6
r=b and f
print (r)

8.) Input Salary and years of service. If the number of years is more than 5 then give an
extra bonus of 15%. Display the net salary after adding the bonus.

salary=int (input (“enter the salary”))


years=int (input (“enter the no. of years”))
if years>5:
bonus=(salary*1.5)
netsalary=salary+bonus
print(netsalary)
else:
print (salary)

9) Take a string ‘zero’ and a Boolean value ‘true’ and try adding both by bool function.
s= “zero”
b=True
r=(s)+str(b)
print(r)

10) Input a billing amount of shopping done. If the amount is more than 5000, then give
a discount of 10%. Display the net billing amount after the discount.

bill=int(input(“enter the billing amount:”))


discount=bill*0.1
if bill>5000:
netamount=bill-discount
print(netamount)
else:
print(bill)

11.Input a year and check whether it is a leap year or not.

y=int(input(“enter the year”))


if(y%4==0) or(y%400==0):
print(“its a leap year”)
else:
print(“its not a leap year”)

12. Same as 7.
13. Take a string ‘morning’ and float value ‘90.4’ and try adding both of them using the
float() function.

s= “morning”
f=90.5
r=float(s)+f
print(r)

You might also like