jedesa: hey!
amgigojapan: hey jedesa !
amgigojapan: jedesa: should we start?
jedesa: is it python or logo for today?
amgigojapan: we only have about 1 hour
jedesa: Yeah
amgigojapan: python
amgigojapan: jedesa: so first go to this link
https://stepindev.com/en/py-playground
jedesa: Okay
amgigojapan: ok?
amgigojapan: then enter the following program:
jedesa: turtle and function
amgigojapan: from turtle import *
amgigojapan: fd(100)
amgigojapan: then hit run
jedesa: Nice
amgigojapan: ok jedesa turtle is a python library that works pretty much like LOGO
jedesa: Oh I forgot to turn of existing algorithm
amgigojapan: so the first line imports the turtle library then the next line if like fd 100 in LOGO
jedesa: a line to the right
amgigojapan: yes, one sec
amgigojapan: I will give you and example
amgigojapan: jedesa: now try this program:
from turtle import *
fd(100)
rt(90)
fd(100)
rt(90)
fd(100)
rt(90)
amgigojapan: was the program displayed?
jedesa: this would be a square
amgigojapan: yes
amgigojapan: jedesa: not try this:
from turtle import *
for i in range(0,4):
fd(100)
rt(90)
jedesa: for is similar to the repeat function in LOGO
amgigojapan: jedesa: for loops are more common in normal programming languages than repeat loops
amgigojapan: let me explain the for loop
jedesa: I see
amgigojapan: for counter_variable in range(start,end)
amgigojapan: jedesa: now, there is a difference here with LOGO, you need to start form 0 , not 1
amgigojapan: try changing hte 0 to 1 and run the program
amgigojapan: what happens?
jedesa: missing a side, so only 3 iterations
amgigojapan: yeah jedesa this is because python is (0 indexed) it counts form 0
jedesa: Yes
amgigojapan: ok, let me give you next example, one sec...
jedesa: Okay
from turtle import *
def square(size):
for i in range(0,4):
fd(size)
rt(90)
square(100)
amgigojapan: remember this program in LOGO?
amgigojapan: defines a function
jedesa: Yes, function in python
amgigojapan: yes
jedesa: function syntax
amgigojapan: jedesa: now I need to tell you a big difference between python and LOGO
β jedesa listens carefully
amgigojapan: jedesa: remember Haniibooru asked " is the space between the left and the command, necessary or for making it pretty?"
jedesa: (guessing) indent
amgigojapan: yes
amgigojapan: jedesa: indents are only for style in LOGO, but in python they are necessary
jedesa: I heard about python takes into account of that
amgigojapan: yeah, thats why you don't need to type END like in LOGO
amgigojapan: jedesa: whenever a new indent is made it opens up a "new block of code" do you understand?
jedesa: But you are free to use whether 2 or 4 spaces, but it must be consistent throughout
jedesa: since it will tell new block..
amgigojapan: jedesa: use 4 spaces please
jedesa: Okay
amgigojapan: ok
amgigojapan: now for the final program for today, one sec
from turtle import *
def square(size):
for i in range(0,4):
fd(size)
rt(90)
square(50)
square(100)
square(200)
jedesa: Okay I have these on the workspace
amgigojapan: what appeared?
jedesa: and creates 3 squares on top of each other
amgigojapan: yeah, same as we did in LOGO
amgigojapan: jedesa: now, your homework, is make δΈ and then ε in python
jedesa: Yes
amgigojapan: jedesa: san and shina,
amgigojapan: jedesa: same as last lesson in LOGO
jedesa: okay
jedesa: working on it now :D
amgigojapan: jedesa: here is hte previous lesson
https://amjp.psy-k.org/Learn-programming-form--AmigoJapan-in-LOGO/index.html
#run on https://stepindev.com/en/py-playground
from turtle import *
def ichi():
fd(100)
rt(180)
fd(100)
lt(90)
pu()
fd(25)
lt(90)
pd()
def san():
for i in range(0,3):
ichi()
san()
β jedesa working on shina
amgigojapan: ok
jedesa: python turtle docs https://docs.python.org/3/library/turtle.html
jedesa: amigojapan: .. are you still there?
amgigojapan: let me see jedesa
jedesa: okay
amgigojapan: jedesa: wait
jedesa: alright :D
amgigojapan: jedesa: I tried cleaning yours up but it does not seem to work
amgigojapan: jedesa: next time please make sure the program starts at the first indentation space, and delete all the comments and previous code
jedesa: huh
amgigojapan: ok
#run on https://stepindev.com/en/py-playground
from turtle import *
def ichi(size):
fd(size)
rt(180)
fd(size)
lt(90)
pu()
fd(25)
lt(90)
pd()
def san(size):
for i in range(0,3):
ichi(size)
def square():
pu()
seth(45)
fd(50)
seth(0)
pd()
for i in range(0,4):
rt(90)
fd(50)
pu()
def shina(size):
pu()
setpos(0,size)
square()
setpos(-size,-size)
square()
setpos(size,-size)
square()
san(100)
resetscreen()
home()
shina(30)
amgigojapan: let me see
amgigojapan: yes that writes both san and shina, but ok, jedesa , end lesson for today :)
jedesa: Nice!
amgigojapan: jedesa: so you see, mostly the difference between python and LOGO is in small syntax changes