0% found this document useful (0 votes)
13 views6 pages

Python Programming Part-1

Defined about class 9 cbse python programing

Uploaded by

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

Python Programming Part-1

Defined about class 9 cbse python programing

Uploaded by

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

PYTHON PROGRAMMING : PART-1

CONTENTS
PROG.
BASIC PROGRAMMING QUESTIONS
NO
1 WAP to print personal information like father's Name, Class, School Name.
WAP to print this pattern.
*
**
2a
***
****
*****
WAP to print this pattern.
*****
****
2b
***
**
*
3 WAP to find a square of a number.
4 WAP to find the sum of two nos 15 and 20.
5 WAP to convert length given in kilometers into meters.
6 WAP to print the table of 5 up to five terms.
7 WAP to calculate SI, if the P=2000, R=4.5, T=10.
8 WAP to calculate area & perimeter of rectangle.
9 WAP to calculate area of a triangle with base & height.
10 WAP to calculate average marks of 3 subjects.
11 WAP to calculate discounted amount with discount %.
12 WAP to calculate surface area & volume of cuboid.
Kindly Save this formula in your Brain
Variable / Identifier = Constants / Literals
Variable / Identifier = Expression
Coding based on - I(Input) P(Process) O(Output)
Read/Input the data  Process the data  Output the Information

Page 1 of 6
PRINT BASED PROGRAM
'''PROG-1: WAP to print personal information like Declaration :
father's Name, Class, School Name''' Strings - Double quote things

Keyword :
print("Father's Name = Nityananda Pradhan") Function - print( )
print("Class Name = VIII")
print("School Name = REC Campus High School")

OUTPUT :
Father's Name = Nityananda Pradhan
Class Name = VIII
School Name = REC Campus High School
'''PROG-2a: WAP to print this pattern Declaration :
* Strings - Double quote things
**
Keyword :
*** Function - print( )
****
*****'''

print("*")
print("**")
print("***")
print("****")
print("*****")

OUTPUT :
*
**
***
****
*****
'''PROG-2b: WAP to print this pattern Declaration :
***** Strings - Double quote things
****
Keyword :
*** Function - print( )
**
*'''

print("*****")
print("****")
print("***")
print("**")
print("*")
OUTPUT :
Page 2 of 6
*****
****
***
**
*
'''PROG-3: WAP to find a square of a number''' Process execution :
no square
no=7 7 49
square=no*no
Declaration :
print("The number is =",no) Constants / literals - 7
print("The square value is =",square)
Strings - Double quote things
OUTPUT :
The number is = 7 Variables / identifiers -
The square value is = 49 no , square

Expression – no * no

Keyword :
Function - print( )
'''PROG-4: WAP to find the sum of two nos 15 and Process execution :
20''' no1 no2 total
15 20 35
no1=15
Declaration :
no2=20 Constants / literals – 15 , 20
total=no1+no2
print("The First no is = ",no1) Strings - Double quote things
print("The Second no is = ",no2)
print("The sum of two no is = ",total) Variables / identifiers -
no1 , no2, total
OUTPUT : Expression – no1 + no2
The First no is = 15
The Second no is = 20 Keyword :
The sum of two no is = 35 Function - print( )
'''PROG-5: WAP to convert length given in Process execution :
kilometers into meters''' km meter
4 4000
km=4
Declaration :
meter=km*1000 Constants / literals - 4
print("Length in Kilometers =",km)
print("Length in meters =",meter) Strings - Double quote things

OUTPUT : Variables / identifiers -


Length in Kilometers = 4 km , meter
Length in meters = 4000 Expression – km * 1000
Keyword :

Page 3 of 6
Function - print( )
'''PROG-6: WAP to print the table of 5 up to five Declaration :
terms''' Strings - Double quote things

Keyword :
print("5x1=",5*1) Function - print( )
print("5x2=",5*2)
print("5x3=",5*3)
print("5x4=",5*4)
print("5x5=",5*5)

