Click the button below to open python for android.
What is python
Python is a high-level programming language designed to be easy to read and
simple to implement. It is open source, which means it is free to use, even
for commercial applications. Python can run on Mac, Windows, and Unix
systems and has also been ported to Java and .NET virtual machines.
Copy and paste this on your idle python to draw a cube
#import the turtle modules
import turtle
# Forming the window screen
tut = turtle.Screen()
# background color green
tut.bgcolor("green")
# window title Turtle
tut.title("Turtle")
my_pen = turtle.Turtle()
# object color
my_pen.color("orange")
tut = turtle.Screen()
# forming front square face
for i in range(4):
my_pen.forward(100)
my_pen.left(90)
# bottom left side
my_pen.goto(50,50)
# forming back square face
for i in range(4):
my_pen.forward(100)
my_pen.left(90)
# bottom right side
my_pen.goto(150,50)
my_pen.goto(100,0)
# top right side
my_pen.goto(100,100)
my_pen.goto(150,150)
# top left side
my_pen.goto(50,150)
my_pen.goto(0,100)
Copy and paste this on your idle python to draw a coloured star
# draw color filled star in turtle
import turtle
# creating turtle pen
t = turtle.Turtle()
# taking input for the side of the star
s = int(input("Enter the length of the side of the star: "))
# taking the input for the color
col = input("Enter the color name or hex value of color(# RRGGBB): ")
# set the fillcolor
t.fillcolor(col)
# start the filling color
t.begin_fill()
# drawing the star of side s
for _ in range(5):
t.forward(s)
t.right(144)
# ending the filling of color
t.end_fill()
Copy and paste this on your idle python to draw a color filled solid cube.
# Draw color-filled solid cube in turtle
# Import turtle package
import turtle
# Creating turtle pen
pen = turtle.Turtle()
# Size of the box
x = 120
# Drawing the right side of the cube
def right():
pen.left(45)
pen.forward(x)
pen.right(135)
pen.forward(x)
pen.right(45)
pen.forward(x)
pen.right(135)
pen.forward(x)
# Drawing the left side of the cube
def left():
pen.left(45)
pen.forward(x)
pen.left(135)
pen.forward(x)
pen.left(45)
pen.forward(x)
pen.left(135)
pen.forward(x)
# Drawing the top side of the cube
def top():
pen.left(45)
pen.forward(x)
pen.right(90)
pen.forward(x)
pen.right(90)
pen.forward(x)
pen.right(90)
pen.forward(x)
pen.right(135)
pen.forward(x)
# Set the fill color to
# red for the right side
pen.color("red")
# Start filling the color
pen.begin_fill()
right()
# Ending the filling of the color
pen.end_fill()
# Set the fill color to
# blue for the left side
pen.color("blue")
# Start filling the color
pen.begin_fill()
left()
# Ending the filling of the color
pen.end_fill()
# Set the fill color to
#green for the top side
pen.color("green")
# Start filling the color
pen.begin_fill()
top()
# Ending the filling of the color
pen.end_fill()