# Learn Python Programming – 4 – Interactive Shell vs. Script

Skip to content
# Net Planning

## Create & Edit Documents Online

# Learn Python Programming – 4 – Interactive Shell vs. Script

##
100 thoughts on “Learn Python Programming – 4 – Interactive Shell vs. Script”

### Leave a Reply

I thought turtle was an object not a file???

import turtle

my_turtle = turtle.Turtle()

my_turtle.forward(100)

my_turtle.left(90)

my_turtle.forward(100)

my_turtle.left(90)

my_turtle.forward(100)

my_turtle.left(90)

my_turtle.forward(100)

import turtle

my_turtle = turtle.Turtle()

my_turtle.forward(100)

my_turtle.left(90)

my_turtle.forward(100)

my_turtle.left(90)

my_turtle.forward(100)

my_turtle.left(90)

my_turtle.forward(100)

Thx a lot dude

Python 3.6.3 (v3.6.3:2c5fed8, Oct 3 2017, 17:26:49) [MSC v.1900 32 bit (Intel)] on win32

Type "copyright", "credits" or "license()" for more information.

>>> import turtle

>>>

>>> my_turtle=turtle.Turtle()

>>> my turtle.forward(200)

SyntaxError: invalid syntax

>>> my_turtle.forward(200)

>>> my_turtle.left(90)

>>> my_turtle.forward(200)

>>> my_turtle.left(90)

>>> my_turtle.forward(200)

>>> my_turtle.left(90)

>>> my_turtle.forward(200)

>>> my_turtle.right(90)

>>> my_turtle.forward(200)

>>> my_turtle.left(90)

>>> my_turtle.forward(200) and my_turtle.left(90)

>>> my_turtle.left(90)

import turtle

#window properties

window = turtle.Screen()

window.bgcolor("lightgrey")

#turtle properties

minhaturt = turtle.Turtle()

minhaturt.shape("turtle")

minhaturt.color("blue")

minhaturt.speed(1)

def square_turt():

for i in range(1, 5):

minhaturt.forward(100)

minhaturt.left(90)

square_turt()

>>> import turtle

>>> my_turtle = turtle.Turtle()

>>>

>>> for i in range(4):

my_turtle.forward(100)

my_turtle.left(90)

>>>

it is not work in this is what i typed

>>> import turtle

>>>

>>>

>>>

>>> my_turtle = turtle.turtle()

Traceback (most recent call last):

File "<pyshell#4>", line 1, in <module>

my_turtle = turtle.turtle()

AttributeError: 'module' object has no attribute 'turtle'

mt.left(10)

mt.circle(20)

import turtle as tt

my_tt = tt.Turtle()

turns = 0

while turns < 4:

my_tt.forward(100);

my_tt.left(90);

turns = turns + 1

@#$%&*! cool

i love how u trasfer the computer world to the real world, or more common innerstandable examples…. day 1 due to your proper guidance and mentorship

Hii!! My question is did the turtle graphics will work in python 2.7?

import turtle

my_turtle = turtle.Turtle()

my_turtle.forward(100)

my_turtle.left(90)

my_turtle.forward(100)

my_turtle.left(90)

my_turtle.forward(100)

my_turtle.left(90)

my_turtle.forward(100)

Love your videos thanks soo much <3

import turtle

my_turtle = turtle.Turtle()

my_turtle.forward(200)

my_turtle.left(90)

my_turtle.forward(200)

my_turtle.left(90)

my_turtle.forward(200)

my_turtle.left(90)

my_turtle.forward(200)

import turtle

my_turtle = turtle.Turtle()

my_turtle.forward(100)

my_turtle.left(90)

my_turtle.forward(100)

my_turtle.left(90)

my_turtle.forward(100)

my_turtle.left(90)

my_turtle.forward(100)

import turtle

my_turtle = turtle.Turtle()

my_turtle.forward(100)

my_turtle.left(90)

my_turtle.forward (100)

my_turtle.left(90)

my_turtle.forward(100)

my_turtle.left(90)

my_turtle.forward(100)

import turtle

my_turtle = turtle.Turtle()

my_turtle.forward(100)

my_turtle.right(90)

