From Blocks to Code with Trinket!
Tavoitteet
Oppia tunnistamaan, millä tavoin blokeista rakennettu ohjelma vastaa Python koodia
Trinketin sivut
Löydät päivän harjoitusmateriaalin täältä
Dragging and Dropping
Huomaa, että saat koodin näkyviin valitsemalla oikealta välilehden >_View Code
Saatuasi koodin näkyviin voit tehdä Python-koodista itsellesi Remixin. Silloin koodi tallentuu omiin Trinketeihisi.
Harjoituksia
Koodarin tulee oppia riittävästi englannin kieltä.
Jos et ymmärrä tehtävää, kysy Pasilta kokouksessa selitystä.
Kokeile seuraavia tehtäviä. Niitä ei tarvitse tallentaa, ellet halua.
Aiempia harjoituksia
Mikäli sinulta jäi kesken jotain aiempia harjoituksia, voit halutessasi jatkaa niistä.
Meet Tina
Can you find the colors? Try changing them to your favorite colors instead
Change some of the numbers in the example. What happens?
Try re-arranging some of the blocks. What changes when you change their order?
Repeating things
Change the number of times the Turtle goes through the loop. How about 1 time? Or 100 times?
The turtle changes a random color each time. Can you have it be your favorite color instead? Hint: you'll need to pick from the list of Color blocks on the left hand side.
The turtle goes to random location each loop. The location it chooses is currently between -200 and 200. Can you make this a smaller range instead?
Changing for loops
Change the numbers in the list and see how the turtle's behavior changes.
Change how many items in the list there are and see how that changes how many circles there are. Hint: you can alter the size of the list by clicking the star and adding or removing items from that screen.
There's Code Under There
Vertaa blokeilla laadittua ohjelmaa ja Python-koodia keskenään
For Loops in The Code
The list that the Turtle uses for the heights at which she should draw circles is [150, 75, 0, -75, -150]. Try changing those to different numbers.
Functions are Recipies
Can you call it more times?
Can you duplicate and make a new function that makes a new shape?
Function parameters
Change the parameters of the functins to change what Tina says.
call the function again to make Tina say more things
Change what Tina does in the function
Advanced: Make Tina yell by making the words UPPERCASE
Jack-o-lantern
Make it your own! Here are some ideas:
Change the colors and positions of the triangles to make new faces
Add new triangles and squares to make more complex faces
Alter the functions themselves to make the shapes different
Materiaaleja
Teemu Sirkiän pdf-dokumentti Ohjelmoinnin perusteet Pythonilla. Mm. for-silmukasta on hyvät kuvaukset.