0% found this document useful (0 votes)
57 views3 pages

Notes Comp1021

The summary adds a new turtle named "Turtle 1" to the list and sets its shape to "turtle". It retrieves things from the list by index and checks if the turtle's x coordinate is greater than 7, returning "Leo" in that case. The turtle's speed and shape are set. It defines a drag function for the turtle and an on screen click function. Input is converted to true/false. A name variable is set to user input and printed. It discusses local vs global variables. Finally, it reads and writes to a file, reading by line and deleting the file.

Uploaded by

6wcdwfcfyd
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
57 views3 pages

Notes Comp1021

The summary adds a new turtle named "Turtle 1" to the list and sets its shape to "turtle". It retrieves things from the list by index and checks if the turtle's x coordinate is greater than 7, returning "Leo" in that case. The turtle's speed and shape are set. It defines a drag function for the turtle and an on screen click function. Input is converted to true/false. A name variable is set to user input and printed. It discusses local vs global variables. Finally, it reads and writes to a file, reading by line and deleting the file.

Uploaded by

6wcdwfcfyd
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Adding a new turtle

Turtle =
Turtle Turtle 1)
.

In His X list :

ht¥ append .
1 %¥¥I )

retrieve
things from htt [index )

?
" *%

µ
p;I |→
Turtle .
X her I =

myrtle . xoor

year if × 7 Leo :

return ha " UH
titular *
www.anahslx.yiayl
speed
shape .

myturtk .
Ondine 4¥

myturtk on drag tire


y€Tf¥mput
.

click Etv TE I x.
" '

mydragfnnc :p

my turtle
.
on
drag (
my
turtle .

goto 1
" "
)
my turtle . On key press 1 function activated , key
myturtle .
listen
done
myturtk .

Hinman activated)
my turtle onscreen click
.
True 1 False

→ to convert input to T1F

)
"

I what's
"

↳ name =
input
ur name

name =
name
= =
Tracy

print ( name )

Tf Input = -
tray T will be printed .

global 1 local variables

local : inside a diet ←


changes in local will not affect global
global : outside 4 unless
global at the very beginning
read I write the

myth =
open ( filename ,
"

w
"
)

Read
" "
r

last
"

Append
fyn¥¥tM¥I
"
a a add to

"
Write
everything myfk.wntet.FI?Y
"
G write At
w over
↳ I -
I
"
"
x Create little already exist terror )

myfie .
read 11

read 151 read 54¥


IT# the
my file . headline 11 C-

delete the :

Import os

a. remove 1 the name )

You might also like