-
Notifications
You must be signed in to change notification settings - Fork 289
/
cy.yaml
5289 lines (4973 loc) · 266 KB
/
cy.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
adventures:
story:
name: Story
default_save_name: Story
description: Story
levels:
1:
story_text: |
In level 1 you can make a story with a different main character that you enter yourself.
In the first line, use `{ask}` and ask who the main character of the story will be.
After that first line, start with `{print}` if the sentence needs to be printed.
You use `{echo}` if you want your main character to be at the end of the sentence.
example_code: |
```
{ask} The main character of this story is
{print} The main character is now going to walk in the forest
{echo} They're a bit scared,
{print} They hear crazy noises everywhere
{print} They're afraid this is a haunted forest
```
story_text_2: |
### Exercise
Can you make your own story in Hedy now by using `{print}` , `{ask}` and `{echo}`?
2:
story_text: |
In level 2 you can make your story more fun. Your main character's name can now be anywhere in the sentence.
You do have to program a little bit extra for that. You must now name your main character first.
You can then put that name anywhere in a sentence.
### Exercise
Can you make a story using a variable yourself? Can you add even more variables?
example_code: |-
```
name {is} {ask} What is the name of the main character?
{print} name is now going to run in the woods
{print} name is a bit scared
{print} Suddenly she hears a crazy noise...
{sleep}
{print} name is afraid this is a haunted forest
```
story_text_2: |
### Exercise
Now it's time to add variables to your own story that you've made in the previous level.
Go to 'My programs', look for your level 1 story adventure and copy the code. Paste the code in your input screen in this level.
This code won't work in this level, because you have not used variables yet.
Change the `{ask}` commands and `{echo}` commands in your code to the correct form that you've learned in this level.
**Extra** Add a sleep command to your code to build up tension in your story.
3:
story_text: |
In level 3 you can make your story more fun. You can use randomness for any monster, animal or other obstacle, like this:
example_code: |
```
animals {is} 🦔, 🐿, 🦉, 🦇
{print} They now hear the sound of an animals {at} {random}
```
story_text_2: |
The command `{add}` can also come in handy in your story.
example_code_2: |
```
{print} They hear a sound
animals {is} 🐿, 🦔, 🦇, 🦉
animal {is} {ask} What do you think it is?
{add} animal {to_list} animals
{print} it was an animals {at} {random}
```
story_text_3: |
This is an example of the `{remove}` command in your story
### Exercise
Can you use the 3 new commands `{at} {random}` , `{add} {to_list}` and `{remove} {from}` in your own story?
example_code_3: |
```
{print} His backpack got way too heavy.
{print} Inside were a bottle of water, a flashlight and a brick.
bag {is} water, flashlight, brick
dump {is} {ask} Which item should he dump?
{remove} dump {from} bag
```
4:
story_text: |
### Exercise
Copy the example code and finish it by adding quotation marks on the blanks in lines 1 and 2.
The blanks in line 3 and 4 should not be replaced by quotation marks, but a `{sleep}` and a `{clear}` command. Can you make it work?
### Exercise 2
Go back to the previous level and copy your story code. Make the code work in this level by adding quotation marks in the right spots.
Mind: The variables in your own story should be outside of the quotation marks. Just like the second line of the example code. In that line the variable name is placed outside of the quotation marks.
example_code: |
```
name {is} {ask} _ What is your name? _
{print} _ The main character is called _ name
_
_
{print} name _ is now going to walk in the woods _
{print} name _ is a bit scared _
animals {is} 🦔, 🐿, 🦉, 🦇
{print} _ He hears the sound of a _ animals {at} {random}
{print} name _ is afraid this is a haunted forest _
```
5:
story_text: |
In this level you can program different endings, which will make your story even more fun.
### Exercise
Think of two endings for your story, for example:
- The princess is walking through the forest
- She runs into a monster
- Happy ending: She takes her sword and the monster quickly runs away
- Bad Ending: The monster eats the princess
You can also ensure that a name can be entered again. That works just like in the previous levels. You can combine that with an `{if}`, and then you have already made a whole program!
example_code: |
```
name {is} {ask} 'Who is walking in the forest?'
{print} name ' walks through the forest'
{print} name ' encounters a monster'
end {is} {ask} 'Would you like a good or a bad ending?'
{if} end {is} good {print} name ' takes the sword and the monster quickly runs away'
{else} {print} 'The monster eats ' name
```
7:
story_text: |
In a story, someone says words several times. For example, when someone calls for help or sings a song.
You can put such repetitions in your story, in this level with `{repeat}`.
### Exercise
Can you make your own story with repitition?
example_code: |
```
{print} 'The prince kept calling for help'
{repeat} 5 {times} {print} 'Help!'
{print} 'Why is nobody helping me?'
```
8:
story_text: |
In this level you can use multiple lines in your {if} commands, this way you can upgrade your happy or sad ending!
### Exercise
Can you make your own story with two different endings?
example_code: |
```
{print} 'OH NO! The T-rex is closing in!'
end = {ask} 'Do you want a happy or a sad ending?'
{if} end {is} happy
{print} 'Just in time Richard jumps back into the time machine!'
{print} 'Michael types in the code and...'
{print} '💥ZAP!💥'
{print} 'They are back in their garage'
{else}
{print} 'Michael yells COME ON RICHARD! RUN FASTER!'
{print} 'But Richard is too slow...'
{print} 'The T-rex closes in and eats him in one big bite!🦖'
```
9:
story_text: |
In this level you can use nesting to put `{if}`, `{repeat}` or `{for}` commands inside other `{if}`, `{repeat}` or `{for}` commands. This gives you many options and really helps you to make your story interactive.
example_code: |
```
{print} 'Robin is walking downtown'
location = {ask} 'Is Robin going into a shop, or does she go home?'
{if} location {is} shop
{print} 'She enters the shop.'
{print} 'Robin sees an interesting looking book'
book = {ask} 'Does Robin buy the book?'
{if} book {is} yes
{print} 'Robin buys the book and goes home'
{else}
{print} 'Robin leaves the shop and goes home'
{else}
{print} 'Robin goes home'
```
10:
story_text: |
In this level you can use the {for} command in your story. In this way you could easily program the children's book 'brown bear, brown bear, what do you see'.
example_code: |
```
animals = red bird, black sheep, green frog, yellow duck, little child
{print} 'brown bear'
{print} 'brown bear'
{print} 'What do you see?'
{for} animal {in} animals
{print} 'I see a ' animal ' looking at me'
{print} animal
{print} animal
{print} 'What do you see?'
{print} 'I see all the animals looking at me!'
```
12:
story_text: In this level you can use the quotation marks to save multiple words in a variable.
example_code: |
```
name = 'The Queen of England'
{print} name ' was eating a piece of cake, when suddenly...'
```
13:
story_text: |
By using the `{and}` and `{or}` commands, you can shorten your stories. For example, check out the dragon story.
### Exercise
Can you make your own adventure minigame like this?
example_code: |
```
sword = 'lost'
game = 'on'
{print} 'Our hero is walking through the forest'
{print} 'The path splits two ways'
{for} i {in} {range} 0 {to} 2
{if} game {is} 'on'
path = {ask} 'Which path should she choose?'
{if} path {is} 'left' {and} sword {is} 'found'
{print} 'Our hero comes across a dragon!'
{print} 'Luckily our hero has a sword to defeat the beast!'
game = 'over'
{if} path {is} 'left' {and} sword {is} 'lost'
{print} 'Our hero finds a dragon, but she doesnt have any weapons!'
{print} 'Our hero is beaten by the dragon...'
{print} 'Try again'
game = 'over'
{if} path {is} 'right' {and} sword {is} 'found'
{print} 'You have already found the sword. There is nothing left here.'
{print} 'She walks back'
{if} path {is} 'right' {and} sword {is} 'lost'
{print} 'Our hero finds a sword'
{print} 'This could come in very handy'
sword = 'found'
```
15:
story_text: |
Using the `{while}` loop can make your stories more interesting. For example, you can use `{while} game == 'on'` so you can play until the game is over.
Or you can use `{while} sword == 'lost'` so the player can't continue the game until they have found something.
### Exercise
The example code shows you how to use the `{while}` loop in a story. Now **think of your own scenario** in which the player has to find something before they can continue.
example_code: |
```
keys = 'lost'
{print} 'You are standing in your garden and you have lost your keys.'
{print} 'Where do you want to look for them?'
{print} 'You can choose: tree, flowerbed, rock, postbox'
{while} keys == 'lost'
location = {ask} 'Where do you want to look?'
{if} location == 'flowerbed'
{print} 'Here they are!'
keys = 'found'
{else}
{print} 'Nope they are not at the ' location
{print} 'Now you can enter the house!'
```
18:
story_text: |
We are going to print another story, but now we have to use brackets with `{print}`.
### Exercise 1
Create a story of at least 5 sentences. You don't have to use 'name' just yet.
example_code: |
```
{print}('Welcome to this story!')
```
story_text_2: |
### Exercise 2
We have already prepared an `{input}` for you. First, use the `name` variable in your story.
Then add a second `{ask}` and use that variable as well.
Tip: Remember the commas in a `{print}` between text and variables!
example_code_2: |
```
naam = {input}("What's your name?")
{print}('Welcome to this story!')
```
add_remove_command:
name: '{add} {to} & {remove} {from}'
default_save_name: add_remove_command
description: introducing add to and remove from
levels:
3:
story_text: |
## Add to
You can add items to the list with the `{add} {to_list}` command. To add an item to a list you can simply type: `{add} penguin {to} animals` or you can use the `{ask}` command like in the example code.
example_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}
```
story_text_2: |
## Remove from
If you can add items to a list, of course you can also take them off. This is done with the `{remove} {from}` command.
example_code_2: |
```
animals {is} dog, cat, kangaroo
dislike {is} {ask} What animal do you not like?
{remove} dislike {from} animals
{print} I choose animals {at} {random}
```
story_text_3: |
### Exercise
Try out the new commands in this virtual restaurant. Add the flavor the player is hpoing for to the list and remove the flavors they are allergic to.
example_code_3: |
```
{print} Mystery milkshake
flavors {is} strawberry, chocolate, vanilla
hope {is} {ask} What flavor are you hoping for?
_
allergies {is} {ask} Are you allergic to any flavors?
_
{print} You get a flavors {at} {random} milkshake
```
and_or_command:
name: '{and} & {or}'
default_save_name: and or
description: introducing and or
levels:
13:
story_text: |-
We are now going to learn `{and}` and `{or}`! If you want to check two statements, you don't have to use two `{if}`s but can use `{and}` and `{or}`.
If you use `{and}`, both statements, left and right of the `{and}` need to be true. We can also use `{or}`. Then only one statement needs to be correct.
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!'
```
ask_command:
name: '{ask}'
default_save_name: ask_command
description: Introduction ask command
levels:
1:
story_text: |
## The ask command
Now that you can use the `{print}` command, you are ready to learn the next command: `{ask}`. With the `{ask}` command, you can ask a question. Check it out:
example_code: |
```
{print} Hello!
{ask} What is your name?
```
story_text_2: |
## The echo command
If you want the computer to repeat the answer, you can use the `{echo}` command. The answer will then be echoed back at the end of the sentence, so in this example after hello.
example_code_2: |
```
{print} Hello!
{ask} What is your name?
{echo} hello
```
story_text_3: |
### Exercise
Try out the `{ask}` and `{echo}` commands. Firstly, fill in the blanks to make this program work.
Then ask 2 more questions using the `{ask}` command, after each `{ask}` use an `{echo}` to print the answer on the screen.
example_code_3: |
```
_ How are you doing?
_
```
2:
story_text: |
## The ask command
Now that we can use **variables** in our codes, we no longer need the `{echo}` command.
We can use variables to store the answers to our questions and this way we can use the answer to multiple questions in our codes.
Check it out:
This way your code is becoming interactive!
example_code: |
```
name {is} {ask} What is your name?
{print} Hello name
age {is} {ask} How old are you?
{print} name is age years old.
```
story_text_2: |
### Exercise
In the previous tab you have practised with setting variables with the `{is}` command.
You have created at least 3 variables and used them with a print command.
Now, instead of setting the variables we want you to make the variables interactive, like we did in our example.
Copy your code from the previous tab and make the variables interactive by using `{ask}` commands.
example_code_2: |
```
favorite_animals is ask What is your favorite animal?
print I like favorite_animals
```
18:
story_text: The final change we will need to make to get Python code is changing `{ask}` into `{input}`.
example_code: |
```
{print}('My name is Hedy!')
name = {input}('What is your name?')
{print}('So your name is ', name)
```
blackjack:
name: Blackjack
default_save_name: Blackjack
description: Try to get as close to 21 as you can
levels:
17:
story_text: |
Blackjack is a simple game of cards in which you have to get as close to 21 points as possible. You get two cards. Each card is worth their numeral value, and the face cards (Jack, Queen and King) are worth 10 points.
The Ace is worth either 1 or 11 points (you can choose). The dealer, your opponent, also gets two cards.
If you want, you can get another card, and its points will be added to your total. The dealer can also choose to take another card.
But be careful not to get more than 21 points, because if you do, you lose!
The player who gets closest to 21, without going over it, wins!
### Exercise
In this adventure we code the first part of our Blackjack game. We'll create a function to calculate how many points a card is worth.
***Set the variables***
Start by making a list of all the cards, from 2 to Ace. Next make a list of the face cards, so Jack, Queen and King. Then pick a random card from the list of cards to be card_1.
***Create a function to calculate the points***
Create a function that calculates how many points a card is worth.
All the face cards are worth 10 points, the Ace is worth 11 and all the other cards are worth their numeral.
Return the variable `points` at the end of the function.
***Test the function***
Test if your function is working properly. Finish the first print command by filling in which card you've drawn. Then finish the second line by calling the function with card_1.
Run the code a couple of times. Are you happy with the results? Great! Then you can remove the testing part and move on the the next tab!
example_code: |
```
{print} 'BLACKJACK'
# Set these variables
cards = _
face_cards = _
card_1 =
# Create a function to calculate the points
{define} calculate_points {with} card:
{if} card {in} face_cards:
points = _
{elif} _
_
{else}:
_
_ points
# Test your function
{print} 'Your card is a ' _
{print} 'That is worth ' _ ' points'.
```
blackjack_2:
name: Blackjack 2
default_save_name: Blackjack_2
description: Blackjack part 2
levels:
17:
story_text: |
### Exercise
In this adventure we code the second part of our Blackjack game.
***Paste your code from the previous adventure***
In the previous adventure you've started a list of variables and created a function to calculate how many points a card is worth. Copy your code and paste it here. Mind that you don't need the testing part, so if you haven't removed that yet, please do so now.
***Add more variables***
You have already set the lists `cards` and `face_cards` and the variable `card_1`. Underneath those variables create 3 more variables: `card_2`, dealer_card_1` and `dealer_card_2`. These variables are all set to a random card from the list of cards.
***Add up points***
To calculate how many points you have scored we call the function with card 1 and we do it again for card 2. Then we add both these scores together to get your total.
Do the same thing for the dealers points, but be sure to use the dealer's cards and not your own!
***2 Aces***
You're doing great! Almost all scores can be calculated now. There is only one exception: 2 Aces. If you get 2 Aces, your total is 12 points and not 22 (because 22 points would be losing!). This of course also goes for the dealer.
***Show the score***
Lastly, you want to tell the program to tell you which cards you have drawn and how many points that is. Then show which cards the dealer has and how many points they have.
***Continue in the next tab***
Great! You have finished this part of the game! Copy your code and go to the next tab to learn how to ask for an extra card and to declare a winner.
example_code: |
```
# Paste your code from the previous adventure here
# Add these variables to the list of variables
card_2 = _
dealer_card_1 = _
dealer_card_2 = _
# Add up your points
your_points_1 = {call} _ {with} card_1
your_points_2 = _
your_total = _
# Add up the dealers points
dealer_points_1 = _
_
_
# 2 Aces
{if} card_1 == 'Ace' {and} _
your_total = 12
{if} dealer_card_1 _
dealer_total = _
# Show the score
{print} 'You have drawn a ' _ ' and a ' _ '. That is ' _ ' points'
{print} 'The dealer has drawn a ' _ ' and a ' _ '. That is ' _ ' points'
```
blackjack_3:
name: Blackjack 3
default_save_name: Blackjack_3
description: Blackjack part 3
levels:
17:
story_text: |
In the previous tabs you have learned how to draw 2 random cards for yourself and for the dealer and to calculate how many points you both got.
In this adventure we add the option to ask for an extra card for both you and the dealer.
### Exercise
***Paste your code from the previous adventure*** Firstly, copy your code from the previous tab and paste it here.
***Extra card for you*** If you want, you can get an extra card to get your total as close to 21 as possible. First ask the player if they want an extra card.
If they do, pick a random card and print what they have drawn. If the card is not an Ace, you can call the function and add the points to your total.
In case the card is an Ace, you can't use the function, because the Ace can be either 1 point or 11 points, depending on how many points you already have earned.
If your total is less than 11, you want the ace to be 11 points (because this is closest to 21). So you add 11 points to your total.
If the total is more than or equal to 11, you want the ace to be 1 point (because you don't want more than 21 points). So you add 1 point to your total.
Lastly, print your new total of points.
***Extra card for the dealer*** The dealer can also get an extra card. The dealer doesn't need to be asked, because they always get an extra card if their total is less than 17.
Copy the 'Extra card for you code' and paste it in the dealers section. Then change it to fit the dealer picking an extra card and getting points added to their total.
example_code: |
```
# Paste your code from the previous adventure here
# Extra card for you
hit = {ask} _
{if} hit == 'yes':
card_3 = _
{print} _
{if} card_3 _ 'Ace':
your_points_3 = _
your_total = _
{else}:
{if} your_total _
_
{else}:
_
{print} _
# Extra card for the dealer
{if} dealer_total < 17
_
```
blackjack_4:
name: Blackjack 4
default_save_name: Blackjack_4
description: Blackjack part 4
levels:
17:
story_text: |
In the last 3 adventures you have alsmost created a working blackjack game! The only thing left to do is to decide a winner!
### Exercise
***Paste your code from the previous adventure*** Start by pasting the code that you've made so far into your programming field.
***Decide a winner***
Firstly, if you and the dealer have an equal amount of points, it's a draw.
Secondly, if the dealer has more than 21 points and you don't, you are the winner.
Thirdly, if both you and the dealer have less than 22 points, we have to see who came closest to 21. We do that by comparing who has the highest score. Is your total higher than the dealer's total, then you are the winner. If not, the dealer wins.
Lastly, in all other scenarios (e.g. you have more than 21 points and the dealer doesn't, or you both have more than 21 points) you are the loser.
***Enjoy the game!***
Does your game work properly? Amazing! You have done a great job! Enjoy your game!
If it doesn't work right away, no worries, you might have made a mistake. Just keep calm and bebug your code using the ladybug button.
example_code: |
```
# Paste your code from the previous adventure here
# Decide a winner
{if} _
{print} 'Its a draw! Play again!'
{elif} _
{print} 'You win!'
{elif} _ :
{if} _:
{print} _
{else}:
{print} _
{else}:
_
```
calculator:
name: Calculator
default_save_name: Calculator
description: Create a calculator
levels:
6:
story_text: |
Now that you can do maths, you can make a calculator yourself!
example_code: |
```
number_1 {is} {ask} 'Fill in the first number:'
number_2 {is} {ask} 'Fill in the second number:'
correct_answer = number_1 * number_2
{print} number_1 ' times ' number_2 ' is ' correct_answer
```
story_text_2: |
### Exercise
The calculator above will calculate the answer for you, but you can also make a program to test your own maths skills, like this:
Fill in the blanks to make it complete!
example_code_2: |
```
correct_answer = 11 * 27
answer = {ask} 'How much is 11 times 27?'
{if} answer {is} _ {print} 'good job!'
{else} {print} 'Wrong! It was ' _
```
story_text_3: |
You can also let the computer do random calculations on its own using {random}.
example_code_3: |
numbers = 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
number_1 = _
number_2 = _
correct_answer = number_1 * number_2
given_answer = 'What is ' number_1 ' times ' number_2 '?'
{if} _
{else} _
9:
story_text: |
In a previous level you've created a calculator, in this level you can expand that code so it asks multiple questions.
### Exercise 1
Can you finish line 10 to get the code to work?
### Exercise 2
Give the player feedback when the enter an answer, like `{print} 'Correct!'` or `{print} 'Wrong! The correct answer is ' correct_answer`.
example_code: |
```
score = 0
{repeat} 10 {times}
numbers = 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
number_1 = numbers {at} {random}
number_2 = numbers {at} {random}
correct_answer = number_1 * number_2
{print} 'What is ' number_1 ' times ' number_2 '?'
answer = {ask} 'Type your answer here...'
{print} 'Your answer is ' answer
{if} _ {is} _
score = score + 1
{print} 'Great job! Your score is... ' score ' out of 10!'
```
10:
story_text: |
This calculator game helps you practise your tables of multiplication!
### Exercise
Fill in the blanks. We want this program to ask the player these questions:
```
How much is 1 times 1?
How much is 1 times 2?
How much is 1 times 3?
How much is 2 times 1?
How much is 2 times 2?
How much is 2 times 3?
How much is 3 times 1?
How much is 3 times 2?
How much is 3 times 3?
_
```
example_code: |
```
numbers = 1, 2, 3
{for} _
{for} _
answer = {ask} _
correct = number_1 * number_2
{if} answer {is} correct
{print} 'Great job!'
{else}
{print} 'That is wrong. The right answer is ' correct
```
11:
story_text: |
With a `{for}` you can simplify tables of multiplication practise program.
### Exercise 1
Improve the example code such that it prints a nice multiplication table: <br> "1 times 10 is 10", "2 times 10 is 20", etc.
### Exercise 2
Go back to your level 10 multiplication code, and modify it so that it uses a `{for}` and `{range}`.
example_code: |
```
number = 10
{for} i {in} {range} 1 to 10
{print} i * number
```
12:
story_text: |
In this level, you can make a calculator that works for decimal numbers.
### Exercise 1
Fill out the blanks to complete the calculator. Remember to use a period and not a comma for decimal numbers.
### Exercise 2
Create a new mathematics practice program, but now use decimal numbers.
Create a list of numbers, choose two to multiple and let the player answer.
And of course you have to validate the answer! **(extra)** Increase the difficulty by adding lives: A player loses a life for a wrong answer and after three wrong answers the game ends.
example_code: |
```
number1 = {ask} 'What is the first number?'
number2 = {ask} 'What is the second number?'
answer = _
{print} number1 ' plus ' number2 ' is ' _
```
13:
story_text: |
### Exercise 1
Let's make the practice program a bit harder. The player now has to answers two questions correctly. Fill out the blanks to complete the program.
### Exercise 2
Sometimes, calculations have multiple correct answers. For example, 10 can be divided by 5 and by 2. So the question 'What number divides 10?' can be answered by 2 and by 5.
Ask for a calculation that has multiple correct answers, ask the player to answer it, and determine if it is correct using `{or}`.
Empty the programming field and create your own solution.
example_code: |
```
answer1 = {ask} 'What is 10 times 7?'
answer2 = {ask} 'What is 6 times 7?'
{if} _ _ _ _ _ _ _
{print} _
```
14:
story_text: |
In this adventure you will build a calculator that calculates your mean grade for you. If you get your calculator to work, you can move on to the next adventure, which allows you to add two extra features.
### Exercise 1
Fill in the blanks to get the calculator to work.
* Start with the fourth line, add a question to figure out what grade the student got.
* In the fifth line you'll want to calculate the total of all grades, so the total = total + grade.
* Then we get to set the return value. We want to return the mean, so the total devided by the amount of tests (4).
* Lastly we finish the code by calling the function in line 8.
Did you get it? Awesome! Would you like to add even more to your calculator? **This adventure continues in the next tab!**
example_code: |
```
{define} calculate_mean_grade
total = 0
{for} i {in} {range} 1 {to} 4
grade = {ask} _
total = total + _
return _ / 4
mean_grade = {call} _
{print} 'Your mean grade is ' mean_grade
```
total = total + _
return _ / 4
mean_grade = {call} _
{print} 'Your mean grade is ' mean_grade
15:
story_text: |
You can add the `{while}` loop to the calculator game you've learned to make in a previous level.
This makes sure the player can't continue to the next question if they answer incorrectly.
### Exercise
Add the `{while}` loop in the function, ask the player what number_1 times number_2 is and print their answer.
Then `{call}` the function.
example_code: |
```
{define} new_question
numbers = 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
number_1 = numbers {at} {random}
number_2 = numbers {at} {random}
correct = number_1 * number_2
answer = 0
_
_
_
{print} 'Well done!'
{print} 'Give 10 correct answers to win!'
{for} i {in} {range} 1 {to} 10
_
{print} 'You win!'
```
calculator_2:
name: Calculator 2
default_save_name: Calculator 2
description: Calculator 2
levels:
14:
story_text: |
### Exercise 2
**This is the second part of this adventure.** The adventure starts in the previous tab.
Of course, you don't always want to calculate the mean of 4 tests. You might want to calculate the mean of 10 tests or only 2...
We can fix this problem by adding the argument and variable 'amount_of_tests'.
* Start a new line on line 3. Set the amount_of_tests argument by asking the student how many tests they have made.
* Change the 4 in line 4 to the new argument amount_of_tests.
* Lastly, change the 4 in line 6 to amount_of_tests
Try out your new program. Does it work?
### Exercise 3
Did you want to make your program even better? Great! In the previous program you could only calculate the mean grade of 1 subject, but it would be better if you could calculate the mean grade for all subjects you want!
We won't tell you how to do it, but we will give you one tip: Start your code in line 1 with: define calculate_mean_grade with subject.
example_code: |
```
# Use your own code from the previous adventure.
```
clear_command:
name: '{clear}'
default_save_name: clear_command
description: clear command
levels:
4:
story_text: |
Time for a new command! With `{clear}` you can clear all the text form your output screen. This way you can prevent your screen getting too full of text.
Beware! If you are using a `{clear}` command, you might need to use a `{sleep}` above it. Otherwise Hedy will clear your screen without giving you the time to read as you can see in the example!
example_code: |
```
{print} '3'
{clear}
{print} '2'
{clear}
{print} '1'
{clear}
{print} 'wait for it...'
{sleep} 3
{clear}
{print} 'SURPRISE!'
```
debugging:
name: debugging
default_save_name: debugging
description: debugging adventure
levels:
1:
story_text: |-
Welcome to a debugging adventure. Debugging a code means getting rid of mistakes in the code.
That means that in these debugging adventures, we will show you code that does not work yet.
You will have to figure out what's wrong and correct the mistakes.
### Exercise
Debug this code. Good luck!
example_code: |
**Warning! This code needs to be debugged!**
```
{print} I love programming
Do you love programming too?
{echo}
{print} What are your hobbies?
{echo} Your hobbies are
```
2:
story_text: |-
Welcome to a debugging adventure. Debugging a code means getting rid of mistakes in the code.
That means that in these debugging adventures, we will give you a code that does not work yet.
You will have to figure out what's wrong and correct the mistakes.
### Exercise
Debug this code. Good luck!
example_code: |
**Warning! This code needs to be debugged!**
```
destination {ask} Where are you going on holidays?
{print} The flight to dstination leaves at 3 pm.
{ask} Did you check in your luggage yet?
{echo}
{print} Let me print your boarding pass for you.
{sleep}
Here you go! Have a nice trip!
```
3:
story_text: |-
Welcome to a debugging adventure. Debugging a code means getting rid of mistakes in the code.
That means that in these debugging adventures, we will give you a code that does not work yet.
You will have to figure out what's wrong and correct the mistakes.
### Exercise
Debug this code. Good luck!
example_code: |
**Warning! This code needs to be debugged!**
```
movie_choices {is} dracula, fast and furious, home alone, barbie
chosen_movie {is} movies {at} {random}
{print} Tonight we will watch chosen _movies
like {ask} Do you like that movie?
{print} Tomorrow we will watch something else.
{add} chosen_movie {to} movie_choices
{print} Tomorrow we will watch tomorrows_movie
tomorrows_movie {is} movie_choices {at} {random}
I'll go get the popcorn! {print}
```
4:
story_text: |-
### Exercise
Debug this code. Good luck!
example_code: |
**Warning! This code needs to be debugged!**
```
{print} 'Welcome to the online library!
{ask} What genre of books do you like?
{print} You like genre
author {is} {ask} 'Who's your favorite author?'
{print} 'author is your favorite author'
{print} Hmmm... i think you should try... books {at} {random}
```
5:
story_text: |-
### Exercise
Debug this code. Good luck!
example_code: |
**Warning! This code needs to be debugged!**
```
{print} Welcome to Swimming Pool Hedy!
class {is} {ask} 'Are you here to join a class today?'
{if} class yes
{print} 'Great! You're joining a class!
{print} {else} 'You will not be joining a class'
discount {is} 'Do you have a discount code?'
{if} discount {is} yes
discount_answer {is} {ask} 'What's your discount code?'
discount_codes = Senior4231, Student8786, NewMember6709
{if} discount_answer {is} {in} discount_cods
{print} 'That will be $3,50'
'That will be $5,50'
{print} 'Have a nice swim!'
```
6:
story_text: |-
### Exercise
Debug this code. Good luck!
example_code: |
**Warning! This code needs to be debugged!**
```
{print} 'Vending machine'
chosen_product = {ask} 'Please select a product'
1_dollar_products = coke orange juice water
2_dollar_products = chocolate, cookie, museli bar
3dollar_prodcuts = potato chips, beef jerky, banana bread
{if} chosen {is} {in} 1_dollar_products
price = 1
{if} chosen_product {is} 2_dollar_products
price = 2
{else} chosen_product {in} 3_dollar_products
price = 3
amount_of_products = '{ask} How many of ' chosen_product would you like to have?'
total = price + amount_of_product
{print} 'That will be $' price 'please'
```
7:
story_text: |-
### Exercise
Surprise! This program looks more like an output than a code. And yet, we don't want you to just add `{print}` commands in front of each line.
Fix this program to turn it into the nursery rhyme 'Brother John (Frère Jaques)' by using the {repeat} command of course!
example_code: |
**Warning! This code needs to be debugged!**
```
Are you sleeping?
Brother John!
Morning bells are ringing!
Ding, dang, dong!
```
8:
story_text: |-
### Exercise
Debug this code. Good luck!
example_code: |
**Warning! This code needs to be debugged!**
```
{print} 'Welcome to Manicures and Pedicures by Hedy'
bodypart = {ask} 'Are you getting your fingernails or toenails done today? Or both?'
{if} bodyparts {is} both
{print} That will be $25'
price = 25
{else}
{print} That will be $18'
price = 18
color = {ask} What color would you like?
sparkles = {ask} 'Would you like some sparkles with that?'
{if} sparkles {is} yes
{print} 'We charge $3 extra for that'
price = price + 3
{else} {print} 'No sparkles' {print} 'So no extra charge'
{sleep} 5
{print} 'All done! That will be $' price ' please!'
{print} 'Thank you! Byebye!'
```
9:
story_text: |-
### Exercise
Debug this code. Good luck!
example_code: |
**Warning! This code needs to be debugged!**
```
{print} 'Welcome to our sandwich shop'
amount 'How many sandwiches would you like to buy?'
{repeat} amount {times}
{ask} {is} {ask} 'What kind or bread would you like your sandwich to be?'
types_of_bread {is} white, wheat, rye, garlic, gluten free
{if} chosen_bread in types_of_bread
{print} 'Lovely!'