CODE
def main() :
print ("This program computes the area of Rectangle")
length = float (input ("Enter length: ") )
width = float (input ("Enter width: ") )
ans = length * width
print ("Area of Rectangle: ", ans)
main()
getsprogramming Tutorials , C Programming, CPP Programming and JAVA Programming , Python Programming , Javascript Programming Welcome to getsprogramming Blog Here You Find Different Programs in Easier way to Explain and gain Knowledge and Try Your Self..Thanks
CODE
def main() :
print ("This program computes the area of Rectangle")
length = float (input ("Enter length: ") )
width = float (input ("Enter width: ") )
ans = length * width
print ("Area of Rectangle: ", ans)
main()
CODE
def main() :
print ("This program computes the area of Cylinder")
rd = float (input ("Enter Radius of Cylinder: ") )
h = float (input ("Enter Height of Cylinder: ") )
ans = 2 * 3.14 * rd * h + 2 * 3.14 * rd *rd
print ("Area of Cyclinder: ", ans)
main()
save file as areaofcylinder.py
SCREENSHOT
CODE
def main() :
print ("This program computes the area of circle")
rd = float (input ("Enter Radius of Circle: ") )
ans = 3.14 * rd *rd
print ("Area of Circle: ", ans)
main()
SCREENSHOT
CODE
#Draw a line Segment using a Line object
from graphics import *
def main():
win = GraphWin('Draw Square',300,300)
center = Point(100,100)
line=Line(Point(20,30),Point(180,165))
line.draw(win)
main()
SCREENSHOT
CODE
#Draw a square using a Rectangle object
from graphics import *
def main():
win = GraphWin('Draw Square',300,300)
center = Point(100,100)
rect = Rectangle(Point(30,30), Point(150,150))
rect.setFill("yellow")
rect.draw(win)
main()
SCREENSHOT
CODE
#Draw a red circle centered at point (100,100) with radius 50 and with text Red Circle
from graphics import *
def main():
win = GraphWin('Draw Circle',300,300)
center = Point(100,100)
circ = Circle(center, 50)
circ.setFill('red')
circ.draw(win)
label = Text(center, "Red Circle")
label.draw(win)
main()
SCREENSHOT
CODE
#Draw a red circle centered at point (100,100) with radius 30
from graphics import *
def main():
win = GraphWin('Draw Circle',300,300)
center = Point(100,100)
circ = Circle(center, 30)
circ.setFill('red')
circ.draw(win)
main()
CODE :
An archery target consists of a central circle of yellow surrounded by concentric rings of red, blue, black and white. Each ring has the same width, which is the same as the radius of the yellow circle. Write a program called target.py that draws this target.
o Use a list of colors and a for loop to draw the target
o Hint: objects drawn later will appear on top of objects drawn earlier
o The output of the program should look like this:
SCREENSHOT
SAVE this file as target.py
from graphics import *
def main():
win = GraphWin('Archery Target',300,300)
center = Point(150,150)
w = Circle(center, 100)
w.setFill('white')
w.draw(win)
bl = Circle(center, 80)
bl.setFill('black')
bl.draw(win)
b = Circle(center, 60)
b.setFill('blue')
b.draw(win)
r = Circle(center, 40)
r.setFill('red')
r.draw(win)
y = Circle(center, 20)
y.setFill('yellow')
y.draw(win)
win.getMouse() # pause for click in window
win.close()
main()