my_turtle.forward(100)

my_turtle.right(90)

my_turtle.forward(100)

<3

my_turtle=turtle.Turtle()

>>> my_turtle.circle(30)

>>> my_turtle.circle(60)

>>> my_turtle.circle(90)

>>> my_turtle.circle(120)

>>> my_turtle.circle(150)

>>> my_turtle.circle(180)

>>> my_turtle.forward(150)

>>> my_turtle.forward(30)

>>> my_turtle.left(90)

>>> my_turtle.forward(300)

>>> my_turtle.forward(30)

>>> my_turtle.forward(30)

>>> my_turtle.left(90)

>>> my_turtle.forward(360)

>>> my_turtle.left(90)

>>> my_turtle.forward(360)

>>> my_turtle.left(90)

>>> my_turtle.forward(180)

import turtle

tt = turtle.Turtle()

tt.forward(200)

tt.left(90)

tt.forward(200)

tt.left(90)

tt.forward(200)

tt.left(90)

tt.forward(200)

Seeing the turtle make a square is satisfying haha.

How I made the square! ~

import turtle

my_turtle = turtle.Turtle()

my_turtle.forward(100)

my_turtle.left(90)

my_turtle.forward(100)

my_turtle.left(90)

my_turtle.forward(100)

my_turtle.left(90)

my_turtle.forward(100)

my_turtle.left(90)

I dont have the run option

import turtle

trt = turtle.Turtle();trt.forward(100);trt.left(90);trt.forward(100);trt.left(90);trt.forward(100);trt.left(90);trt.forward(200);trt.right(90);trt.forward(100);trt.right(90);trt.forward(100);trt.right(90);trt.forward(100)

dude this is insane

Import turtle

a = turtle.Turtle()

a.forward(100)

a.left(90)

a.forward(100)

a.left(90)

a.forward(100)

a.left(90)

a.forward(100)

sir your teaching style is awesome i love it

import turtle

my_turtle=turtle.Turtle()

my_turtle.forward(100)

my_turtle.left(90)

my_turtle.forward(100)

my_turtle.left(90)

my_turtle.forward(100)

my_turtle.left(90)

my_turtle.forward(100)

import turtle

my_turtle=turtle.Turtle()

my_turtle.forward(100)

my_turtle.left(90)

my_turtle.forward(100)

my_turtle.left(90)

my_turtle.forward(100)

my_turtle.left(90)

my_turtle.forward(100)

print("Yay i wrote my first real thing. What do you think?")

import turtle

my_turtle = turtle.Turtle()

my_turtle.forward(100)

my_turtle.circle(4)

my_turtle.left(90)

my_turtle.forward(100)

my_turtle.circle(4)

my_turtle.left(90)

my_turtle.forward(100)

my_turtle.circle(100)

my_turtle.circle(4)

my_turtle.left(90)

my_turtle.forward(100)

my_turtle.circle(4)

my_turtle.circle(100)

bit diffrent

first letter of my name xD

import turtle

x = turtle.Turtle()

x.forward(200)

x.back(100)

x.left(90)

x.forward(200)

x.left(90)

x.forward(100)

x.left(180)

x.forward(200)

Is it necessary to assign the turtle to my_turtle . Can't we assign another variable like x

import turtle

>>>

>>>

>>> my_turtle = turtle.Turtle()

>>> my_turtle.forward(100)

>>> my_turtle.left(90)

>>> my_turtle.forward(100)

>>> my_turtle.left(90)

>>> my_turtle.forward(100)

>>> my_turtle.left(90)

>>> my_turtle.forward(100)

Hey Qazi,

i wish to ask you one thing, i am using PyCharm. is it fine or do i have to do some modifications>???

import turtle

my_turtle=turtle.Turtle()

my_turtle.forward(100)

my_turtle.left(90)

my_turtle.forward(100)

my_turtle.left(90)

my_turtle.forward(100)

my_turtle.left(90)

my_turtle.forward(100)

Traceback (most recent call last):

File "/Users/Nick/Documents/game.py", line 3, in <module>

my_turtle.turtle.Turtle()

NameError: name 'my_turtle' is not defined

import turtle

