0% found this document useful (0 votes)
1K views11 pages

Codementum - Test

The document discusses using various Python coding concepts like for loops, if/else conditionals, while loops, functions, and error handling to solve challenges involving turtles, pots, capsules, chests, and lions. It provides code examples for using these concepts, including using for loops to move turtles and open pots, if/else statements to check capsules, while loops to collect items from chests until depleted, defining functions to control characters, and using try/except to catch errors.

Uploaded by

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

Codementum - Test

The document discusses using various Python coding concepts like for loops, if/else conditionals, while loops, functions, and error handling to solve challenges involving turtles, pots, capsules, chests, and lions. It provides code examples for using these concepts, including using for loops to move turtles and open pots, if/else statements to check capsules, while loops to collect items from chests until depleted, defining functions to control characters, and using try/except to catch errors.

Uploaded by

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

Codementum - Test

20230608
Let's solve this challenge by using for loops.

turtle.forward(2)

50
Check inside the pots with open() method. You will see
black ones. Try not to touch them!

Let's solve this challenge by using


if capsule.green: conditionals.

capsules=[capsule1,capsule2,capsule3]

70
We need to check inside the pots with open() method. Try not
to take black capsules. We should pass black ones by jumping
over them!
Let's solve this challenge by using
if-else conditionals.

91
Use repeat a: loop to execute repetitive codes.

Let's solve this challenge with repeat a:

repeat 4:

14
We should use while loop to collect the capsules until they are
depleted.

Let's solve this challenge by using while loop.

chests=[chest1,chest2]

while chest.hasItem:
collect()

113
We should learn the not ! logical operation.

Let's use while loop with not to solve this challenge!

lions=[lion1,lion2,lion3]

while not lions[a].sleeping:

170
Make sure we use our char parameter inside the collect
function.

def collect(char):

collect(dog)
collect(monkey)

182
By setting a function to onKey event we can control what will
happen when press arrow keys on the keyboard like up, right,
down, and left.

def keyPress(key):
if key == up:
forward(2)

onKey(keyPress)

199
We use ** double star operator to compute power

235
This time there is an error in the code. Let's find and fix it

try:
turtles=[turtle1,turtle1,turtle2]
pots=[pot1,pot2,pot3]
for a in range(3):
turtles[a].forward(3)
pots[a].open()
forward(8)
turn(right)
forward(7)
jump()
except Exception as e:
say(e)

250

You might also like