OUTPUT :
5x1= 5
5x2= 10
5x3= 15
5x4= 20
5x5= 25
'''PROG-7: WAP to calculate SI, if the P=2000, R=4.5, Process execution :
T=10''' P R T SI
2000 4.5 10 900
P=2000
Declaration :
R=4.5 Constants / literals –
T=10 2000, 4.5, 10
SI=(P*R*T)/100
print("The Principal is =",P) Strings - Double quote things
print("The Rate of Interest is =",R)
print("The Time is =",T) Variables / identifiers -
P , R , T, SI
print("The Simple Interest is =",SI)
Expression – (P*R*T)/100
OUTPUT :
The Principal is = 2000 Keyword :
The Rate of Interest is = 4.5 Function - print( )
The Time is = 10
The Simple Interest is = 900.0

INPUT / ENTER BASED PROGRAM


Process execution :
'''PROG-8: WAP to calculate area & perimeter of
length breadth area peri
rectangle''' 22
5 6 30

length=int(input("Enter the length :")) Declaration :


breadth=int(input("Enter the breadth :")) Constants / literals – 5 , 6
area=length*breadth
peri=2*(length+breadth) Strings - Double quote things
print("Area of rectangle is =",area)
Variables / identifiers -
print("Perimeter of rectangle is =",peri) length , breadth , area , peri
Page 4 of 6
OUTPUT : Expression –
length*breadth
Enter the length : 5
2*(length+breadth)
Enter the breadth : 6
Area of rectangle is = 30 Keyword :
Perimeter of rectangle is = 22 Function – int( ) , print( )
Process execution :
'''PROG-9: WAP to calculate area of a triangle with base Height area
base & height''' 4 7 14.0

Declaration :
base=int(input("Enter the base :")) Constants / literals – 4 , 7
height=int(input("Enter the height :"))
area=1/2*base*height Strings - Double quote things
print("Area of triangle is =",area)
Variables / identifiers -
OUTPUT : base , height , area
Enter the base : 4
Expression – ½*base*height
Enter the height : 7
Area of triangle is = 14.0 Keyword :
Function – int( ), print( )
'''PROG-10: WAP to calculate average marks of 3 Process execution :
subjects''' math sc eng avg
89 78 67 78.0
math=int(input("Enter Maths mark :"))
Declaration :
sc=int(input("Enter Science mark :")) Constants / literals –
eng=int(input("Enter English mark :")) 89 , 78 , 67
avg=(math+sc+eng)/3
print("The average mark is =",avg) Strings - Double quote things

OUTPUT : Variables / identifiers -


math , sc , eng , avg
Enter Maths mark : 89
Enter Science mark : 78 Expression –
Enter English mark : 67 avg = (math+sc+eng)/3
The average mark is = 78.0
Keyword :
Function – int( ), print( )
'''PROG-11: WAP to calculate discounted amount Process execution :
with discount %''' price discount amount
4000 200.0 3800.0
price=int(input("Enter price of the product :"))
Declaration :
discount=price*.05 Constants / literals – 4000
amount=price-discount
print("The discount(5%) is =",discount) Strings - Double quote things
print("The amount is =",amount)
Variables / identifiers -
OUTPUT : price , discount , amount

Page 5 of 6
Enter price of the product : 4000
The discount(5%) is = 200.0 Expression –
Price*.05
The amount is = 3800.0
price-discount

Keyword :
Function – int( ), print( )
'''PROG-12: WAP to calculate surface area & volume Process execution :
of cuboid''' l b h sarea volume
5 6 4 148 120
l=int(input("Enter the length of cuboid :"))
Declaration :
b=int(input("Enter the breadth of cuboid :")) Constants / literals – 5 , 6 , 4
h=int(input("Enter the height of cuboid :"))
sarea=2*(l*b+b*h+l*h) Strings - Double quote things
volume=l*b*h
print("The surface area is =",sarea) Variables / identifiers -
print("The voulme is =",volume) l , b , h , sarea , volume

Expression –
OUTPUT : 2*(l*b+b*h+l*h)
Enter the length of cuboid : 5 l*b*h
Enter the breadth of cuboid : 6
Enter the height of cuboid : 4 Keyword :
The surface area is = 148 Function – int( ) , print( )
The volume is = 120

Page 6 of 6

You might also like