x=turtle.Turtle()

side_num=4

side_length=100

angle=360/side_num

for i in range(side_num):

x.forward(side_length)

x.right(angle)

turtle.done()

import turtle

my_turtle=turtle.Turtle()

my_turtle.forward(50)

my_turtle.right(90)

my_turtle.forward(50)

my_turtle.right(90)

my_turtle.forward(50)

my_turtle.right(90)

my_turtle.forward(50)

import turtle

x=turtle.Turtle()

x.circle(200)

x.penup()

x.goto(0,8)

x.pendown()

x.circle(70)

x.penup()

x.goto(100,160)

x.pendown()

x.circle(50)

x.circle(30)

x.penup()

x.goto(-100,160)

x.pendown()

x.circle(50)

x.circle(30)

x.penup()

x.forward(1000)

turtle.done()

import turtle

my_turtle = turtle.Turtle()

my_turtle.forward(100)

my_turtle.left(90)

my_turtle.forward(100)

my_turtle.left(90)

my_turtle.forward(100)

my_turtle.left(90)

my_turtle.forward(100)

import turtle

>>> my_turtle=turtle.Turtle()

>>> my_turtle.forward(100)

>>> my_turtle.left(90)

>>> my_turtle.forward(100)

>>> my_turtle.left(90)

>>> my_turtle.forward(100)

>>> my_turtle.left(90)

>>> my_turtle.forward(100)

>>> my_turtle.left(90)

import turtle

my_turtle = turtle.Turtle()

my_turtle.forward(100)

my_turtle.left(90)

my_turtle.forward(100)

my_turtle.left(90)

my_turtle.forward(100)

my_turtle.left(90)

my_turtle.forward(100)

my_turtle.left(90)

my_turtle.forward(100)

import turtle

my_turtle= turtle.Turtle()

my_turtle.forward(100)

my_turtle.left(90)

my_turtle.forward(100)

my_turtle.left(90)

my_turtle.forward(100)

my_turtle.left(90)

my_turtle.forward(100)

This will make a square

my_turtle = turtle.Turtle()

my_turtle.forward(100)

my_turtle.left(90)

my_turtle.forward(100)

my_turtle.left(90)

my_turtle.forward(100)

my_turtle.left(90)

my_turtle.forward(100)

You can simply use a loop to draw a square

import turtle

for steps in range(4):

turtle.forawrd.(100)

turtle.right(90)

Hey bro I am watching your videos and subscribing. I want to invite you over to steemit https://steemit.com/@stateless1?r=stateless1 You can make alot of crypto there. I hope you check it out and apply for an account. they are still free

how to duplicate sentence more fast?

import turtle

>>> my_turtle = turtle.Turtle()

>>> my_turtle.forward(300)

>>> my_turtle.left(90)

>>> my_turtle.forward(300)

>>> my_turtle.left(90)

>>> my_turtle.forward(300)

>>> my_turtle.left(90)

>>> my_turtle.left(90)

>>> my_turtle.forward(300)

import turtle

my_turtle = turtle.Turtle()

my_turtle.forward(100)

my_turtle.left(90)

my_turtle.forward(100)

my_turtle.right(90)

my_turtle.forward(100)

my_turtle.left(90)

my_turtle.forward(100)

my_turtle.left(90)

my_turtle.forward(100)

my_turtle.left(90)

my_turtle.forward(100)

my_turtle.right(90)

my_turtle.forward(200)

my_turtle.right(90)

my_turtle.forward(100)

my_turtle.right(90)

my_turtle.forward(200)

my_turtle.right(180)

my_turtle.forward(100)

my_turtle.left(90)

my_turtle.forward(200)

my_turtle = turtle.Turtle()

my_turtle.forward(100)

my_turtle.left(90)

my_turtle.forward(100)

my_turtle.left(90)

my_turtle.forward(100)

my_turtle.left(90)

my_turtle.forward(100)

Turtle() its function calling please explain

Sir, I have made a word 'PYTHON' with the use of turtle should I paste that code in to this comment section???

import turtle

my_turtle = turtle.Turtle()

my_turtle.forward(100)

my_turtle.left(90)

my_turtle.forward(100)

