-
Notifications
You must be signed in to change notification settings - Fork 294
/
Copy pathcs.yaml
1195 lines (1136 loc) · 50.8 KB
/
cs.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
levels:
0:
1:
header: Welcome to Hedy!
text: Hedy is a programming language.
2:
header: Programming
text: |-
Programming is giving instructions to a computer, using the language of the computer.
Such a language is called a "programming language".
3:
header: Programming Language
text: |-
Maybe you already know some programming languages?
Some examples are:
* Scratch
* Python
* HTML
4:
header: Programming
text: |-
If you can program, you can do many cool things:
* Build interactive stories
* Create computer drawings and draw these on paper or fabric
* Build your own apps to use on your phone
5:
header: Programming in Hedy
text: In Hedy we use special codes, like `{print}`.
code: '{print} Welcome to Hedy!'
6:
header: Programming in Hedy
text: Code words will be shown in pink.
code: '{print} Welcome to Hedy!'
7:
header: Programming in Hedy
text: We start the code with the Run code button underneath the code.
code: '{print} Welcome to Hedy!'
8:
header: Programming in Hedy
text: Output appears on the left-hand side.
code: '{print} Welcome to Hedy!'
9:
header: Programming in Hedy
text: The output can also be a drawing.
code: |-
{forward} 100
{turn} left
1:
1:
header: Welcome to level 1!
text: |-
We will start level 1 by making stories in Hedy!
We need three text codes to create interactive stories.
2:
header: 'Hedy level 1: {print}'
text: |-
The first code that you can use in level 1 is `{print}`.
`{print}` is used to show text on the screen.
code: '{print} Show text on the screen'
3:
header: 'Hedy level 1: {ask}'
text: |-
The second code that you can use in level 1 is `{ask}`.
`{ask}` is used to ask a question that can be answered.
code: |-
{print} Welcome to your own rock scissors paper!
{ask} What will you choose?
4:
header: 'Hedy level 1: {echo}'
text: |-
The final text code that you can use in level 1 is `{echo}`.
`{echo}` is used to repeat the answer of an `{ask}`.
code: |-
{print} Hello!
{ask} What is your name?
{echo} hello
5:
header: Programming!
text: |-
with `{print}`, `{ask}` and `{echo}` you can already create a little story.
This is a good time to try the Parrot, Story and Rock, Paper Scissors adventures.
code: |-
{print} Hello!
{ask} What is your name?
{echo} hello
6:
header: Programming!
text: Adventures are shown in tabs.
editor: /hedy/1
7:
header: Programming!
text: The yellow arrow buttons can be used to copy examples.
editor: /hedy#print_command
8:
header: Drawing with the turtle
text: Now that we have seen at text codes, we will now look at drawing codes next.
editor: /hedy#print_command
9:
header: 'Drawing with the turtle: {forward}'
text: '`{forward}` is used to move the turtle forward.'
10:
header: 'Drawing with the turtle: {forward}'
text: '`{forward}` is used to move the turtle forward.'
code: '{forward} 50'
11:
header: 'Drawing with the turtle: {turn}'
text: '`{turn}` is used to make the turtle turn left or right.'
code: |-
{forward} 50
{turn} left
12:
header: Debugging
text: Debugging a code means getting rid of mistakes in the code. Let's debug this code together. Click the ladybug button to start the debugger.
code: |-
I am DJ Hedy
{print} What song would you like to hear?
{ask} I like that song too!
{print} Next up... {echo}
debug: 'True'
13:
header: Let the programming fun begin!
text: Enjoy the adventures in level 1!
2:
1:
header: Welcome to level 2
text: |-
In this level you will learn to use variables.
A variable is a word that can be used to store information.
For example: a name, age or favorite sports team.
2:
header: Variables
text: To make or 'set' a variable we use the `{is}` command
code: |-
name {is} Hedy
age {is} 15
{print} name is age years old
3:
header: Interactive
text: |-
We can also set a variable by asking questions.
The answer to the question is stored in the variable.
This way we don't need the `{echo}` command.
code: |-
name {is} {ask} What is your name?
{print} Hello name
4:
header: Multiple variables
text: Now that we use variables, we can use multiple variables instead of just one `{echo}`command.
code: |-
name {is} {ask} What is your name?
{print} Hello name
age {is} {ask} How old are you?
{print} name is age years old.
5:
header: Sleep
text: You can also use the `{sleep}` command to pause the code for a while.
code: |-
{print} My favorite colour is...
{sleep} 2
{print} green!
6:
header: Sleep 5
text: |-
You can add a number after the `{sleep}` command if you want the pause to be longer.
If you want, you could even use a variable instead of a number to decide the duration of the sleep command.
code: |-
pause {is} 10
{print} My favorite colour is...
{sleep} pause
{print} green!
7:
header: Debugging
text: Debugging a code means getting rid of mistakes in the code. Let's debug this code together. Click the ladybug button to start the debugger.
code: |-
{print} Welcome to the donut shop!
filling {is} What kind of filling would you like?
{print} You have chosen... Filling! Yum!
topping {ask} What kind of topping would you like?
topping is delicious!
{print} I'll go get your donut. {sleep}
{print} Here you go! A filling donut with toping!
{ask} Have a nice day!
debug: 'True'
8:
header: Let the programming fun begin!
text: Enjoy the adventures in level 2!
3:
1:
header: Welcome to level 3
text: In this level you'll learn how to make a list, add and remove items form your lists and pick a random item off that list.
2:
header: Making a list
text: |-
You make a list with `{is}`.
Separate the items on your list with a comma.
code: animals {is} dogs, cats, kangaroos
3:
header: At random
text: |-
You can use the list with the `{at}` `{random}` command.
The computer will randomly pick one item of the list.
Every time you run this code the output will differ.
code: |-
animals {is} dogs, cats, kangaroos
{print} animals {at} {random}
4:
header: At random in a sentence
text: You can use the `{at}` `{random}` command in a sentence as well.
code: |-
animals {is} dogs, cats, kangaroos
{print} My favorite animal is animals {at} {random}
5:
header: Add to
text: |-
You can add items to a list with the `{add}` `{to}` command.
You can choose what to add to the list or you can use the `{add}` `{to}` command in combination with the `{ask}` command.
This way you can let the player decide what to add to the list.
code: |-
animals {is} dog, cat, kangaroo
like {is} {ask} What is your favorite animal?
{add} like {to_list} animals
{print} I choose animals {at} {random}
6:
header: Remove from
text: |-
The opposite of the `{add}` `{to}` command is the `{remove}` `{from}` command.
This command removes an item from a list.
code: |-
animals {is} dog, cat, kangaroo
dislike {is} {ask} What animal do you not like?
{remove} dislike {from} animals
{print} I choose animals {at} {random}
7:
header: Debugging
text: Let's debug this code!
editor: |-
music_genres {is} rock, pop, metal, indie, jazz
chosen_genre is music {at} {random}
{print} Let's listen to chosen genre
nice {ask} Do you like that genre?
{remove} chosen_genre {from} chosen_genre
second_choice {is} music_genres
{print} or do you prefer... second_choice {at} {random}
{remove} second_choice {to} music_genres
{print} I like music_genre {random} best!
debug: 'True'
8:
header: Let's get to work!
text: Enjoy the adventures in level 3!
4:
1:
header: Welcome to level 4
text: In this level you will learn how to use quotation marks.
code: '{print} ''print with quotes!'''
2:
header: Problem
text: 'In the previous levels, you might have come across this problem:'
code: |-
name {is} Sophie
{print} My name is name
debug: 'True'
3:
header: Fixing it with quotation marks
text: |-
In this level we will fix this problem by using quotation marks.
This also makes our code look more like 'real' Python code.
4:
header: Quotation marks with print
text: Each time you use the `{print}` command you need to put the text that you want to appear on the screen in quotation marks.
code: '{print} ''print with quotes!'''
5:
header: Quotation marks with ask
text: This also goes for the `{ask}` command.
code: name {is} {ask} 'name please?'
6:
header: Quotation marks and variables
text: |-
You do not want variable names to be printed on the screen.
This is why variables should be left out of the quotation marks, like this:
code: |-
name {is} Harry
{print} 'Hello ' name
7:
header: Quotation marks and variables
text: |-
When variable names are used in the middle of a sentence, you have to leave the variables out of the quotation marks.
The rest of the sentence however, does need quotation marks. That looks like this:
code: |-
name {is} Harry
{print} 'Hello ' name ', how are you?'
8:
header: Quotation marks and contractions
text: |-
Be careful! Now that you are using quotation marks, you can't use apostrophes in contractions.
Please try to print a contraction like "you're" or "I'm" in the screen below and see what happens....
code: '{print} ''This won''t work!'''
debug: 'True'
9:
header: Ready, Set, Go!
text: Enjoy the adventures in level 4!
code: |-
{print} '3'
{clear}
{print} '2'
{clear}
{print} '1'
{clear}
{print} 'SURPRISE!'
10:
header: Debugging
text: Let's debug this code!
code: |-
{clear}
{print} What a nice day to go to the beach!
{ask} 'Do you want to build a sandcastle or swim in the ocean?'
{print} 'You would like to activity '
{print} 'I'd like to do that too'
{print} 'Look at these beautiful seashells!'
colors {is} 'orange, silver, white, brown'
{print} 'I love the colors {at} {random} one!'
choice {is} {ask} Which one do you like?
debug: 'True'
11:
header: Ready, Set, Go!
text: Enjoy the adventures in level 4!
5:
1:
header: Welcome to level 5
text: 'In this level you will learn to use 3 new commands: `{if}`, `{else}` and `{in}`.'
2:
header: if
text: |-
The `{if}` command allows you to choose between two options.
In this example the computer will print 'nice' if the given answer is Hedy.
If the answer is not Hedy, the computer will do nothing.
code: |-
name {is} {ask} 'what is your name?'
{if} name {is} Hedy {print} 'nice'
3:
header: Don't forget to print
text: |-
When using the `{if}` command, don't forget to use the `{print}` command.
This code will not work!
code: '{if} name {is} Hedy ''nice'''
debug: 'True'
4:
header: else
text: |-
When using an `{if}` command, you can also add an `{else}` command.
If the answer is Hedy, the computer will print 'nice'.
But if the answer is something else the computer will print 'boo'
code: '{if} name {is} Hedy {print} ''nice'' {else} {print} ''boo!'''
5:
header: Long lines
text: |-
You might have noticed that your lines can get very long when you have both an `{if}` and an `{else}` command.
You can choose to separate commands and put them on 2 lines, like this:
code: |-
{if} name {is} Hedy {print} 'nice'
{else} {print} 'boo!'
6:
header: Another new command
text: |-
If you have practised with the `{if}` and `{else}` commands, you can also try the `{in}` command.
With `{in}` you can let the computer check if an item is in a list, for example:
Please note that Hedy is case sensitive. This means that if you answer "Green" instead of "green", Hedy will print "meh".
code: |-
pretty_colors {is} green, yellow
favorite_color {is} {ask} 'What is your favorite color?'
{if} favorite_color {in} pretty_colors {print} 'pretty!'
{else} {print} 'meh'
7:
header: Debugging
text: Let's debug this code!
code: |-
{print} Welcome to HedyAir Security!
boarding_pass {is} {ask} 'Do you have your boarding pass?'
{if} bording_pass yes {print} Great!
{else} Please, get your boarding pass ready.
passport {is} 'Can I see your passport, please?'
{if} passport {is} yes 'thank you'
{else} 'You can't fly without a passport'
declare {is} {ask} Do you have anything to declare?
{if} declare {is} yes
item_to_declare {is} {ask} 'What would you like to declare'
{else} Alright
{print} Thank you. Please head to gate A22.'
debug: 'True'
8:
header: Let's go!
text: Enjoy the adventures in level 5!
6:
1:
header: Welcome to level 6
text: In this level we are adding maths to our codes.
2:
header: Addition
text: If you want to calculate an addition, simply use the plus sign.
code: '{print} ''5 plus 5 is '' 5 + 5'
3:
header: Subtraction
text: If you want to subtract, you can use the minus sign.
code: '{print} ''5 minus 5 is '' 5 - 5'
4:
header: Multiplication
text: If you want to do multiplications, you can use the asterisk.
code: '{print} ''5 times 5 is '' 5 * 5'
5:
header: Division
text: You can use the slash for division.
code: '{print} ''5 divided by 5 is '' 5 / 5'
6:
header: Summary
text: In summary, you can use +, -, * and / to do maths.
code: |-
{print} '5 plus 5 is ' 5 + 5
{print} '5 minus 5 is ' 5 - 5
{print} '5 times 5 is ' 5 * 5
{print} '5 divided by 5 is ' 5 / 5
7:
header: The = symbol
text: |-
From now on you can also use the = symbol instead of the `{is}` command.
This goes for both numbers and words, and it also goes after the `{if}` or `{else}` commands.
code: |-
name = Hedy
answer = 20 + 4
8:
header: Calculations with variables
text: 'You can use calculations with numbers, but you can also use variables to do calculations, like this:'
code: |-
number_1 = {ask} 'Fill in the first number:'
number_2 = {ask} 'Fill in the second number:'
correct_answer = number_1 * number_2
{print} number_1 ' times ' number_2 ' is ' correct_answer
9:
header: Debugging
text: Let's debug this code!
code: |-
{print} 'This is the water park ticket machine'
{print} 'Price list: Children under 12 $3, Adults $5'
{print} 'Mondays are 25% off'
amount_of_children = 'How many kids tickets would you like?'
amount_of_adults = 'How many adult tickets would you like?'
day_of_the_week = {ask} 'What day is it?'
{clear}
child_price = amount of children * 3
adult_price = amount_of_adults + 5
total_price = adult_price * child_price
{if} day {is} monday
total_price = total_price * 0.25
{print} 'That will be total_price please'
debug: 'True'
10:
header: Let's get to work!
text: Enjoy the adventures in level 6!
7:
1:
header: Welcome to level 7
text: In this level you will learn how to repeat a line of code as many times a you'd like.
2:
header: repeat 3 times
text: |-
If you want to repeat a line of code, you can use the `{repeat}` 3 `{times}` code.
If you want to repeat the line more times, simply change the number.
For example: If you are programming a story where your character shouts for help for 5 times, it could look like this:
code: |-
{print} 'The prince kept calling for help'
{repeat} 5 {times} {print} 'Help!'
{print} 'Why is nobody helping me?'
3:
header: Don't forget the print command
text: When using the repeat command, do not forget the `{print}` command.
code: '{repeat} 5 {times} ''Help!'''
debug: 'True'
4:
header: Repeat an ask command
text: You can also repeat an `{ask}`, `{if}` or `{else}` command multiple times.
code: |-
{repeat} 2 {times} answer = {ask} 'Did you know you could ask a question multiple times?'
{if} answer {is} yes {repeat} 2 {times} {print} 'You knew that already!'
{else} {repeat} 3 {times} {print} 'You have learned something new!'
5:
header: Debugging
text: Let's debug this code!
code: |-
{print} You gave stranded on a desert island.
{repeat} 3 'Help!'
rescued = {ask} Has anybody come to the rescue?
{if} rescued yes {is}
{print} Lucky!
{else} {repeat} 3 {times} 'HELP!'
rescued = 'What about now?'
{if} yes
{print} 'Hurray!
{else} 'That's a shame... Oh well... time to build a shelter and find some food.'
debug: 'True'
6:
header: Ready Set Go!
text: Enjoy the adventures in level 7!
8:
1:
header: Welcome to level 8
text: In this level you will learn to use indentation to make the `{repeat}`, `{if}` and `{else}` commands work for multiple lines of code.
2:
header: '{repeat} commands before'
text: |-
In the previous levels, the `{repeat}` command looked like this:
You could only repeat one line of code.
code: '{repeat} 5 {times} {print} ''Help!'''
debug: 'True'
3:
header: '{repeat} commands now'
text: |-
In this level you can repeat multiple lines of code. To do this you must tell the computer which lines belong together and should be repeated.
You do this by using indentation.
Use 4 spaces (or one tab) at the beginning of each line that you want to repeat, like this:
code: |-
{repeat} 5 {times}
{print} 'Hello everyone'
{print} 'This will be printed 5 times'
4:
header: '{repeat} commands now'
text: |-
If you want to, you can continue after the `{repeat}` command without indentation.
The lines that do not start with indentation will not be repeated.
code: |-
{repeat} 3 {times}
{print} 'Hello!'
{print} 'We are done repeating!'
5:
header: if and else before
text: |-
The same goes for the `{if}` and `{else}` commands.
These were the commands before:
code: |-
{if} name {is} Hedy {print} 'nice'
{else} {print} 'boo!'
debug: 'True'
6:
header: if and else now
text: |-
These are the `{if}` and `{else}` commands now.
Each line after the `{if}` and `{else}` commands start with indentation.
code: |-
name = {ask} 'What is your name?'
{if} name {is} Hedy
{print} 'Welcome Hedy'
{else}
{print} 'Welcome programmer!'
7:
header: stopping the indentation
text: Just like with the `{repeat}` command, you can stop using indentation and the lines will always be shown. Not just if the statement is true.
code: "name = {ask} 'What is your name?'\n{if} name {is} Hedy\n {print} 'Welcome Hedy'\n{else}\n {print} 'Welcome programmer!' \n{print} '3..2..1.. Start programming!'"
8:
header: if statements inside if statements
text: |-
You might have thought of trying to put an if command inside a repeat command, or inside another if command.
For now, this is not possible yet. In the higher levels, it will be allowed, but for now let's focus on practising the `{if}` `{else}` and `{repeat}` commands with proper indentation first.
9:
header: Debugging
text: Let's debug this code!
code: |-
{print} 'HedyWheels bus tickets machine'
zone_1 = Town Hall, Library, Campus, Market Place
zone_2 = Swimming Pool, Skate Park, Mall, Airport
destination = 'Where do you want to go?'
{if} destination {in} zone 1
{print} destination 'is in zone 1'
price = 3 euros
{if} destination {is} zone_2
{print} destination 'is in zone 2'
price = 6
ticket_types = {ask} 'Press 1 for a single use ticket.
Press 2 for a round trip ticket:'
{if} ticket_type = 1
{print} 'You chose a single use ticket'
{else}
{print} You chose a round trip ticket'
price * 2
{print} 'That will be ' price ' euros please'
debug: 'True'
10:
header: Let's check out the adventures!
text: Enjoy the adventures in level 8!
9:
1:
header: Welcome to level 9
text: |-
In this level you can use multiple lines of code after an `{if}` or after a `{repeat}` command.
You can even put a `{repeat}` command within another `{repeat}` command.
2:
header: Multiple lines after `{repeat}`
text: You are allowed to combine `{repeat}` and `{if}` in this level.
code: |-
{repeat} 3 {times}
food = {ask} 'What do you want?'
{if} food {is} pizza
{print} 'nice!'
{else}
{print} 'pizza is better'
3:
header: Indentation matters!
text: Indentation is very important to tell the computer which lines should be repeated and which lines should only be ran once.
code: |-
{repeat} 3 {times}
{print} 'This line will be repeated...'
{print} 'This one too...'
{print} 'but this one will not!'
4:
header: Multiple lines after `{if}`
text: You can also use multiple lines after `{if}`
code: |-
continue = {ask} 'Do you want to continue?'
{if} continue = yes
sure = {ask} 'Are you sure?'
{if} sure {is} yes
{print} 'We will continue'
{else}
{print} 'You are not sure'
{else}
{print} 'You do not want to continue'
5:
header: Indentation matters
text: Again, indentation is still very important and can make a big difference in the code.
code: |-
continue = {ask} 'Do you want to continue?'
{if} continue = yes
sure = {ask} 'Are you sure?'
{if} sure {is} yes
{print} 'We will continue'
{else}
{print} 'You are not sure'
6:
header: An `{if}` inside a `{repeat}`
text: |-
Now that you can use multiple lines of code after these command, you can also put them within each other.
Check it out:
code: |-
{repeat} 3 {times}
food = {ask} 'What do you want?'
{if} food {is} pizza
{print} 'nice!'
{else}
{print} 'pizza is better'
7:
header: Mind the indentation
text: Mind that the fourth and sixth line of this code starts with 8 spaces of indentation.
code: |-
{repeat} 3 {times}
food = {ask} 'What do you want?'
{if} food {is} pizza
{print} 'nice!'
{else}
{print} 'pizza is better'
8:
header: Debugging
text: Let's debug this code!
code: |-
{print} 'Welcome to HedyJumps, your parachute jump adventure!'
people = {ask} 'How many people are you jumping with today?
{print} 'We'll ask all of you some questions for safety reasons.'
extra_instructions_people = a, b
{repeat} 3 {times}
name = {ask} 'What is your name?'
jumped_before = 'Have you ever done a parachute jump before, ' name '?'
{if} jumped_before no
{print} 'No worries, you'll get an extra safety instruction in room 13'
{add} name {to} extra_instructions_people
{else}
{print} 'Fun!'
{print} 'Thanks for filling in the safety questions everyone. Enjoy your jump!'
debug: 'True'
9:
header: Let's go!
text: Enjoy the adventures in level 9!
10:
1:
header: Welcome to level 10
text: 'In this level you will learn a new command: `{for}`.'
2:
header: The for command
text: With for you can make a list and use all items on that list. `{for}` creates a block, like repeat and if so all lines in the block need to start with indentation (4 spaces).
code: |-
animals = dog, cat, blobfish
{for} animal {in} animals
{print} 'I love ' animal
3:
header: The for command
text: 'Here you see another example of the `{for}` command:'
code: |-
days = Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday
names = mom, dad, Emma, Sophie
{for} day {in} days
{print} names {at} {random} ' does the dishes on ' day
4:
header: Debugging
text: Let's debug this code
code: |-
{print} 'Ladies and gentlemen!'
{print} 'For one night and one night only in circus Hedy!'
acts = shoot out of a canon, walk the tightrope, pack themself in a suitcase,
people = Iris the Incredible Achmed the Amazing Francis the Fantastic
{for} people {in} acts
chosen_person {is} people {random}
chosen_person ' will ' act
{add} chosen_person {from} people
{print} 'Come and watch our show tonight!'
{print} 'Tickets are only available at the counter
debug: 'True'
5:
header: Time to program!
text: Enjoy the adventures in level 10!
11:
1:
header: Welcome to level 11
text: |-
In this level, we add a new form of the `{for}` command. In earlier levels, we used for with a list, but we can also use for with numbers.
This way we don't need the `{repeat}` command anymore.
2:
header: The for command
text: 'This is what the new for command looks like:'
code: |-
{for} counter {in} {range} 1 {to} 10
{print} counter
{print} 'Ready or not. Here I come!'
3:
header: the variable i
text: |-
In the previous slide the variable was named 'counter', because it was counting down.
You can of course use any name for the variable you want.
The standard name for variables in this situation that is used in programming languages like Python is 'i'.
That looks like this:
code: |-
number = 10
{for} i {in} {range} 1 {to} 10
{print} i * number
4:
header: Debugging
text: Let's debug this code!
code: |-
factor {is} {ask} 'Which table of multiplication do you need?'
{repeat} {for} numbers {in} {range} 1 {to} 10 {times}
{print} This is the table of multiplications for factor
{print} number ' x ' factor ' = ' i * factor
debug: 'True'
5:
header: Let's start programming!
text: Enjoy the adventures in level 11!
12:
1:
header: Welcome to level 12
text: |-
From this level on you are allowed to use decimal numbers and there are some changes to the quotation marks.
You can also use functions from this level on!
2:
header: Quotation marks
text: |-
This level makes some changes to the usage of quotation marks.
From now on, **all texts** need to be in quotation marks. This includes values of variables, items on lists and text after {if} commands.
code: |-
name = 'Hedy the Robot'
{print} 'Hello ' name
3:
header: Decimal numbers
text: |-
From this level on you are also allowed to use decimal numbers. This can make programs like your restaurant even better!
Numbers do not need quotation marks.
code: |-
{print} 'decimal numbers now need to use a dot'
{print} 2.5 + 2.5
4:
header: Functions!
text: |-
In this level you'll learn how to use functions. A function is a block of code you can easily use multiple times. Using functions helps us organize pieces of code that we can use again and again. To create a function, use define and give the function a name. Then put all the lines you want in the function in a indented block under the define line. Leave one empty line in your code to make it look nice and neat. Great job! You have created a function!
Now, whenever we need that block of code, we just use call with the function's name to call it up! We don't have to type that block of code again.
5:
header: Twinkle Twinkle little star!
text: |-
In this program you see an example of a function.
Let's see what happens if you fill in the rest of the song!
code: |-
{define} twinkle
{print} 'Twinkle'
{print} '...'
{call} twinkle
{print} 'Up above the world so high'
{print} 'Like a diamond in the sky'
{call} twinkle
6:
header: Functions
text: As you could see in the example a function is a block of code that can be called anytime. You use `{define}` to set the function and `{call}` to use it.
7:
header: Debugging
text: Let's debug this code!
code: |-
{call} new_member
{print} 'Hi new member!'
username = {ask} 'What is your username?'
password = 'What is your password?'
{print} 'Welcome to our club!'
username = {ask} 'Please enter your username. Are you a new member? Type New Member'
{if} username = New Member
{call} new member
{else}
password = {ask} 'Please enter password'
debug: 'True'
8:
header: Ready to try it out?
text: Enjoy the adventures in level 12!
13:
1:
header: Welcome to level 13
text: |-
We are now going to learn `{and}` and `{or}`! If you want to check two statements, you don't have to use two ifs but can use and and or.
From now on you could also use arguments in your functions.
2:
header: The and command
text: |-
The `{and}` command is always used in a combination with the {if} command.
This way you can check if 2 statements are true. For example:
code: |-
name = {ask} 'what is your name?'
age = {ask} 'what is your age?'
{if} name {is} 'Hedy' {and} age {is} 2
{print} 'You are the real Hedy!'
3:
header: The or command
text: |-
The `{or}` works in the same way as the `{and}` command, but only 1 of the two statements has to be true.
Let's see what happens when you change the `{and}` for `{or}`.
code: |-
name = {ask} 'what is your name?'
{if} name {is} 'Hedy' {or} name {is} 'hedy'
{print} 'Welcome!!'
4:
header: Functions with arguments
text: Now that you've learned how to use functions, you'll learn how to use a function with an **argument**. An argument is a variable that is used within a function. It is not used outside the function.
5:
header: Example
text: |-
In this example you see how the argument 'place' is used in the function.
Run the code and change 'ocean' and 'sea' to something else, and see what happens.
code: |-
{define} song {with} place
{print} 'My Bonnie is over the ' place
{call} song {with} 'ocean'
{call} song {with} 'sea'
{call} song {with} 'ocean'
6:
header: Example with variable
text: |-
You can also combine functions with a question.
What happens if you make these changes:
```
define song with place
print 'My Bonnie is ' place
answer is ask 'Where is my Bonnie?'
call song with answer
```
code: |-
{define} song {with} place
{print} 'My Bonnie is over the ' place
{call} song {with} 'ocean'
{call} song {with} 'sea'
{call} song {with} 'ocean'
7:
header: Even more questions!
text: |-
Now we have combined even more question with the function. Type this code and see what happens.
Note how the variables and the arguments have the same name. This is allowed.
Does it confuse you? Just use different names, that is allowed as well.
```
define song with name, place
print 'My ' name ' is ' place
name is ask 'Who?'
place is ask 'Where are they?'
call song with name, place
```
code: |-
{define} song {with} place
{print} 'My Bonnie is over the ' place
{call} song {with} 'ocean'
{call} song {with} 'sea'
{call} song {with} 'ocean'
8:
header: Debugging
text: Let's debug this code!
code: |-
{define} happiness {with} name
{print} '🥳'
{play} G
{play} A
{play} B
{print} 'Party on, ' name
{define} sadness
{print} '😞'
{play} E
{play} D
{play} C
{print} 'Hope you feel better, ' name
name = {ask} 'What is your' name '?'
mood = {ask} 'Are you happy or sad?'
{if} mood = happy
{call} happiness {with} person
{else} mood = sad
{define} sadness {to} name
debug: 'True'
9:
header: Let's go!
text: Enjoy the adventures in level 13!
14:
1:
header: Welcome to level 14
text: In this level you'll learn some new symbols that can help you improve your programs, like >. You will also learn to work with return values of a function.
2:
header: Symbols
text: |-
These are the new symbols you can use:
The > means bigger than...
The >= means bigger than or the same as...
The < means smaller than...
The <= means smaller than or the same as...
You can use them like this:
code: |-
age = {ask} 'How old are you?'
{if} age < 13
{print} 'You are younger than me!'
{else}
{print} 'You are older than me!'
3:
header: Symbols
text: |-
You can also use:
== is the same as.
!= is not
== is used in `{if}` statements.
code: |-
answer = {ask} 'Do you want to learn more?'
{if} answer == 'yes'
{print} 'Go to the next adventure!'
{if} answer != 'yes'
{print} 'That is a shame!'
4:
header: Return value
text: In the previous levels you have learned to create functions and use arguments with them. Another great use of a function is to let it calculate something for you. You can give the function a calculation and it will give you the answer of the calculation. This answer is called a **return value**.
5:
header: Return value
text: For example, in this code the function calculate_new_price will calculate the new price of any item. It will give you the new price as a return value.
code: |-
{define} calculate_new_price {with} amount, percentage
percentage = percentage / 100
discount_amount = amount * percentage
{return} amount - discount_amount
old_price = {ask} 'How much is on the price tag?'
discount = {ask} 'What percentage is the discount?'