You are on page 1of 34

ALWIN INTERNATIONAL PUBLIC SCHOOL

Zion Avenue, Padappai, Chennai - 601301

AISSCE 2022 – 2023

Menu driven python program to show the shapes like,


to find factors, HCF of 2 numbers, LCM of 2
numbers and factorial…

NAME ……………………………………………..

REGISTER NO……………………………………

STD.….…………………SEC……………………..

SUBJECT.………………………………………….
ALWIN INTERNATIONAL PUBLIC SCHOOL
Zion Avenue, Padappai, Chennai - 601301

BONAFIDE CERTIFICATE

This is to certify that the project titled ___________


___________________________ is a Bonafide work done by
_________________ in partial fulfillment of the requirements
in computer science practical as prescribed by CBSE for
AISSCE 2022 – 2023.

REGISTER NO. ______________

TEACHER-IN-CHARGE SENIOR PRINCIPAL

INTERNAL EXAMINER EXTERNAL EXAMINER


o INDEX:

Sno. ORDER OF DOCUMENTATION PAGE No.


1. Acknowledgement
2. Abstract
3. Requirement Analysis
a) Hardware Requirements
b) Software Requirements

4. Applications
5. Design
6. Flow Chart
7. Algorithm
8. Source Code
9. Execution Screenshots / Sample Outputs
10. Future Enhancement
11. Bibliography / References
o ACKNOWLEDGEMENT:

➢ I am really grateful for the opportunity of this project and sincerely thank
my computer teacher Mrs. Shanmugapriya mam She will remain one of my
favorite teachers for contributing his valuable time and effort to help me
with this project.

➢ Secondly, I would like to thank my parents, family member and friends


who have always been there whenever needed.

➢ Lastly, I thank them all from my heart and wish that they will continue to
support me like this.

1
o ABSTRACT:

➢ Menu driven python program to show the shapes like <circle , diamond ,
right_angled triangle , triangle and square or a rectangle>,

➢ to find factors of a number by user defined function ,

➢ HCF of 2 number by user defined function ,

➢ LCM of 2 number by user defined function and

➢ factorial of a given number

2
o REQUIREMENT ANALYSIS:

a) Hardware Requirement
➢ Operating system: Linux- Ubuntu 16.04 to 17.10, or Windows 7 to 10, with
2GB RAM (4GB preferable)
➢ Computer or laptop

b) Software Requirement
➢ Python 3.10 and above

3
o APPLICATION:

➢ This menu driven python program to show the shapes like <circle , diamond
, right_angled triangle , triangle and square or a rectangle>,

➢ to find factors of a number by user defined function ,

➢ HCF of 2 number by user defined function ,

➢ LCM of 2 number by user defined function and

➢ factorial of a given number can be used for education purposes and

➢ also to find the HCF , LCM , factor and factorial faster

4
Start
o DESIGN:

