# Drawing Tally Marks using Python Turtle Module

## Introduction

The Logo programming language is frequently linked to turtle graphics. In the late 1960s, Seymour Papert added turtle graphics support to Logo to support his version of the turtle robot, which is a simple robot controlled from the user’s workstation and designed to carry out the drawing functions assigned to it using a small retractable pen set into or attached to the robot’s body.

The standard library of the Python programming language now contains a Turtle graphics module. Turtle in Python, like its Logo ancestor, allows programmers to manipulate one or more turtles in a two-dimensional space.

## Overview of the syntax

A location, an orientation (or direction), and a pen are the three qualities of the turtle. Color, width, and on/off state are all properties of the pen (also called down and up).

“Move ahead 10 spaces” and “turn left 90 degrees” are orders that the turtle responds to based on its current location. The turtle’s pen can also be managed by enabling it, changing its color, and adjusting its breadth. By visualizing what they would do if they were the turtle, a pupil may comprehend (and forecast and reason about) the turtle’s motion. This is referred to as “body syntonic” reasoning by Seymour Papert.

Basic syntax:

import turtle // start of the program
//body
//of the main
//code
turtle.done() //end of the program

Inorder to understand the codes to draw various shapes given below, Getting Started with Powerful yet Easy Python Graphics Module, Turtle.

## Methods

A Python method is a label that can be applied to an object and is a piece of code that may be run on that object.

The most frequently, used turtle methods are:

## Tally Marks using Python Turtle Module

The principles governs everything in every subject. They’re the basis on which all incredible exploits are built. To execute acts that appear magical to us simple humans, great scientists and artists equally rely on their most basic skills. Same is the case for python turtle module.

Tally marks, often known as hash marks, are a system of unary numerals. They are a type of numeral that is used to count. They’re best for counting or tallying continuing results, such as a game or sport’s score, because no intermediate results need to be erased or discarded.

Drawing marks as a method of retaining count. Every fifth mark is drawn across the previous four marks, making groups of five easy to spot.

In order to make any drawings in python turtle, for this instance a tally marks for the given number input, the fundamentals are mandatory. If you think about it a tally is basically four lines sitting parallel to each other with a fifth line crossing the four parallel lines. Enough of explaining, let’s get coding!

The following is the code for drawing a Tally using python turtle module:

#import turtle and math python modules
import turtle
import math

tallymarks = turtle.Turtle()
number = int(input("Enter a number to make a tally: ")) #Asking user to enter a number
tallymarks.right(90)
x = 0
for i in range(1,number+1):
if(i%5 == 0): #For every fifth number, it will draw diagonal line
tallymarks.right(135)
tallymarks.forward(30*math.sqrt(2))
tallymarks.right(225)
else: #For other numbers, it will draw vertical line
tallymarks.penup()
tallymarks.goto(x*10,0)
tallymarks.pendown()
tallymarks.forward(30)
x = x + 1

turtle.done()


## Output

When we run the code we can see that the terminal asks us to “Enter a number to make a tally: “. Here you can enter any positive integer and get a output optimal for your choice of integer number. For this instance we take, 47.

The output for the above input is:

Form above output, we can observe what seems like a tally of 47. If we look closely we can observe 9 sets of five (four lines with a line crossed diagonally across them) and two lines signifying 47 in tally.

SHARE Drawing Tally Marks using Python Turtle Module