Showing posts with label While. Show all posts
Showing posts with label While. Show all posts

Turtle 3D cubes

import turtle

screen=turtle.Screen()  

screen.setup(800,800)   

trtl = turtle.Turtle()

screen.title("3-D CUBES")

trtl.penup()

trtl.setposition(0,0)

trtl.setheading(90)

trtl.color('red')

def hexagon():

    for i in range(6):

        trtl.fd(50)

        trtl.rt(60)

i = 1

while i < 7:

    trtl.pendown()

    hexagon()

    trtl.right(60)

    i = i + 1 

Factorial using while loop

f=i=1
n=int(raw_input('Enter the number: '))
while i<=n:
      f=f*i
      i=i+1
print f