๐Ÿ
B.TECH I YEAR โ€ข II SEMESTER โ€ข R25

Python Programming - Lab Manual

Python Programming Laboratory โ€ข Program Solution

๐Ÿ“˜ R25 Regulation ๐ŸŽ“ I Year ๐Ÿ“š II Semester ๐Ÿ Python Programming ๐Ÿงช Lab Program
Selected Program

draw_circle

โ† All Python Programs

Aim:

☛   Define a new class called Circle with appropriate attributes and instantiate a few Circle objects. Write a function called draw_circle that draws circles on the canvas.

Solution :


PROGRAM: (draw_circle.py)

 
from tkinter import *
#Create an instance of tkinter frame
root = Tk()
# Create Title
root.title(" Circle ")
# create canvas object
widget = Canvas(root, width=500,height=400 , bg = "brown" )
#function
def draw_circle(widget,circle):
	print(circle)
# Read Co-ordinates
x1 = int(input(" Enter x1 value = "))
y1 = int(input(" Enter y1 value = "))
x2 = int(input(" Enter x2 value = "))
y2 = int(input(" Enter y2 value = "))
# create object for rectangle
circle = widget.create_oval(x1 , y1 , x2 , y2 , fill = "#000fff000")
# call function by passing canvas & rectangle objects as argument
draw_circle(widget,circle)
widget.pack()
root.mainloop()

OUTPUT:


image

๐Ÿ’ป Run This Python Program

draw_circle
The selected Python program is loaded automatically into the editor. Edit the program, provide input if required and click Run.

The compiler is embedded using OneCompiler. Your Python program runs inside the embedded Python environment; Study Glance does not execute Python code directly on your web server.
โ† Back to Python Lab Programs ๐Ÿ“š All Lab Manuals