Programming Examples

Python program to input any choice and to implement the following


Write a program to input any choice and to implement the following.

Choice Find

1. Area of square

2. Area of rectangle

3. Area of triangle

Solution

c = input ("Enter any Choice")
if(c==1):
	s = input("enter any side of the square")
	a = s*s
	print"Area = ",a
elif(c==2):
	l = input("enter length")
	b = input("enter breadth")
	a = l*b
	print"Area = ",a
elif(c==3):
	x = input("enter first side of triangle")
	y = input("enter second side of triangle")
	z = input("enter third side of triangle")
	s = (x+y+z)/2
	A = ((s-x)*(s-y)*(s-z))**0.5
	print"Area=",A
else:
	print "Wrong input"
Output

Enter any Choice2
enter length4
enter breadth6
Area = 24
CCC Online Test Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Online Exam Quiz O Level NIELIT Study material and Quiz Bank SSC Railway TET UPTET Question Bank career counselling in allahabad Best Website and Software Company in Allahabad Website development Company in Allahabad