Page 131 - Computing E-Book Grade 7
P. 131
The City School 2021-2022
Logical Error: a logical mistake while designing the program which occurs due to the
improper planning of the program flow. Logical errors can be avoided by working on a
Data Flow Diagram (DFD), one practice of DFD is also a flowchart which is an extract
of the algorithm. Mentioned below are the few areas which can be used to avoid
logical errors in your program:
Form a hypothesis or two before looking at code.
• Resolve syntax errors.
• Start the debugger. Programming the Computer-Python
• Identify key variables or conditions.
• Step to your suspicious code.
• Look at the relevant variables.
• Predict what the suspicious line should do.
• Compare your expectations with reality.
• Think about your logic.
5.15. Creating Graphics with Python
The Canvas widget supplies graphics facilities for Tkinter. Among these graphical
objects are lines, circles, images, and even other widgets. With this widget, it’s possible
to draw graphs and plots, create graphics editors, and implement various kinds of
custom widgets and for using those we need to call/import the library of Tkinter so we
can use these functions.
Example-Creating Line
We will draw our first example, drawing a line.
The method create_line(coords, options) is used to draw a straight line. The
coordinates “coords” are given as four integer numbers: x1, y1, x2, y2 this means that
the line goes from the point (x1, y1) to the point (x2, y2).
131