my_turtle.left(90)

my_turtle.forward(100)

my_turtle.left(90)

my_turtle.forward(100)

import turtle

my_turtle = turtle.Turtle()

my_turtle.forward(100)

my_turtle.right(90)

my_turtle.forward(100)

my_turtle.right(90)

my_turtle.forward(100)

my_turtle.right(90)

my_turtle.forward(100)

This is awesome

man it doesn't work on my laptop

that turtle

Do theses all work using microsoft?

import turtle

my_turtle= turtle.Turtle()

my_turtle.forward(200)

my_turtle.left(90)

my_turtle.forward(200)

my_turtle.left(90)

my_turtle.forward(200)

my_turtle.left(90)

my_turtle.forward(200)

import turtle

my_turtle = turtle.Turtle()

my_turtle.forward(200)

my_turtle.left(90)

my_turtle.forward(200)

my_turtle.left(90)

my_turtle.forward(200)

my_turtle.left(90)

my_turtle.forward(200)

import turtle

my_turtle=turtle.Turtle()

my_turtle=turtle.forward(275)

my_turtle=turtle.left(90)

my_turtle=turtle.forward(275)

my_turtle=turtle.left(90)

my_turtle=turtle.forward(275)

my_turtle=turtle.left(90)

mt_turtle=turtle.forward(275)

i didn't understand script

import turtle

my_turtle = turtle.Turtle()

my_turtle.forward(100)

my_turtle.left(90)

my_turtle.forward(100)

my_turtle.left(90)

my_turtle.forward(100)

my_turtle.left(90)

my_turtle.forward(100)

my_turtle=turtle.TURTLE

AttributeError: module 'turtle' has no attribute 'TURTLE' what does it mea

ns sir

import turtle

tim = turtle.Turtle()

tim.forward (100)

tim.right (90)

tim.forward (100)

tim.right (90)

tim.forward (100)

tim.right (90)

tim.forward (100)

tim.right (90)

import turtle

my_turtle = turtle.Turtle()

count = 0

while count < 4:

my_turtle.left(90)

my_turtle.forward(100)

count += 1

import turtle

tacky=turtle.Turtle()

tacky.forward(100)

tacky.right(90)

tacky.forward(100)

tacky.right(90)

tacky.forward(100)

tacky.right(90)

tacky.forward(100)

my_turtle = turtle.Turtle()

my_turtle.forward(100)

my_turtle.left(90)

my_turtle.forward(100)

my_turtle.left(90)

my_turtle.forward(100)

my_turtle.left(90)

my_turtle.forward(100)

import turtle

my_turtle = turtle.Turtle()

my_turtle.forward(200)

my_turtle.left(90)

my_turtle.forward(200)

my_turtle.left(90)

my_turtle.forward(200)

my_turtle.left(90)

my_turtle.forward(200)

# Make a square with the turtle.

import turtle

My_Square= turtle.Turtle() # invoking the turtle class and assigning object name

My_screen=turtle.Screen() # invoking the screen class and assigning object name

My_screen.bgcolor("Black") # setting screen back ground color

My_Square.pencolor("White") # setting square turtle pen color

My_Square.forward(100) # setting forward mesaurement for moving the trutle

My_Square.left(90) # setting angel of degree for direction change of turtle

My_Square.forward(100)

My_Square.left(90)

My_Square.forward(100)

My_Square.left(90)

My_Square.forward(100)

My_Square.hideturtle() # removing the turtle

how do we fill color inside the square ?

I made more then 1 turtle and created a square with a "X" inside it

import turtle

turtle1 = turtle.Turtle()

turtle2 = turtle.Turtle()

turtle2 = turtle.Turtle()

turtle3 = turtle.Turtle()

turtle4 = turtle.Turtle()

turtle1.forward(100)

turtle2.left(90)

turtle2.forward(100)

turtle3.left(180)

turtle3.forward(100)

turtle4.right(90)

turtle4.forward(100)

turtle5 = turtle.Turtle()

turtle5.left(45)

turtle5.forward(141.4213562373)

turtle5.backward(282.8427124746)

turtle6 = turtle.Turtle()

turtle6.right(45)

