Learn Python Programming - 4 - Interactive Shell vs. Script

Learn Python Programming – 4 – Interactive Shell vs. Script



Views:138207|Rating:4.84|View Time:5:9Minutes|Likes:970|Dislikes:32
Exercises on
We will discuss the difference between an interactive python terminal vs. A python script. …

★☆★ FREE Lesson 1: The Most Important Thing For a Successful Programmer★☆★

Enroll for coding exercises, projects, tutorials, and courses…
————————————
Clever Programmer
Website ►
Facebook ►
Twitter ►
Instagram ►
Snapchat ► Rafeh1
iTunes Podcast ►
Google Podcast ►
Support (Patreon) ►
Youtube ►
Github (Code) ►

okay in this video I'm gonna go over the solution to the previous problem that I posed to you and also we're going to learn how to write the turtle the entire thing in one go so the problem that I pose to you is make a square with the turtle well in your case let's see how you could do exactly that so let me find the file where we open up the turtle let me close that guy right there copy this line and paste it right there okay my turtle has begun well the idea is simple I take this line forward and go 100 now since sometimes programmers are lazy I don't want to keep writing this over and over again so one thing I can do to make my life is it easier is go to the line that I want to click on and I want to use basically go to that line click my mouse there hit enter it brings that down at the bottom as you can see right here and now I can just hit enter so you can see my turtle just moved left okay now it's facing up now what I want to do is move it forward again and you can see that it's facing up again or I'm sorry it's a it moved up now I need to make it face left so how do I do that I go to the left make it turn 90 degrees and you can see turn 90 degrees now I want it to move 100 again you can see it move forward and 90 degrees and then 100 once again and I have made the square now what I want you to be able to do is make a python file which means that remember this thing that we opened up right right here where we write all of the code at once so for example I'm going to close it I'm going to show you how to open it again okay so I'm going to close this one and I will simply open it again new file or command and and I will go and put it to the right side just so I have these side by side and I will say something like important turtle remember that command if you don't use that command and you try to do turtle your program will be like what the heck is turtle so by doing import turtle now it knows what turtle is it's like when you're talking about your friends if you talk about your friend John right like let's say you're talking about your friend John to your mom or to your dad and you're like dad this guy blah blah your dad's gonna be like who the heck is John so you're gonna be like oh yeah you remember John from my fifth grade class and then your dad if you're talking to him he's gonna say oh okay I know who you're talking about so import is basically like hey Python import that turtle that those coders wrote and now we can use in Python is like on that turtle but if you don't have this import command here Python is gonna be like what the heck what turtle are you talking about you must be out of your mind anyways we're gonna import this turtle all right so now here's what I want you to do I want you to write a script that makes the turtle in one single go okay and I want you to make that square with the turtle straight up in one go for example let's come over here to our script that I've written and if I write stuff here it does things immediately right as you saw but if I come to my right side over here oh by the way just one quick note whatever you do do not name this file turtle that py you can name it turtle underscore game or a game or something else just don't name a turtle because then it confuses this turtle here with this file and everything goes all over the place so don't do that because um I ended up taking that and caused lots of problems alright so let me just show you what happens when I run this file I'll go to run I'll hit run module and hit OK and you can see that my turtle went and did all those things in one go how cool is that so you don't have to sit there type it all in you can just write it in one go and it'll do that every single time so I want you to work on that square but before you go and do that I just want to show you what this file actually looks like so if I go to ooop um let's say documents and clever programmer practice exercises and we take a look at this file turtle game it's just a text file with this code in here okay that's really it that's all that's going on in here so I'm gonna leave it here the code that you write for the square I want you to either go to the YouTube place YouTube channel and post it in the comment or I want you to paste your code right here in the comments on clever programmer comm okay I'm gonna take a look at it I will see you in the next video

34 Replies to “Learn Python Programming – 4 – Interactive Shell vs. Script”

  1. Code with Rohit

    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)

  2. ajay kumar

    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)

  3. Sirmore Kemp

    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)

  4. SYED MAHIB

    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)

  5. Salman Haider

    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)

  6. shashank sanjeev

    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)

  7. Varun Pratap Singh

    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)

  8. Abraham Mayova

    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)

  9. Andy N

    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"}
    }

  10. Mohammad Shahadat Hossain

    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

  11. Mohammad Shahadat Hossain

    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)

  12. Kashyap Wadekar

    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)

  13. KaMeL Klennex

    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)

    >

  14. Dikshit Upadhya

    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.

  15. hardgamer123

    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)

  16. Gursahib Singh

    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)

  17. Karan Phogat

    import turtle

    bob = turtle.Turtle()

    bob.speed(1)

    def mysqr(x):

    bob.forward(100)

    bob.left(90)

    for i in range(4):

    mysqr(i)

  18. Moataz Tharwat

    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)

  19. Younas Bangash

    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)

  20. Benjamin Liles

    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)

  21. DAS TECH

    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)

  22. saumil christian

    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)

  23. Хороший парень

    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)

  24. Ryan Alfa

    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)

  25. Deebhan Hari

    # 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

  26. Saif Tamim

    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)

  27. oneshortfocus

    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)

  28. divine son

    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)

Leave a Reply

Your email address will not be published. Required fields are marked *