o=int(input("select an option :) \n 1.student \n 2.teacher \n


o=int(input("select an option :) \n 1.student \n 2.teacher \n
3.other \n Enter the option n o=int(input("select an option
:) \n 1.student \n 2.teacher \n 3.other \n Enter the option
number please : ")) o=int(input("select an option :) \n
1.student \n 2.teacher \n 3.other \n Enter the option
number please : "))umber please : ")) 3.other \n Enter the
option number please : "))

no
elif o == 3:
if o == 1: elif o == 2:

yes

name=input("welcomeee ;0 name=input("welcomee
yes Enter full name [all in e ;0 Enter name : ")
lowercase] please : ")

B C
A

5
A B

name=input("welcome no
ee ;0 Enter name : ") if
(('shanmuga')
print ("welcomeeeee ...
or ('priya')) in mr/mrs",name,"<<have a
name: noice day>>")

print("welcome:) yes
","{<<",name,">>}","hope u got
the correct options and answers
print (" mam thankyou for all
u wanted") the teachings and supports
that u have given to us :) ...
have a noice day mamm :o ")

C D
D

print("welcome:) ","{<<",name,">>}","hope u got choice="yes"


the correct options and answers u wanted.......
have funnnnnn ;0")

yes
option=int(input("Select the while choice
number :) \n 1.Shapes \n 2.Factors == "yes" :
\n 3.HCF \n 4.LCM \n 5.Factorial \n
Enter here please : "))

6
print("Thankyou for your time :)
E hope you enjoyed it !!!:O")

if option H
== 1 :
yes

shape=int(input("select
the shapes :) \n 1.Circle
\n 2.Diamond \n 3.Right
angled triangle \n
4.Triangle \n 5.Square or
rectangle \n Enter here
please : "))

no no
if shape elif elif
== 1: shape shape no G
== 2: == 3:

yes yes yes

row=int(input("Enter the row value num=int(input("Enter


for the circle : ")) num=int(input("Enter
the number of rows :
the number of rows :
"))
column=int(input("Enter the "))
column value for the circle : "))
yes

for i in
range(1,num
print("
+1): for i in
"*(num-i)+"*
range(1,num+1)
"*i)
yes :
F
yes

yes yes
print(" "*(num- for i in
i)+"* "*i)
range(num,0,
print("* "*i)
-1):

7
FF

for i in
range(0,row)

yes

for j in print()
range(0,column)

yes

no elif( ((i==0 or no
if((j == 0 or j ==
i==row-1) and print(end=" ")
column-1) and
(i!=0 and (j>0 and
i!=row-1)): j<column-1))):

yes yes

print('*',end="")
print('*',end="")

no no
elif shape elif shape print("Enter a
== 4: == 5: valid option
G
number")
yes

yes
num=int(input("Enter the
number of rows : ")) num=int(input("Enter the
number of rows : "))
yes

yes yes yes print("


for i in for i in "*(num-
print("* "*i)
range(1,num+1): range(1,num+1) i)+"* "*i)
: 8
num1 = int(input("Enter the first number to find HCF
: "))
H
I
num2 = int(input("Enter the second number to
find HCF : "))

no

no
elif option print("The
elif H.C.F. is",
== 3:
option hcf(num1,
== 2: num2))
num = int(input("Enter
the number to find the
yes factors: ")) yes

def hcf(x,
def y):
factors
factors(num)
(x):

no
print("The factors
of",x,"are:") smaller = x
if x > y:

for i in yes
range(1,
for i in
x + 1):
range(1,
yes smaller+1):
smaller = y

return hcf

if x % i ==
0: if((x % i == 0)
and (y % i ==
0)):

yes yes

print(i)

hcf = i

9
num1 = int(input("Enter the first
number to find LCM : "))
I num=int(input("Enter
num2 = int(input("Enter the the number to find the
second number to find LCM : ")) factors of a number : "))

yes

no
elif elif ans=1
option option
== 4 : == 5 : i=1
yes

print("The L.C.M. is",


lcm(num1, num2)) no
def lcm(x, while
y): i<=num:

J
yes yes
greater = x
ans=ans*i

if x > y: i=i+1
no

greater = y print("Factorial
of",num,"is",ans)

while(T
rue):
if((great
er % x
== 0)
and
(greater
% y == yes
greater += 1 0)):
return lcm

lcm = greater

break

10
no print("Enter a valid option
J number")

choice=input("wanna continue
<yes or no> :")

if "o" or
"O" in
choice :

yes

print("Program is closingg....")

Stop

11
Start
o FLOW CHART:

o=int(input("select an option :) \n 1.student \n 2.teacher \n


o=int(input("select an option :) \n 1.student \n 2.teacher \n
3.other \n Enter the option n o=int(input("select an option
:) \n 1.student \n 2.teacher \n 3.other \n Enter the option
number please : ")) o=int(input("select an option :) \n
1.student \n 2.teacher \n 3.other \n Enter the option
number please : "))umber please : ")) 3.other \n Enter the
option number please : "))

no
elif o == 3:
if o == 1: elif o == 2:

yes

name=input("welcomeee ;0 name=input("welcomee
yes Enter full name [all in e ;0 Enter name : ")
lowercase] please : ")

B C
A

12
A B

name=input("welcome no
ee ;0 Enter name : ") if
(('shanmuga')
print ("welcomeeeee ...
or ('priya')) in mr/mrs",name,"<<have a
name: noice day>>")

print("welcome:) yes
","{<<",name,">>}","hope u got
the correct options and answers
print (" mam thankyou for all
u wanted") the teachings and supports
that u have given to us :) ...
have a noice day mamm :o ")

C D
D

print("welcome:) ","{<<",name,">>}","hope u got choice="yes"


the correct options and answers u wanted.......
have funnnnnn ;0")

yes
option=int(input("Select the while choice
number :) \n 1.Shapes \n 2.Factors == "yes" :
\n 3.HCF \n 4.LCM \n 5.Factorial \n
Enter here please : "))

13
print("Thankyou for your time :)
E hope you enjoyed it !!!:O")

if option H
== 1 :
yes

shape=int(input("select
the shapes :) \n 1.Circle
\n 2.Diamond \n 3.Right
angled triangle \n
4.Triangle \n 5.Square or
rectangle \n Enter here
please : "))

no no
if shape elif elif
== 1: shape shape no G
== 2: == 3:

yes yes yes

row=int(input("Enter the row value num=int(input("Enter


for the circle : ")) num=int(input("Enter
the number of rows :
the number of rows :
"))
column=int(input("Enter the "))
column value for the circle : "))
yes

for i in
range(1,num
print("
+1): for i in
"*(num-i)+"*
range(1,num+1)
"*i)
yes :
F
yes

yes yes
print(" "*(num- for i in
i)+"* "*i)
range(num,0,
print("* "*i)
-1):

14
FF

for i in
range(0,row)

yes

for j in print()
range(0,column)

yes

no elif( ((i==0 or no
if((j == 0 or j ==
i==row-1) and print(end=" ")
column-1) and
(i!=0 and (j>0 and
i!=row-1)): j<column-1))):

yes yes

print('*',end="")
print('*',end="")

no no
elif shape elif shape print("Enter a
== 4: == 5: valid option
G
number")
yes

yes
num=int(input("Enter the
number of rows : ")) num=int(input("Enter the
number of rows : "))
yes

yes yes yes print("


for i in for i in "*(num-
print("* "*i)
range(1,num+1): range(1,num+1) i)+"* "*i)
:
15
num1 = int(input("Enter the first number to find HCF
: "))
H
I
num2 = int(input("Enter the second number to
find HCF : "))

no

no
elif option print("The
elif H.C.F. is",
== 3:
option hcf(num1,
== 2: num2))
num = int(input("Enter
the number to find the
yes factors: ")) yes

def hcf(x,
def y):
factors
factors(num)
(x):

no
print("The factors
of",x,"are:") smaller = x
if x > y:

for i in yes
range(1,
for i in
x + 1):
range(1,
yes smaller+1):
smaller = y

return hcf

if x % i ==
0: if((x % i == 0)
and (y % i ==
0)):

yes yes

print(i)

hcf = i

16
num1 = int(input("Enter the first
number to find LCM : "))
I num=int(input("Enter
num2 = int(input("Enter the the number to find the
second number to find LCM : ")) factors of a number : "))

yes

no
elif elif ans=1
option option
== 4 : == 5 : i=1
yes

print("The L.C.M. is",


lcm(num1, num2)) no
def lcm(x, while
y): i<=num:

J
yes yes
greater = x
ans=ans*i

if x > y: i=i+1
no

greater = y print("Factorial
of",num,"is",ans)

while(T
rue):
if((great
er % x
== 0)
and
(greater
% y == yes
greater += 1 0)):
return lcm

lcm = greater

break

17
no print("Enter a valid option
J number")

choice=input("wanna continue
<yes or no> :")

if "o" or
"O" in
choice :

yes

print("Program is closingg....")

Stop

18
o ALGORITHM :

➢ Start

➢ Ask input as ((select an option :) \n 1.student \n 2.teacher \n 3.other


\n Enter the option number please :))
➢ if o == 1
➢ Ask input name
➢ print ((welcome:) ","{<<",name,">>}","hope u got the correct options
and answers u wanted))
➢ elif o == 2
➢ Ask input name
➢ if (('shanmuga') or ('priya')) in name
➢ print (" mam thankyou for all the teachings and supports that u have
given to us :) ... have a noice day mamm :o ")
➢ else
➢ Ask input name
➢ print ("welcomeeeee ... mr/mrs",name,"<<have a noice day>>")
➢ elif o == 3
➢ Ask input name
➢ print("welcome:) ","{<<",name,">>}","hope u got the correct options
and answers u wanted....... have funnnnnn ;0")
➢ else
➢ print("/&*%$^#@\input invalid T-T sry.. please run it again <not in
loop> enter [1 if student] or [2 if teacher] or [3 if
other]/&*%$^#@*BUZZZ*")

➢ choice="yes"
➢ while choice == "yes"

➢ Ask input ("Select the number :) \n 1.Shapes \n 2.Factors \n 3.HCF \n


4.LCM \n 5.Factorial \n Enter here please : "))
➢ if option == 1
➢ Ask input ("select the shapes :) \n 1.Circle \n 2.Diamond \n 3.Right
angled triangle \n 4.Triangle \n 5.Square or rectangle \n Enter here
please : "))

19
➢ if shape == 1
➢ Ask input ("Enter the row value for the circle : ")) and ("Enter the
column value for the circle : "))
➢ for i in range(0,row)
➢ for j in range(0,column)
➢ if((j == 0 or j == column-1) and (i!=0 and i!=row-1))
➢ print('*',end="")
➢ elif( ((i==0 or i==row-1) and (j>0 and j<column-1)))
➢ print('*',end="")
➢ else
➢ print(end=" ")
➢ print()

➢ elif shape == 2
➢ Ask input ("Enter the number of rows : "))
➢ for i in range(1,num+1)
➢ print(" "*(num-i)+"* "*i)
➢ for i in range(num,0,-1)
➢ print(" "*(num-i)+"* "*i)

➢ elif shape == 3
➢ Ask input("Enter the number of rows : "))
➢ for i in range(1,num+1)
➢ print("* "*i)

➢ elif shape == 4
➢ Ask input ("Enter the number of rows : "))
➢ for i in range(1,num+1)
➢ print(" "*(num-i)+"* "*i)

➢ elif shape == 5
➢ Ask input ("Enter the number of rows : "))
➢ for i in range(num)
➢ for j in range(num)
➢ print('*',end=" ")
➢ print()

20
➢ else
➢ print("Enter a valid option number")

➢ elif option == 2
➢ def factors(x)
➢ print("The factors of",x,"are:")
➢ for i in range(1, x + 1)
➢ if x % i == 0
➢ print(i)
➢ Ask input ("Enter the number to find the factors: "))
➢ factors(num)

➢ elif option == 3
➢ def hcf(x, y)
➢ if x > y
➢ smaller = y
➢ else
➢ smaller = x
➢ for i in range(1, smaller+1)
➢ if((x % i == 0) and (y % i == 0))
➢ hcf = i
➢ return hcf
➢ Ask input ("Enter the first number to find HCF : ")) and ("Enter the
second number to find HCF : "))
➢ print("The H.C.F. is", hcf(num1, num2))

➢ elif option == 4
➢ def lcm(x, y)
➢ if x > y
➢ greater = x
➢ else
➢ greater = y
➢ while(True)
➢ if((greater % x == 0) and (greater % y == 0))
➢ lcm = greater
➢ break

21
➢ greater += 1
➢ return lcm
➢ Ask input ("Enter the first number to find LCM : ")) and ("Enter the
second number to find LCM : "))
➢ print("The L.C.M. is", lcm(num1, num2))

➢ elif option == 5
➢ Ask input ("Enter the number to find the factors of a number : "))
➢ ans=1
➢ i=1
➢ while i<=num
➢ ans=ans*i
➢ i=i+1
➢ print("Factorial of",num,"is",ans)

➢ else
➢ print("Enter a valid option number")

➢ Ask input ("wanna continue <yes or no> :")


➢ if "o" or "O" in choice
➢ print("Program is closingg....")

➢ print("Thankyou for your time :) hope you enjoyed it !!!:O")

➢ Stop

22
o SOURCE CODE:
#menu driver python program to show [SHAPES],to find[FACTORS],[HCF
of 2 giver number],[LCM of 2 giver number] and [FACTORIAL]
o=int(input("select an option :) \n 1.student \n 2.teacher \n 3.other \n Enter the
option number please : "))
if o == 1:
name=input("welcomeee ;0 Enter name : ")
print("welcome:) ","{<<",name,">>}","hope u got the correct options and
answers u wanted")
elif o == 2:
name=input("welcomeee ;0 Enter full name [all in lowercase] please : ")
if (('shanmuga') or ('priya')) in name:
print (" mam thankyou for all the teachings and supports that u have given to
us :) ... have a noice day mamm :o ")
else:
print ("welcomeeeee ... mr/mrs",name,"<<have a noice day>>")
elif o == 3:
name=input("welcomeee ;0 Enter name : ")
print("welcome:) ","{<<",name,">>}","hope u got the correct options and
answers u wanted....... have funnnnnn ;0")
else:
print("/&*%$^#@\input invalid T-T sry.. please run it again <not in loop> enter
[1 if student] or [2 if teacher] or [3 if other]/&*%$^#@*BUZZZ*")
#program storts.....
choice="yes"
while choice == "yes" :

23
option=int(input("Select the number :) \n 1.Shapes \n 2.Factors \n 3.HCF \n
4.LCM \n 5.Factorial \n Enter here please : "))
if option == 1 :
shape=int(input("select the shapes :) \n 1.Circle \n 2.Diamond \n 3.Right
angled triangle \n 4.Triangle \n 5.Square or rectangle \n Enter here please : "))
if shape == 1:
#<<CIRCLE>>
row=int(input("Enter the row value for the circle : "))
column=int(input("Enter the column value for the circle : "))
for i in range(0,row):
for j in range(0,column):
if((j == 0 or j == column-1) and (i!=0 and i!=row-1)):
print('*',end="")
elif( ((i==0 or i==row-1) and (j>0 and j<column-1))):
print('*',end="")
else:
print(end=" ")
print()
elif shape == 2:
#<<DIAMOND>>
num=int(input("Enter the number of rows : "))
for i in range(1,num+1):
print(" "*(num-i)+"* "*i)
for i in range(num,0,-1):
print(" "*(num-i)+"* "*i)

24
elif shape == 3:
#<<RIGHT ANGLED TRIANGLE>>
num=int(input("Enter the number of rows : "))
for i in range(1,num+1):
print("* "*i)
elif shape == 4:
#<<TRIANGLE>>
num=int(input("Enter the number of rows : "))
for i in range(1,num+1):
print(" "*(num-i)+"* "*i)
elif shape == 5:
#<<SQUARE OR RECTANGLE>>
num=int(input("Enter the number of rows : "))
for i in range(num):
for j in range(num):
print('*',end=" ")
print()
else :
print("Enter a valid option number")
elif option == 2:
# Program to find the factors of a number <<user defined function>>
def factors(x):
print("The factors of",x,"are:")
for i in range(1, x + 1):
if x % i == 0:

25
print(i)
num = int(input("Enter the number to find the factors: "))
factors(num)
elif option == 3:
# Python program to find H.C.F of two numbers <<user defined function>>
def hcf(x, y):
#only the smaller number
if x > y:
smaller = y
else:
smaller = x
for i in range(1, smaller+1):
if((x % i == 0) and (y % i == 0)):
hcf = i
return hcf
# To make your functions send Python objects back to the caller
code
num1 = int(input("Enter the first number to find HCF : "))
num2 = int(input("Enter the second number to find HCF : "))
print("The H.C.F. is", hcf(num1, num2))
elif option == 4 :
# Python Program to find the L.C.M of two number <<user defined
function>>
def lcm(x, y):
# only the greater

26
if x > y:
greater = x
else:
greater = y
while(True):
if((greater % x == 0) and (greater % y == 0)):
lcm = greater
break
greater += 1
return lcm
# To make your functions send Python objects back to the
caller code
num1 = int(input("Enter the first number to find LCM : "))
num2 = int(input("Enter the second number to find LCM : "))
print("The L.C.M. is", lcm(num1, num2))
elif option == 5 :
#Program to find the factors of a number
num=int(input("Enter the number to find the factors of a number : "))
ans=1
i=1
while i<=num:
ans=ans*i
i=i+1
print("Factorial of",num,"is",ans)
else :

27
print("Enter a valid option number")
choice=input("wanna continue <yes or no> :")
if "o" or "O" in choice :
print("Program is closingg....")
print("Thankyou for your time :) hope you enjoyed it !!!:O")

28
o EXECUTION SCREENSHOT / SAMPLE OUTPUTS:

29
o FUTURE ENHANCEMENT:

➢ By merging this menu driven python program to show the shapes like
<circle , diamond , right_angled triangle , triangle and square or a
rectangle>, to find factors of a number by user defined function , HCF of 2
number by user defined function , LCM of 2 number by user defined
function and factorial of a given number… we can find the quadratic
equation of an equation of a shape

30
o BIBLIOGRAPHY / REFERENCE:

➢ Computer Science for Class XI – Hrushikesh Senapaty


➢ Computer Science with Python – Sumita Arora
➢ Youtube
➢ www.programiz.com

31

You might also like