Turle Infographics on Carbon Footprint
import turtle
s=turtle.Screen()
s.bgcolor('blue')
t=turtle.Turtle()
t.speed(0)
carbon_emmision_value_list = []
def base():
t.penup()
t.goto(-90,150)
t.write('CARBON EMISSION',align='centre',font=('ariel',15))
t.goto(-120,+100)
t.pendown()
t.fillcolor('white')
t.begin_fill()
for i in range (4):
t.forward(250)
t.right(90)
t.end_fill()
t.forward(125)
t.right(90)
t.fd(250)
t.right(180)
t.fd(125)
t.left(90)
t.fd(125)
t.right(180)
t.fd(250)
base()
def car(c,x,y):
t.penup()
t.goto(x,y)
t.pendown()
a=0
initial_x = x
initial_y = y
for i in range(c):
t.right(90)
t.fd(10)
t.left(90)
for i in range(3):
t.fd(10)
t.left(90)
t.left(90)
t.fd(10)
t.left(90)
t.fd(10)
t.right(90)
t.fd(20)
t.right(90)
t.fd(20)
t.right(90)
t.fd(20)
t.fd(10)
t.dot(8)
t.backward(30)
t.dot(8)
t.right(90)
a += 1
if a < 3:
x += 40
elif a >= 3:
x = -110
y -= 35
t.penup()
t.goto(x, y)
a=0
t.penup()
t.goto(x, y)
t.pendown()
t.right(90)
carr = int(input("Enter the distance travelled in kilometers. (Between 10 - 90 KMS): "))
if carr <= 90 and carr>= 10:
car(carr//10, -110, 80)
else:
print("Invalid: Value Greater than 90 or Less than 10")
carr = int(input("Enter the distance travelled in kilometers. (Between 10 - 90 KMS): "))
car(carr//10, -110, 80)
def bulb(b,x,y):
t.penup()
t.goto(x,y)
t.pendown()
a=0
initial_x = x
initial_y = y
t.left(90)
for i in range(b):
t.color('black')
t.width(8)
t.fd(20)
t.color('yellow')
t.dot(30)
a += 1
if a < 3:
x += 40
elif a >= 3:
x = 25
y -= 40
t.penup()
t.goto(x, y)
a=0
t.penup()
t.goto(x, y)
t.pendown()
bulbb = int(input("Enter the number of devices(1-9): "))
if bulbb<= 9 and bulbb>= 1:
bulb(bulbb, 25, 60)
else:
print("Invalid: Value Greater than 9 or Less than 1")
bulbb = int(input("Enter the number of devices(1-9): "))
bulb(bulbb, 25, 60)
def carrot(cr,x,y):
t.penup()
t.goto(x,y)
t.pendown()
a=0
initial_x = x
initial_y = y
t.right(90)
for i in range(cr):
t.color('green')
t.right(45)
t.fd(10)
t.left(90)
t.fd(10)
t.backward(10)
t.right(45)
t.color('orange')
t.begin_fill()
t.fd(10)
t.right(135)
t.fd(15)
t.right(90)
t.fd(15)
t.right(135)
t.fd(10)
t.end_fill()
a += 1
if a < 3:
x += 45
elif a >= 3:
x = -110
y -= 40
t.penup()
t.goto(x, y)
a=0
t.penup()
t.goto(x, y)
t.pendown()
carro = int(input("Enter the number of veg meals(1-9): "))
if carro<= 9 and carro>= 1:
carrot(carro, -110, -40)
else:
print("Invalid: Value Greater than 9 or Less than 1")
carro = int(input("Enter the number of veg meals(1-9): "))
carrot(carro, -110, -40)
def fish(fishy, x, y):
t.penup()
t.goto(x, y)
t.pendown()
a=0
initial_x = x
initial_y = y
t.begin_fill()
for i in range(fishy):
t.color('grey')
for i in range(2):
t.fd(10)
t.right(45)
t.fd(10)
t.right(90)
t.fd(10)
t.right(45)
t.fd(10)
t.fd(10)
t.right(45)
t.fd(20)
t.left(120)
t.fd(10)
t.left(120)
t.fd(10)
t.right(50)
t.fd(10)
t.left(45)
t.fd(18)
t.end_fill()
t.color('yellow')
t.dot(5)
t.right(190)
a += 1
if a < 3:
x += 40
elif a >= 3:
x = 25
y -= 40
a=0
t.penup( )
t.goto(x, y)
t.pendown()
fishy = int(input("Enter the number of veg meals(1-9): "))
if fishy <= 9 and fishy>= 1:
fish(fishy, 25, -45)
transport_emission_factor = carr * 0.24
device_emission_factor = bulbb * 0.05
veg_meal_factor = carro * 0.002
non_veg_meal_factor = fishy * 0.01
total = 0
carbon_emmision_value_list = [transport_emission_factor, device_emission_factor,
veg_meal_factor, non_veg_meal_factor]
for i in carbon_emmision_value_list:
total += i
print("----------------------------------------------------------------------")
print("| The amount of carbon emmited by", carr , "Km", "vehicles is:",
transport_emission_factor, "kg CO2e |")
print("| The amount of carbon emmited by", bulbb , "devices is:",
device_emission_factor, "kg CO2e |")
print("| The amount of carbon emmited by consuming", carro , "veg meals is:",
veg_meal_factor, "kg CO2e |")
print("| The amount of carbon emmited by consuming", fishy , "non-veg meals is:",
non_veg_meal_factor, "kg CO2e |")
print("|", "The carbon emmited by all 4 is:", carbon_emmision_value_list, "|")
print("| The total carbon emmited is:",total)
print("----------------------------------------------------------------------")