turtle6.forward(141.4213562373)

turtle6.backward(282.8427124746)

turtle6.left(45)

turtle6.forward(100)

turtle6.forward(100)

turtle6.right(90)

turtle.forward(100)

turtle6.forward(100)

turtle6.forward(100)

turtle6.right(90)

turtle6.forward(100)

turtle6.forward(100)

turtle6.right(90)

turtle6.forward(200)

turtle6.left(45)

import turtle

my_turtle = turtle.Turtle()

my_turtle.forward(100)

my_turtle.right(90)

my_turtle.forward(100)

my_turtle.right(90)

my_turtle.forward(100)

my_turtle.right(90)

my_turtle.forward(100)

my_turtle = turtle.Turtle()

my_turtle.forward(100)

my_turtle.left(90)

my_turtle.forward(100)

my_turtle.left(90)

my_turtle.forward(100)

my_turtle.left(90)

my_turtle.forward(100)

my_turtle = turtle.Turtle()

my_turtle.forward(100)

my_turtle.left(90)

my_turtle.forward(100)

my_turtle.left(90)

my_turtle.forward(100)

my_turtle.left(90)

my_turtle.forward(100)

Got mine to work when I realized how to do it, so here's that code

import turtle

my_turtle = turtle.Turtle()

my_turtle.forward(100)

my_turtle.right(90)

my_turtle.forward(100)

my_turtle.right(90)

my_turtle.forward(100)

my_turtle.right(90)

my_turtle.forward(100)

my_turtle = turtle.Turtle()

my_turtle.forward(100)

my_turtle.left(90)

my_turtle.forward(100)

my_turtle.left(90)

my_turtle.forward(100)

my_turtle.left(90)

my_turtle.forward(100)

import turtle

my_turtle = turtle.Turtle()

my_turtle.forward(100)

my_turtle.left(90)

my_turtle.forward(100)

my_turtle.left(90)

my_turtle.forward(100)

my_turtle.left(90)

my_turtle.forward(100)

import turtle

bob = turtle.Turtle()

bob.speed(1)

def mysqr(x):

bob.forward(100)

bob.left(90)

for i in range(4):

mysqr(i)

import turtle

mt = turtle.Turtle()

mt.forward(100)

mt.left(90)

mt.forward(100)

mt.left(90)

mt.forward(100)

mt.left(90)

mt.forward(100)

I like learning from this guy.

import turtle

bob = turtle.Turtle()

bob.forward(100)

bob.left(90)

bob.forward(100)

bob.left(90)

bob.forward(100)

bob.left(90)

bob.forward(100)

Bruh, u need to give a bit of more details in ur videos. U just started by writing import turtle. A beginner won't know what a turtle is. And u never taught that Turtle() function. U just started, and things are gonna go over the minds of beginners.

import turtle

>>>

>>> my_turtle = turtle.Turtle()

>>> my_turtle.forward(100)

>>> my_turtle.left(90)

>>> my_turtle.forward(100)

>>> my_turtle.left(90)

>>> my_turtle.forward(100)

>>> my_turtle.left(90)

>>> my_turtle.forward(100)

>>> my_turtle.left(90)

>>> my_turtle.right(90)

>>> my_turtle.forward(100)

>>> my_turtle.right(90)

>>> my_turtle.forward(100)

>>> my_turtle.left(90)

>>> my_turtle.forward(100)

>>> my_turtle.right(90)

>>> my_turtle.forward(100)

>>> my_turtle.right(90)

>>> my_turtle.forward(100)

>>> my_turtle.right(90)

>>> my_turtle.forward(100)

>>> my_turtle.left(90)

>>> my_turtle.forward(100)

>>> my_turtle.right(90)

my_turtle.forward(100)

>

import turtle

my_turtle = turtle.Turtle()

my_turtle.left(90)

my_turtle.forward(100)

my_turtle.left(90)

my_turtle.forward(100)

my_turtle.left(90)

my_turtle.forward(100)

import turtle

my_turtle=turtle.Turtle()

my_turtle.forward(100)

my_turtle.right(90)

my_turtle.forward(100)

my_turtle.right(90)

my_turtle.forward(100)

my_turtle.right(90)

