0% found this document useful (0 votes)
15 views7 pages

Class 9 Python

The document contains a series of Python programs that demonstrate various programming concepts, including calculating the area and circumference of a circle, compound interest, converting time to seconds, calculating employee salary, checking odd/even numbers, finding the greatest of three numbers, determining grades based on marks, checking leap years, applying discounts in a store, summing numbers, calculating factorials, generating multiplication tables, and printing a series of squares. Each program includes user input prompts and corresponding output examples. The code snippets are provided alongside their expected outputs for clarity.

Uploaded by

notdivit.1234
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)
15 views7 pages

Class 9 Python

The document contains a series of Python programs that demonstrate various programming concepts, including calculating the area and circumference of a circle, compound interest, converting time to seconds, calculating employee salary, checking odd/even numbers, finding the greatest of three numbers, determining grades based on marks, checking leap years, applying discounts in a store, summing numbers, calculating factorials, generating multiplication tables, and printing a series of squares. Each program includes user input prompts and corresponding output examples. The code snippets are provided alongside their expected outputs for clarity.

Uploaded by

notdivit.1234
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

1.

WAP to find the area and circumference of circle


OUTPUT CODE
Enter radius : 2 r = float(input("Enter radius : "))
Area : 12.56 ar = 3.14*r*r
Circumference : 12.56 cr = 2*3.14*r
print("Area : ",ar)
print("Circumference : ",cr)

2. WAP to calculate compound interest.


OUTPUT CODE
Enter Principal : 10000 p = int(input("Enter Principal : "))
Enter Rate of interest : 5 r = int(input("Enter Rate of interest :
Enter Time : 2 ")) t = int(input("Enter Time : "))
Compound Interest : amt =
25.0 p*(1+(r/100)**t) ci =
amt - p
print("Compound Interest : ",ci)

3. WAP to input Hours, Minutes and Seconds and display in seconds.


OUTPUT CODE
Enter Hours : 2 hr = int(input("Enter Hours : "))
Enter Minutes : 30 mn = int(input("Enter Minutes :
Enter Seconds : ")) sc = int(input("Enter Seconds
10 : ")) total = hr*3600 + mn*60 +
Time in seconds : 9010 sc
print("Time in seconds : ",total)

4. WAP to calculate salary of an employee when basic pay is entered by the user, HRA= 10% of
basic, TA = 5% of basic. Define HRA and TA as constants and use them to calculate total
salary as basic + HRA + TA
OUTPUT CODE
Enter Basic Salary : 10000 basic = int(input("Enter Basic Salary : "))
Total Salary : 11500.0 hra = 10/100*basic
ta = 5/100*basic
total = basic + hra + ta
print("Total Salary : ",total)
5. WAP to read any number and check whether it is odd or even.
OUTPUT CODE
Enter number : 10 num = int(input("Enter number :
Number is Even ")) if num%2==0 :
print("Number is Even")
else :
print("Number is odd")

6. WAP to read any 3 numbers and find greatest among them.


OUTPUT CODE
Enter number 1 : 10 a = int(input("Enter number 1 : "))
Enter number 2 : 15 b = int(input("Enter number 2 : "))
Enter number 3 : 12 c = int(input("Enter number 3 :
15 is greatest ")) if a>b and a>c:
print(a , "is greatest")
elif b>a and b>c :
print(b , "is greatest")
else:
print(c , "is greatest")

7. Write a program to decide the grade scored by candidate in an examination on the basis of marks
scored out of 100 as per the following:
Marks Scored Grade
90 and above A
Marks >= 80 and less than 90 (80-90) B
Marks >= 70 and less than 80 (70-80) C
Marks >= 60 and less than 70 (60-70) D
Mark less than 60 E
OUTPUT CODE
Enter your marks out of 100: 91 marks = int (input("Enter your marks out of 100:"))
You have got A grade if marks >= 90:

print ("You have got A grade")

elif marks >= 80:

print ("You have got B grade")

elif marks >= 70:

print ("You have got C grade")

elif marks >= 60:

print ("You have got B grade")

else:

print ("You have got E grade")

8. Any year is input by the user. Write a program to determine whether the year is a leap year or
not.
OUTPUT CODE
Enter year : 1995 yr = int(input("Enter year : "))
Not a Leap Year if yr%100 == 0 and yr%400 ==
0: print("Leap Year")
elif yr%4 == 0:
print("Leap
Year")
else :
print("Not a Leap Year")

9. Biglife is a garment store in a shopping complex. The store offers Diwali discount for its
happy customers as below. Input price per unit and number of units from the user and
calculate total amount to be paid.

Purchase Amount Discount


<=5000 400
>5000 And <=10000 800
>10000 and <=20000 1000
>20000 2000

OUTPUT CODE
Enter price per unit : 1000 price = int(input("Enter price per unit : "))
Enter quantity : 10 qty = int(input("Enter quantity : "))
Payable Amount : 9200 amt = price * qty
if amt<=5000 :
dis = 400
elif amt <=
10000 : dis =
800
elif amt <=20000 :
dis = 1000
else :
dis = 2000
final = amt -
dis
print("Payable Amount : ",final)

10. WAP to display Sum numbers from 1 to N


OUTPUT CODE
Enter value of n : 10 sum = 0
Sum : 55 n = int(input("Enter value of n : "))
for i in range (1 , n+1) :
sum = sum+i
print("Sum : ",sum)

11. WAP to find factorial of a number entered by the user.


OUTPUT CODE
Enter value of n : pro = 1
5 Factorial : 120 n = int(input("Enter value of n : "))
for i in range (1 , n+1) :
pro = pro*i
print("Factorial : ",pro)
12. WAP to enter a number and print its multiplication table
OUTPUT CODE
Enter the number whose table is to num = int (input (“Enter the number whose table
is to displayed: ”))
displayed: 2
for i in range (1, 11):
2 *1 = 2
print (num, “*”, i, “=”, num*i)
2 *2 = 4

2 *3 = 6

2 *4 = 8

2 *5 = 10

2 *6 = 12

2 *7 = 14

2 *8 = 16

2 *9 = 18

2 *10 = 20

13. WAP to print the following series 1,4,9,16 n


OUTPUT CODE
Enter value of n : n = int(input("Enter value of n : "))
51 for i in range (1 , n+1) :
4 print(i*i)
9
16
25

You might also like