my_turtle.forward(100)

It is say that my turtle is not defined. What can I do. I have made turtle several time. Buy unfortunately don't know why this is happening

Please help! When running the code in the command window, it works fine. However, when running my Turtle_game.py-file, the animation shows up and draws a box. BUT the animation window closes as soon as its drawn and I get the following ERROR messages:

2019-02-23 05:13:09.883 Python[1311:55258] isPrefsCreateCacheFromEnabledAndDefaultInputSources – can't find anything from GetInputSourceEnabledPrefs, use defaultASCIIKeyLayoutDict = <CFBasicHash 0x7f8ef8c57cb0 [0x7fff86dd58f0]>{type = mutable dict, count = 3,

entries =>

0 : <CFString 0x7fff86e43eb8 [0x7fff86dd58f0]>{contents = "InputSourceKind"} = <CFString 0x7fff86e893f8 [0x7fff86dd58f0]>{contents = "Keyboard Layout"}

1 : <CFString 0x7fff86e75538 [0x7fff86dd58f0]>{contents = "KeyboardLayout ID"} = <CFNumber 0x737 [0x7fff86dd58f0]>{value = +7, type = kCFNumberSInt64Type}

9 : <CFString 0x7fff86e3ebb8 [0x7fff86dd58f0]>{contents = "KeyboardLayout Name"} = <CFString 0x7fff86e25038 [0x7fff86dd58f0]>{contents = "Swedish – Pro"}

}

import turtlemy_turtle = turtle.Turtle()

my_turtle.forward(200)

my_turtle.left(90)

my_turtle.forward(200)

my_turtle.left(90)

my_turtle.forward(200)

my_turtle.left(90)

my_turtle.forward(200)

import turtle

>>> my_turtle = turtle.Turtle()

>>> my_turtle.forward(100)

>>> my_turtle.left(90)

>>> my_turtle.forward(100)

>>> my_turtle.left(90)

>>> my_turtle.forward(100)

>>> my_turtle.left(90)

>>> my_turtle.forward(100)

You are superb… Actually amazing but lack of subs doesn't motivate you for creating more and more… Right?

my_turtle = turtle.Turtle()

my_turtle.forward(200)

my_turtle.left(90)

my_turtle.forward(200)

my_turtle.left(90)

my_turtle.forward(200)

my_turtle.left(90)

my_turtle.forward(200)

my_turtle=turtle.Turtle()

my_turtle.forward(100)

my_turtle.left(90)

my_turtle.forward(100)

my_turtle.left(90)

my_turtle.forward(100)

my_turtle.left(90)

my_turtle.forward(100)

who the hell is john hahaha lol u r a good teacher as well a funny guy

You are awesome!

2 adds are very annoying!!

import turtle

my_turtle = turtle.Turtle()

my_turtle.fd(100)

my_turtle.lt(90)

my_turtle.fd(100)

my_turtle.lt(90)

my_turtle.fd(100)

my_turtle.lt(90)

my_turtle.fd(100)

import turtle

my_turtle =turtle.Turtle()

my_turtle.forward(100)

my_turtle.left(90)

my_turtle.forward(100)

my_turtle.left(90)

my_turtle.forward(100)

my_turtle.left(90)

my_turtle.forward(100)

square code-

import turtle

my_turtle = turtle.Turtle()

my_turtle.forward(100)

my_turtle.left(90)

my_turtle.forward(100)

my_turtle.left(90)

my_turtle.forward(100)

my_turtle.left(90)

my_turtle.forward(100)

import turtle

myturtle=turtle.turtle()

myturtle.forward(100)

myturtle.right(90)

myturtle.forward(100)

myturtle.right(90)

myturtle.forward(100)

myturtle.right(100)

myturtle.forward(100)

import turtle

my_turtle = turtle.Turtle()

my_turtle.forward(100)

my_turtle.left(90)

my_turtle.forward(100)

my_turtle.left(90)

my_turtle.forward(100)

my_turtle.left(90)

my_turtle.forward(100)

Hi, I am thinking about learning this program and was nervous about it being too complicated for me, but you made it look so easy, now I'm excited. Thank you. You are a great teacher.