diff --git a/content/adventures/ar.yaml b/content/adventures/ar.yaml index d83c4a9cdb9..b03131688b3 100644 --- a/content/adventures/ar.yaml +++ b/content/adventures/ar.yaml @@ -132,126 +132,6 @@ adventures: ### تمرين 2 ارجع إلى برامجك المحفوظة، واختر برنامج قصتك من المستوى 5. والآن اكتب نهاية جيدة ونهاية سيئة بطول ثلاثة أسطر على الأقل! - 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. - 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: - 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!' - add_remove_command: - name: '{add} {to} & {remove} {from}' - 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. - 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. - and_or_command: - description: introducing and or - ask_command: - description: Introduction ask command - levels: - 1: - 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. calculator: name: آلة حاسبة default_save_name: آلة حاسبة @@ -280,67 +160,9 @@ adventures: story_text_3: | يمكنك أيضاً ترك الكومبيوتر يختار لك أرقام عشوائياً بإستخدام الأمر بشكل عشوائي. يوضح هذا المثال كيفية إختيار رقم من الجداول للتدريب، و بذلك تحصل على أرقام مختلفة دائماً لتتمرن على ناتج الضرب: - 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: | لقد تعلمت صنع آلة حاسبة في المستويات السابقة. يمكنك الآن أن تطور البرنامج وتحوله للعبة حسابية. هكذا ... - example_code: | - ``` - score = 0 - {repeat} 10 {times} - numbers = 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 - number1 = numbers {at} {random} - number2 = numbers {at} {random} - correct_answer = number1 * number2 - {print} 'What is ' number1 ' times ' number2 '?' - answer = {ask} 'Type your answer here...' - {print} 'Your answer is' answer - {if} answer {is} correct_answer - score = score + 1 - {print} 'Great job! Your score is... ' score ' out of 10!' - ``` - 11: - example_code: | - ``` - number = 10 - {for} i {in} {range} 1 to 10 - {print} i * number - ``` - 12: - story_text: | - Now you can make a calculator that works for decimal numbers. - example_code: | - ``` - number1 = {ask} 'What is the first number?' - number2 = {ask} 'What is the second number?' - answer = number1 + number2 - {print} number1 ' plus ' number2 ' is ' answer - 14: - 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 clear_command: description: clear command debugging: @@ -522,248 +344,6 @@ adventures: الأنشطة = يطير طائرة ورقية، يذهب للسباحة، يذهب للمشي في الطبيعة، يستلقي للحصول على لون برونزي من الشمس {for} الاسم {is} الأسماء {print} في الشاطئ الاسم يحب القيام ب نشاط {at} {random} - 11: - story_text: |- - ### Exercise - Debug this calender program. The output of this program is supposed to look like a list of dates. - For example: - - ``` - Hedy calender - Here are all the days of November - November 1 - November 2 - November 3 - ``` - And so on. - - Mind that you have to test your code extra carefully for the month February, because the amount of days in this month changes in leap years. - example_code: | - **Warning! This code needs to be debugged!** - ``` - print 'Hedy calender' - months_with_31 days = January, March, May, July, September, October, December - months_with_30_days = April, June, August, November - month = ask 'Which month would you like to see?' - if month in months_with_31_days - days = 31 - if month in months_with30_days - days = 30 - if month = February - leap_years = 2020, 2024, 2028, 2036, 2040, 2044, 2028 - year = ask 'What year is it?' - if year in leap_years - days = 29 - else - days = 28 - - print 'Here are all the days of ' moth - for i in range 1 to days - print month i - ``` - 12: - example_code: | - **Warning! This code needs to be debugged!** - ``` - define greet - greetings = 'Hello', 'Hi there', 'Goodevening' - print greetings at random - - define take_order - food = ask 'What would you like to eat?' - print 'One food' - drink = 'What would you like to drink?' - print 'One ' drink - more = ask 'Would you like anything else?' - if more is 'no' - print 'Alright' - else - print 'And ' more - print 'Thank you' - - print 'Welcome to our restaurant' - people = ask 'How many people are in your party tonight?' - for i in range 0 to people - call greet_costumer - ``` - 13: - example_code: | - **Warning! This code needs to be debugged!** - ``` - defin movie_recommendation with name - action_movies == 'Die Hard', 'Fast and Furious', 'Inglorious Bastards' - romance_movies = 'Love Actually', 'The Notebook', 'Titanic' - comedy_movies = 'Mr Bean' 'Barbie''Deadpool' - kids_movies = 'Minions', 'Paddington', 'Encanto' - if name is 'Camila' or name is 'Manuel' - recommended_movie = kids_movie at random - if name is 'Pedro' or 'Gabriella' - mood = ask 'What you in the mood for?' - if mood is 'action' - recommended_movie = comedy_movies at random - if mood is 'romance' - recommended_movie = romance_movies - if mood is 'comedy' - recommended_movie = comedy_movies at random - - print 'I would recommend ' recommended_movie ' for ' name - - name = ask 'Who is watching?' - recommendation = ask 'Would you like a recommendation?' - if recommendaion is 'yes' - print movie_recommendation with name - else - print 'No problem!' - ``` - 14: - example_code: | - **Warning! This code needs to be debugged!** - ``` - define calculate_heartbeat - print 'Press your fingertips gently against the side of your neck' - print '(just under your jawline)' - print 'Count the number of beats you feel for 15 seconds' - beats == ask 'How many beats do you feel in 15 seconds?' - heartbeat = beats*4 - print 'Your heartbeat is ' heartbeat - if heartbeat >= 60 or heartbeat <= 100 - print 'Your heartbeat seems fine' - else - if heartbeat > 60 - print 'Your heartbeat seems to be too low' - if heartbeat < 100 - print 'Your heartbeat seems to be too high' - print 'You might want to contact a medical professional' - - measure_heartbeat = ask 'Would you like to measure your heartbeat?' - if measure_heartbeat = 'yes' - call measure_heartbeat - else - 'no problem' - ``` - - print '(just under your jawline)' - print 'Count the number of beats you feel for 15 seconds' - beats == ask 'How many beats do you feel in 15 seconds?' - heartbeat = beats*4 - print 'Your heartbeat is ' heartbeat - if heartbeat >= 60 or heartbeat <= 100 - print 'Your heartbeat seems fine' - else - if heartbeat > 60 - print 'Your heartbeat seems to be too low' - if heartbeat < 100 - print 'Your heartbeat seems to be too high' - print 'You might want to contact a medical professional' - - measure_heartbeat = ask 'Would you like to measure your heartbeat?' - if measure_heartbeat = 'yes' - call measure_heartbeat - else - 'no problem' - 15: - example_code: | - **Warning! This code needs to be debugged!** - ``` - names = 'Tanya', 'Romy', 'Kayla', 'Aldrin', 'Ali' - verbs='walking', 'skipping', 'cycling', 'driving', 'running' - locations = 'on a mountaintop', 'in the supermarket', 'to the swimming pool' - hiding_spots = 'behind a tree', under a table', in a box' - sounds = 'a trumpet', 'a car crash', 'thunder' - causes_of_noise = 'a television', 'a kid with firecrackers', 'a magic elephant', 'a dream' - - chosen_ name = names at random - chosen_verb = verbs at random - chosen_location = 'locations at random' - chosen_sounds = noises at random - chosen_spot = hiding_spots random - chosen_causes = causes_of_noise at random - - print chosen_name ' was ' chosen_verb ' ' chosen_location - print 'when they suddenly heard a sound like ' sounds at random - print chosen_name ' looked around, but they couldn't discover where the noise came from' - print chosen_name ' hid ' chosen_spot' - print 'They tried to look around, but couldn't see anything from there' - hidden = 'yes' - while hidden = 'yes' - print chosen_name 'still didn't see anything' - answer = ask 'does ' chosen_name ' move from their hiding spot?' - if answer = 'yes' - hidden == 'no' - print 'chosen_name moved from' chosen_spot - print 'And then they saw it was just' chosen_cause - print chosen_name 'laughed and went on with their day' - print The End - ``` - 16: - example_code: | - **Warning! This code needs to be debugged!** - ``` - country = ['The Netherlands', 'Poland', 'Turkey', 'Zimbabwe', 'Thailand', 'Brasil', 'Peru', 'Australia', 'India', 'Romania' ] - capitals = 'Amsterdam', 'Warshaw' 'Istanbul', 'Harare', 'Bangkok', 'Brasilia', 'Lima', 'Canberra', 'New Delhi', 'Bucharest' - score = 0 - for i in range 0 to 10 - answer = ask 'What's the capital of ' countries[i] - correct = capital[i] - if answer = correct - print 'Correct!' - score = score + 1 - else - print 'Wrong,' capitals[i] 'in the capital of' countries[i] - print 'You scored ' score ' out of 10' - - ``` - 17: - example_code: | - **Warning! This code needs to be debugged!** - ``` - define food_order - toppings = ask 'pepperoni, tuna, veggie or cheese?' - size = ask 'big, medium or small?' - number_of_pizza = ask 'How many these pizzas would you like?' - - print 'YOU ORDERED' - print number_of_pizzas ' size ' topping ' pizza' - - define drinks_order - drink = ask 'water, coke, icetea, lemonade or coffee?' - number_of_drinks = ask 'How many of these drinks would you like?' - - print 'YOU ORDERED' - print number_of_drinks ' ' drink - - 'Welcome to Hedy pizza' - more_food = ask 'Would you like to order a pizza?' - while more_food = 'yes' - return food_order - more_food = ask 'Would you like to order a pizza?' - more_drinks = ask 'Would you like to order some drinks?' - while more_drinks == 'yes' - call drink_order - more_drinks == ask 'Would you like to order more drinks?' - - - print 'Thanks for ordering!' - ``` - 18: - example_code: | - **Warning! This code needs to be debugged!** - ``` - animals = ['pig', 'dog', 'cow'] - sounds = ['oink', 'woof', 'moo'] - for i in range 1 to 3 - animal = animals[i] - sound = sounds[i] - print 'Old MacDonald had a farm' - print 'E I E I O!' - print 'and on that farm he had a ' animal - print 'E I E I O!' - print 'with a ' sound sound ' here' - print 'and a ' sound sound ' there' - print 'here a ' sound - print 'there a ' sound - print 'everywhere a ' sound sound - ``` default: name: المقدمة default_save_name: مقدمة @@ -968,30 +548,6 @@ adventures: {if} رمية {is} دودةالأرض النقاط = النقاط + 5 {else} النقاط = النقاط + رمية {print} 'نقاطك الآن ' النقاط' نقطة' ``` - example_code_2: | - Did you manage to calculate the score for 8 dice? That required a lot of cutting and pasting, right? We are going to make that easier in level 7! - 7: - story_text: | - You can also make a die again in level 5. With the `{repeat}` code you can easily roll a whole hand of dice. - Try to finish the sample code! The dashes should contain multiple commands and characters. - - But maybe you want to make a completely different die. Of course you can! - example_code: | - ``` - choices = 1, 2, 3, 4, 5, earthworm - {repeat} _ _ {print} _ _ _ - ``` - 10: - story_text: | - Is everybody taking too long throwing the dice? In this level you can let Hedy throw all the dice at once! - example_code: | - ``` - players = Ann, John, Jesse - choices = 1, 2, 3, 4, 5, 6 - {for} player {in} players - {print} player ' throws ' choices {at} {random} - {sleep} - ``` dishes: name: غسل الأطباق؟ description: Use the computer to see who does the dishes (Start at level 2) @@ -1068,41 +624,6 @@ adventures: {remove} غسيل_الأطباق {from} الأشخاص غسيل_الأطباق = الأشخاص {at} {random} ``` - 7: - story_text: | - With the `{repeat}` you can repeat pieces of code. You can use this to calculate who will be washing dishes for the entire week. - example_code: | - ``` - people = mom, dad, Emma, Sophie - {repeat} _ _ {print} 'the dishwasher is' _ - ``` - 10: - story_text: | - In this level you could make an even better dish washing shedule. - elif_command: - description: elif - levels: - 17: - example_code: | - ``` - prices = ['1 million dollars', 'an apple pie', 'nothing'] - your_price = prices[{random}] - {print} 'You win ' your_price - {if} your_price == '1 million dollars' : - {print} 'Yeah! You are rich!' - {elif} your_price == 'an apple pie' : - {print} 'Lovely, an apple pie!' - {else}: - {print} 'Better luck next time..' - ``` - for_command: - description: for command - levels: - 11: - story_text: |- - In this level, we add a new form of the `{for}`. In earlier levels, we used `{for}` with a list, but we can also use `{for}` with numbers. - We do that by adding a variable name, followed by `{in}` `{range}`. We then write the number to start at, `{to}` and the number to end at. - Try the example to see what happens! In this level again, you will need to use indentations in lines below the `{for}` statements. fortune: name: العراف default_save_name: العراف @@ -1178,123 +699,6 @@ adventures: النتيجة = النتيجة * كرةقدم {print} 'أنت ' النتيجة ' بالمائة ذكي.' ``` - 7: - story_text: | - In this level you can use the `{repeat}` command to make your machine tell multiple fortunes at once. - example_code: | - ``` - {print} 'Im Hedy the fortune teller!' - {print} 'You can {ask} 3 questions!' - {repeat} 3 {times} question = {ask} 'What do you want to know?' - answer = yes, no, maybe - {repeat} 3 {times} {print} 'My crystal ball says... ' answer {at} {random} - ``` - - ### Exercise - As you can see, the questions aren't printed in this example. That's because the variable `question` was changed 3 times. - Every time the player fills in the new answer, Hedy overwrites the previous one, so the first answer the player gave is forgotten. - This means you can't print all the questions this way. - - By using 3 different variables instead of 1 (for example `question1` , `question2` and `question3`), you could solve the problem and print the questions. - This does mean that you can only use `{repeat}` for the answers, and you will have to ask and print all the questions separately. - Can you do it? - - In the upcoming levels the layout of {repeat} command will change, which enables you to repeat multiple lines at once. - 8: - story_text: | - In the previous levels you've learned how to use repeat to make the fortune teller answer 3 questions in a row, but we had a problem with printing the questions. - Now that problem is solved, because of the new way of using the repeat command. - In the next example you can have your fortune teller {ask} 3 questions and also print them! - example_code: | - ``` - {print} 'I am Hedy the fortune teller!' - {print} 'You can {ask} me 3 questions.' - answers = yes, no, maybe - {repeat} 3 {times} - question = {ask} 'What do you want to know?' - {print} question - {sleep} - {print} 'My crystal ball says...' answers {at} {random} - ``` - 10: - story_text: | - In this level you'll learn how to program the game MASH (mansion, apartement, shack, house). In this game you can predict for all the players at once, what their future will look like. - example_code: | - ``` - houses = mansion, apartment, shack, house - loves = nobody, a royal, their neighbour, their true love - pets = dog, cat, elephant - names = Jenna, Ryan, Jim - {for} name {in} names - {print} name ' lives in a ' houses {at} {random} - {print} name ' will marry ' loves {at} {random} - {print} name ' will get a ' pets {at} {random} ' as their pet.' - {sleep} - ``` - 12: - story_text: | - In this level you can make your fortunes multiple words. Like in this example below: - example_code: | - ``` - fortunes = 'you will be rich', 'you will fall in love', 'you will slip on a banana peel' - {print} 'I will take a look in my crystall ball for your future.' - {print} 'I see... I see...' - {sleep} - {print} fortunes {at} {random} - ``` - functions: - levels: - 12: - example_code: | - ``` - sides = 'left', 'right' - limbs = 'hand', 'foot' - colors = 'red', 'blue', 'green', 'yellow' - - {define} turn - chosen_side = sides {at} {random} - chosen_limb = limbs _ - chosen_color = colors _ - {print} chosen_side ' ' chosen_limb ' on ' chosen_color - - {print} 'Lets play a game of Twister!' - {for} i {in} {range} 1 to _ - {call} turn - {sleep} 2 - ``` - 13: - story_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. - - For example in this code we've programmed the first verse of the song 'My Bonnie is over the ocean'. - In this example code the argument `place` is used. Place is a variable that is only used in the function, so an argument. - To use `place` we have programmed the line `define song with place`. - When the function is called, computer will replace the argument `place`, with the piece of text after `call song with`. - - ### Exercise - The next verse of this song goes: - - Last night as I lay on my pillow - Last night as I lay on my bed - Last night as I lay on my pillow - I dreamed that my Bonnie is dead - - Can you program this verse in the same way as the example? - 14: - example_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?' - - new_price = _ calculate_new_price {with} old_price, _ - {print} 'The new price is ' new_price ' dollar' - ``` haunted: name: بيت الأشباح default_save_name: بيت الأشباح @@ -1365,102 +769,6 @@ adventures: هل يمكنك العثور على الكلمات الأربع المفقودة لإكمال الكود؟ example_code: "```\n{print} 'اهرب من بيت الأشباح !'\n{print} 'أمامك 3 أبواب ...'\nالأبواب {is} ۱ ، ۲، ۳ \nالوحوش {is} مستذئب، مومياء، مصاص دماء، زومبي\n الباب_الذي_إخترته {is} {ask} 'أي باب تختار؟'\n{print} 'انت إخترت باب ..' الباب_الذي_إخترته\n{sleep}\nالباب_الصحيح {is} الأبواب {at} {random}\n____ {print} 'رائعة! لقد نجوت!'\n{else} {print} 'أوه لا! لقد تم أكلك من قبل ... \"الوحوش {at} {random}\n```\n" - 9: - story_text: | - In this level you can use nesting, which allows you to make the haunted house even more interactive! - example_code: | - ``` - {print} 'Escape from the Haunted House!' - player = alive - doors = 1, 2, 3 - monsters = zombie, vampire, giant spider - {repeat} 3 {times} - {if} player {is} alive - correct_door {is} doors {at} {random} - {print} 'There are 3 doors in front of you...' - chosen_door = {ask} 'Which door do you choose?' - {if} chosen_door {is} correct_door - {print} 'No monsters here!' - {else} - {print} 'You are eaten by a ' monsters {at} {random} - player = dead - {else} - {print} 'GAME OVER' - {if} player {is} alive - {print} 'Great! You survived!' - ``` - ### Exercise - Now it's very hard to win this game, can you make it easier to win? - For example by only having 1 wrong door and 2 correct doors instead of 1 correct door en 2 wrong ones? - 11: - story_text: | - In this level we've changed the repeat command and we've added a line to our haunted house that tells the player in which room they are. - example_code: | - ``` - {print} 'Escape from the Haunted House!' - player {is} alive - doors = 1, 2, 3 - monsters = zombie, vampire, giant spider - {for} i {in} {range} 1 {to} 3 - {if} player {is} alive - correct_door = doors {at} {random} - {print} 'Room ' i - {print} 'There are 3 doors in front of you...' - chosendoor = {ask} 'Which door do you choose?' - {if} chosendoor {is} correct_door - {print} 'No monsters here!' - {else} - {print} 'You are eaten by a ' monsters {at} {random} - player = dead - {else} - {print} 'GAME OVER' - {if} player {is} alive - {print} 'Great! You survived!' - ``` - if_command: - description: Introducing the if command - levels: - 9: - story_text: | - In this level you can also put an {if} command inside another {if} command. - in_command: - description: Introducing the in command - levels: - 5: - example_code_2: | - ``` - animals is dog, cow, sheep - answer is ask 'What is your favorite animal?' - _ answer _ animals _ 'Mine too!' - _ _ 'My favorite animals are dogs, cows and sheep' - ``` - is_command: - description: introducing is command - levels: - 2: - story_text_2: | - ### Exercise - Time to make your own variables! - In the example code we made an example of the variable `favorite_animal`. In line 1 the variable is set, and in line 2 we haved used the variable in a print command. - Firstly, finish our example by filling in your favorite animal on the blank. Then make at least 3 of these codes yourself. Pick a variable, and set the variable with the {is} command. Then use it with a {print} command, just like we did. - 14: - example_code: | - ``` - age = {ask} 'How old are you?' - {if} age > 12 - {print} 'You are older than I am!' - ``` - example_code_3: | - ``` - name = {ask} 'What is your name?' - {if} name != 'Hedy' - {print} 'You are not Hedy' - ``` - - {if} age < 13 - {print} 'You are younger than me!' - {else} - {print} 'You are older than me!' language: name: لغة default_save_name: لغة @@ -1479,24 +787,6 @@ adventures: {if} ضفدع {is} غرينويل {print} 'ممتاز!' {else} {print} 'لا, الضفدع هو غرينويل' ``` - maths: - levels: - 6: - example_code: | - ``` - {print} '5 plus 5 is ' 5 + 5 - {print} '5 minus 5 is ' 5 - 5 - {print} '5 times 5 is ' 5 * 5 - ``` - 12: - example_code_2: | - ``` - a = 'Hello ' - b = 'world!' - {print} a + b - ``` - - {print} 2.5 + 2.5 music: name: موسيقى default_save_name: موسيقى @@ -1514,8 +804,6 @@ adventures: ### تمرين حاول على سبيل المثال هذا كود ثم العب به! هل يمكنك إنشاء اللحن الخاص بك؟ في المستوى التالي ستتعلم كيفية تشغيل بعض الأغاني الموجودة. - 6: - story_text: "Instead of playing notes, you can also play numbers now. Simply type `{play} 1` for the lowest note, `{play} 70` for the highest note, or anything in between.\n\n### Exercise\n This calls for musical maths! Try out the example code a couple of times with different starting numbers. \nThen, see if you can compose a song using the numbers.\n" parrot: name: الببغاء default_save_name: الببغاء @@ -1594,103 +882,10 @@ adventures: _ الكلمة_التي_قالها{is} الكلمة_الجديدة {print} '🧒 هيدي، عمل رائع! 🍪' __ {print} '🧒 لا, هيدي! قل ' الكلمة_الجديدة ``` - piggybank: - name: البنك الإلكتروني - default_save_name: البنك الإلكتروني - description: احسب مصروفك ومدخراتك! - levels: - 12: - story_text: | - In this adventure you learn how to make a digital piggy bank, to calculate how much money you have and how long you need to save up to buy what you want! - example_code: | - ``` - {print} 'The digital piggy bank' - wish = {ask} 'What would you like to buy?' - price = {ask} 'How much does that cost?' - saved = {ask} 'How much money have you saved already?' - allowance = {ask} 'How much pocket money do you get per week?' - to_save = price - saved - weeks = to_save / allowance - {print} 'You can buy a ' wish ' in ' weeks ' weeks.' - 14: - example_code: | - ``` - _ calculate_budget with wish, money, allowance - to_save = wish - money - weeks = to_save / allowance - {if} wish _ money - {print} 'You need to save up some more!' - {print} 'Youll need ' weeks ' more weeks.' - {else} - {print} 'Great! You have enough' - {print} 'Lets go shopping!' - - money = {ask} 'How much money have you saved?' - wish = {ask} 'How much money do you need?' - allowance = {ask} 'How much pocket money do you get each week?' - - {call} calculate_budget with _, _, _ - ``` - pressit: - levels: - 9: - story_text: | - Now that you know how to combine statements, you can create a touch type tool with `{pressed}`. - - ### Exercise - Finish the code. Each time a random letter should be chosen, which you have to press. You get a point for a correct press, and and two points deduction for a wrong press. - **(extra)** Clear the screen after each letter, and show the user how many points they have scored. - print_command: - levels: - 18: - example_code_2: | - ``` - temperature = 25 - {print}('It is ', temperature, ' degrees outside') - ``` - - {print}('My name is ', name) quizmaster: name: عريف المسابقات default_save_name: عريف المسابقات description: اصنع مسابقة جديدة! - random_command: - levels: - 16: - story_text: |- - We are going to make lists the Python way, with square brackets around the lists! We also keep the quotation marks around each item like we have learned in previous levels. - We use square brackets to point out a place in a list. For example: `friends[1]` is the first name on the list of friends, as you can see in the first part of the example code. The second part of the example code shows you that we can also match 2 lists using the variable i. - repeat_command: - description: repeat command - levels: - 7: - story_text: | - ## Repeat! Repeat! Repeat! - Level 7 adds the `{repeat}` command. `{repeat}` can be used to execute one line of code multiple times. Like this: - - ### Exercise - Play around with the repeat command. Can you make the happy birthday song in only 3 lines of code instead of 4 now? - 9: - story_text: | - Great job! You've reached another new level! In the previous level you've learned to use multiple lines of code in an {if} or {repeat} command. But you can't yet combine the two... - Good news! In this level you will be allowed to put an {if} inside an {if}, or inside a {repeat} command. Putting a block of code inside another block of code is called nesting. ``` Putting a block of code inside another block of code is called nesting. - example_code: | - ``` - answer = {ask} 'Are you ready to learn something new?' - {if} answer {is} yes - {print} 'Great! You can learn to use the repeat command in the if command!' - {print} 'Hooray!' - {print} 'Hooray!' - {print} 'Hooray!' - {else} - {print} 'Maybe you should practice some more in the previous level' - repeat_command_2: - description: repeat command 2 - levels: - 7: - story_text_2: | - Another interesting thing you can so with the `{repeat}` command is using variables to set the amount of times something should be repeated. In the example code you can see that we first ask the person how old they are. - Then, in line 3, the question is repeated 'age' times. So we have used the variable 'age' with the `{repeat}` command. restaurant: name: المطعم default_save_name: المطعم @@ -1806,123 +1001,6 @@ adventures: {print} 'سيكون ثمنه ' المبلغ ' دولارات، من فضلك' {print} 'شكراً لك، إستمتع بوجبتك!' ``` - 7: - story_text: | - In this level you've learned how to use the {repeat} command to repeat a line of code a certain amount of times. - You can use that in your restaurant to {ask} multiple people what they'd like to eat. Like this: - - ``` - {print} 'Welcome to Hedys restaurant!' - people = {ask} 'How many people are joining us today?' - {repeat} people times food = {ask} 'What would you like to eat?' - {print} 'Thanks for your order! Its coming right up!' - ``` - example_code: | - ``` - {print} 'Welcome to Hedys restaurant!' - people = {ask} 'How many people are joining us today?' - {repeat} people times food = {ask} 'What would you like to eat?' - {print} 'Thanks for your order! Its coming right up!' - ``` - 9: - story_text: | - In this level you can use nesting to make your restaurant more realistic and more fun! - For example you would {ask} for sauce {if} somebody orders fries, but you wouldn't {if} someone orders pizza! - Check out the example, and try this at your own virtual restaurant! - example_code: | - ``` - {print} 'Welcome to Hedys restaurant!' - people = {ask} 'How many people will be joining us today?' - {print} 'Great!' - price = 0 - {repeat} people {times} - food = {ask} 'What would you like to order?' - {print} food - {if} food {is} fries - price = price + 3 - sauce = {ask} 'What kind of sauce would you like with your fries?' - {if} sauce {is} no - {print} 'no sauce' - {else} - price = price + 1 - {print} 'with ' sauce - {if} food {is} pizza - price = price + 4 - {print} 'That will be ' price ' dollar' - {print} 'Enjoy your meal!' - ``` - 10: - story_text: | - In this level you'll learn how to easily {ask} your guests' orders in a short code. - example_code: | - ``` - courses = appetizer, main course, dessert - {for} course {in} courses - food = {ask} 'What would you like to eat as your ' course '?' - {print} food ' will be your ' course - ``` - story_text_2: | - Of course, you could also order for multiple people! - example_code_2: | - ``` - courses = appetizer, main course, dessert - names = Timon, Onno - {for} name {in} names - {for} course {in} courses - food = {ask} name ', what would you like to eat as your ' course '?' - {print} name ' orders ' food ' as their ' course - ``` - 11: - story_text: | - We can use the `{for} i {in} {range} 1 {to} 5` to {print} the orders from multiple customers in an orderly manner. - example_code: | - ``` - {print} 'Welcome to Restaurant Hedy!' - people = {ask} 'For how many people would you like to order?' - {for} i {in} {range} 1 {to} people - {print} 'Order number ' i - food = {ask} 'What would you like to eat?' - {print} food - {if} food {is} fries - sauce = {ask} 'What kind of sauce would you like with that?' - {print} sauce - drinks = {ask} 'What would you like to drink?' - {print} drinks - price = 4 * people - {print} 'That will be ' price ' dollars, please!' - ``` - 12: - story_text: | - From this level on you can use decimal numbers to make you menu more realistic. - example_code: | - ``` - price = 0 - food = {ask} 'What would you like to order?' - drink = {ask} 'What would you like to drink?' - {if} food {is} 'hamburger' - price = price + 6.50 - {if} food {is} 'pizza' - price = price + 5.75 - {if} drink {is} 'water' - price = price + 1.20 - {if} drink {is} 'soda' - price = price + 2.35 - {print} 'That will be ' price ' dollar, please' - ``` - 13: - story_text: | - In this level we can use the new commands to upgrade our restaurant. - We use `{and}` to see {if} two things are both the case. - example_code: | - ``` - price = 10 - food = {ask} 'What would you like to eat?' - drinks = {ask} 'What would you like to drink?' - {if} food {is} 'sandwich' {and} drinks {is} 'juice' - {print} 'Thats our discount menu' - price = price - 3 - {print} 'That will be ' price ' dollars' - ``` rock: name: حجر، ورقة، مقص default_save_name: حجر ورقة مقص @@ -1994,122 +1072,9 @@ adventures: ``` املأ الكود الصحيح في الفراغات لترى {if} إنه تعادل. - 9: - story_text: | - In this level you can program the whole rock, paper, scissors game by nesting the {if}-commands. Can you finish the code? - example_code: | - ``` - choices = rock, paper, scisscors - your_choice = {ask} 'What do you choose?' - {print} 'You choose ' your_choice - computer_choice = choices {at} {random} - {print} 'The computer chooses ' computer_choice - {if} computer_choice {is} your_choice - {print} 'Tie' - {if} computer_choice {is} 'rock' - {if} your_choice {is} 'paper' - {print} 'You win!' - {if} your_choice {is} 'scissors' - {print} 'You lose!' - ``` - 10: - story_text: | - Feeling too lazy to play the game yourself? Let Hedy play it for you! - example_code: | - ``` - choices = rock, paper, scissors - players = Marleen, Michael - {for} player {in} players - {print} player ' chooses ' choices {at} {random} - ``` - 13: - story_text: | - With the `{and}` command you can shorten your rock, paper, scissors code! Check out the example code below and try to finish it. - example_code: | - ``` - options = 'rock', 'paper', 'scissors' - your_choice = {ask} 'What do you choose?' - computer_choice = options {at} {random} - {print} 'You choose ' your_choice - {print} 'The computer chooses ' computer_choice - {if} computer_choice {is} your_choice - {print} 'Tie' - {if} computer_choice {is} 'rock' {and} your_choice {is} 'paper' - {print} 'You win!' - {if} computer_choice {is} 'rock' {and} your_choice {is} 'scissors' - {print} 'The computer wins!' - ``` - 15: - example_code: | - ``` - won = 'no' - options = 'rock', 'paper', 'scissors' - {while} won == 'no' - your_choice = {ask} 'What do you choose?' - computer_choice = options {at} {random} - {print} 'you chose ' your_choice - {print} 'the computer chose ' computer_choice - {if} computer_choice == your_choice - {print} 'Tie!' - {if} computer_choice == 'rock' {and} your_choice == 'scissors' - {print} 'You lose!' - {if} computer_choice == 'rock' {and} your_choice == 'paper' - {print} 'You win!' - won = 'yes' - rock_2: - levels: - 2: - story_text: | - Now that you have learned how to use the `{ask} command, you can make your rock, paper, scissors code interavtive too! - - ### Exercise - Make the rock, paper, scissors code interactive by adding the `{ask}` command and a question to your rock, paper, scissors code. - example_code: | - ``` - choice is _ - {print} I choose choice - ``` secret: name: العميل السري default_save_name: العميل السري - levels: - 12: - story_text: | - In this adventure you can create your own super spy code. Encode a message that only the right agent can decipher. - If the enemy tries to crack the code, they will get some false info to waste their time. - example_code: | - ``` - name {is} {ask} 'What is your name?' - {if} name {is} '_' - a {is} 'Go to the airport ' - {else} - a {is} 'Go to the trainstation ' - password {is} {ask} 'What is the password?' - {if} password {is} _ - b {is} 'tomorrow at 02.00' - {else} - b {is} 'today at 10.00' - {print} _ _ _ - ``` - 13: - story_text: | - The code you made in the previous level can be made a lot easier in this one with the `{and}` command. - example_code: | - ``` - name = {ask} 'What is your name?' - password = {ask} 'What is your password?' - {if} name {is} 'Agent007' _ password {is} 'TOPSECRET' - {print} 'Go to the airport at 02.00' - {else} - {print} 'Go to the trainstation at 10.00' - ``` - sleep_command: - description: introducing sleep command - levels: - 2: - story_text: | - ## The sleep command - Another new command in this level is `{sleep}`, which pauses your program for a second. If you type a number behind the {sleep} command, the program pauses for that amount of seconds. songs: name: غنّ أغنية! default_save_name: أغنية @@ -2155,149 +1120,6 @@ adventures: بيبي شارك يمكنك أن تصنع هذه الأغنية بعدد قليل من الأوامر البرمجية باستعمال `{repeat}`! هل يمكنك إكمال الكود؟ - example_code: | - ``` - {repeat} _ _ {print} 'Baby Shark tututudutudu' - {print} 'Baby Shark' - ``` - - After Baby Shark you can of course also program other songs. There are many songs with repetition. - 8: - story_text: | - In a previous level you've programmed the song 'Bottles of beer'. You made one verse and then had to copy the verses 99 times. In level 7 you can repeat the song 99 times, just by adding one simple line! - example_code: | - ``` - verse = 99 - {repeat} 99 {times} - {print} verse ' bottles of beer on the wall' - {print} verse ' bottles of beer' - {print} 'Take one down, pass it around' - verse = verse - 1 - {print} verse ' bottles of beer on the wall' - ``` - 10: - story_text: | - In this level you can easily make the childrens' song 'Five little monkeys'. Can you make the last chorus? - You can also make the whole baby shark song (including all the other sharks in the family) in only 6 lines! - Or you can make Old MacDonald with all the different animals. - example_code: | - ``` - monkeys = 5, 4, 3, 2 - {for} monkey {in} monkeys - {print} monkey ' little monkeys jumping on the bed' - {print} 'One fell off and bumped his head' - {print} 'Mama called the doctor and the doctor said' - {print} 'NO MORE MONKEYS JUMPING ON THE BED!' - ``` - ``` - sharks = baby, mommy, daddy, grandma, grandpa - {for} shark {in} sharks - {print} shark 'tututututudu' - {print} shark 'tututututudu' - {print} shark 'tututututudu' - {print} shark - ``` - ``` - animals = pig, dog, cow - {for} animal {in} animals - {if} animal {is} pig - sound = oink - {if} animal {is} dog - sound = woof - {if} animal {is} cow - sound = moo - {print} 'Old MacDonald had a farm' - {print} 'E I E I O!' - {print} 'and on that farm he had a ' animal - {print} 'E I E I O!' - {print} 'with a ' sound sound ' here' - {print} 'and a ' sound sound ' there' - {print} 'here a ' sound - {print} 'there a ' sound - {print} 'everywhere a ' sound sound - ``` - story_text_2: | - ### Exercise 2 - Print the song Five little moneys jumping on the bed. Look up the text if you don't remember. - - **(extra)** Print the song Old MacDonald had a farm, and make sure all animals make a different sound, using an `{if}`. - 11: - story_text: | - In this level you can use the `{for} i {in} {range}` command to make songs that use counting. - example_code: | - ``` - {for} i {in} {range} 5 {to} 1 - {print} i ' little monkeys jumping on the bed' - {print} 'One fell off and bumped his head' - {print} 'Mama called the doctor and the doctor said' - {if} i {is} 1 - {print} 'PUT THOSE MONKEYS RIGHT TO BED!' - {else} - {print} 'NO MORE MONKEYS JUMPING ON THE BED!' - ``` - 12: - story_text: | - In this song we can make it even easier to program '{if} you're happy and you know it, clap your hands'. Because we can put all of the actions in a variable, check it out: - example_code: | - ``` - actions = 'clap your hands', 'stomp your feet', 'shout Hurray!' - {for} action {in} actions - {for} i {in} {range} 1 {to} 2 - {print} '{if} youre happy and you know it' - {print} action - {print} '{if} youre happy and you know it and you really want to show it' - {print} '{if} youre happy and you know it' - {print} action - ``` - 16: - story_text: | - In this level, you can program a song like OldMacDonald even more quickly. You can connect the right animal to the right sound by simply putting them in the same place in the list. - The Drunken Sailor is also quickly made in this level. You only need 8 lines for the entire song, check it out! - - ### Exercise - Complete the Old MacDonald song by setting the variable `animal` to `animals[i]` and `sound` to `sounds[i]`. - - ``` - animals = ['pig', 'dog', 'cow'] - sounds = ['oink', 'woof', 'moo'] - {for} i {in} {range} 1 {to} 3 - animal = _ - sound = _ - {print} 'Old MacDonald had a farm' - {print} 'E I E I O!' - {print} 'and on that farm he had a ' animal - {print} 'E I E I O!' - {print} 'with a ' sound sound ' here' - {print} 'and a ' sound sound ' there' - {print} 'here a ' sound - {print} 'there a ' sound - {print} 'everywhere a ' sound sound - ``` - - ``` - lines = ['what shall we do with the drunken sailor', 'shave his belly with a rusty razor', 'put him in a long boat till hes sober'] - {for} line {in} lines - {for} i {in} {range} 1 {to} 3 - {print} line - {print} 'early in the morning' - {for} i {in} {range} 1 {to} 3 - {print} 'way hay and up she rises' - {print} 'early in the morning' - ``` - songs_2: - levels: - 12: - example_code: | - ``` - {define} twinkle - {print} 'Twinkle' - {print} '...' - - {call} twinkle - {print} 'Up above the world so high' - {print} 'Like a diamond in the sky' - {call} _ - ``` turtle: name: الرسام default_save_name: الرسام @@ -2387,13 +1209,6 @@ adventures: {turn} الزاوية {forward} ٢٥ ``` - example_code_2: | - ``` - direction {is} {ask} 'Do you want to go left, right, or straight ahead?' - if direction is left turn _ - if direction is right turn _ - forward 100 - ``` 6: story_text: | في هذا المستوى يمكننا استخدام الحساب لنرسم أشكالاً مختلفة. @@ -2430,91 +1245,3 @@ adventures: ``` story_text_2: "كذلك يمكننا تحسين البرنامج الذي يرسم الأشكال المختلفة. \nهل يمكنك حاسب كم يجب على الرسام أن يستدير هنا؟ أكمل الكود وسيصبح بإمكانك أن تطبع الشكل المضلع الذي تريد!\n" example_code_2: "```\nعدد_الزوايا = {ask} \"كم عدد الزوايا التي يجب أن أقوم بها؟\"\nالزاوية = ٣٦٠ / عدد_الزوايا \n{repeat} عدد_الزوايا {times} \n {turn} _\n {forward} _\n```\n" - 10: - story_text: | - In this level you can make the turtle draw a figure. - The turtle will travel the distances in the list, one by one, making bigger and bigger steps. - ### Exercise 1 - Add a 90 degree turn in the loop, so that a spiral is drawn. - Add at least 5 numbers to the list, so the spiral grows larger. - **(extra)** can you change the spiral into another shape? Experiment with numbers for the turn! - ### Exercise 2 - The spiral is drawn outwards, make it go inwards? - turtle_draw_it: - levels: - 9: - example_code: | - Hint for the nested squares: - ``` - colors = red, blue, orange, yellow, pink, purple, green, brown, black - distance = 120 - repeat 5 times - _ - ``` - Hint for the flags: - ``` - country = ask 'which country would you like to see the flag of?' - if country is 'the Netherlands' - color_1 = red - color_2 = white - color_3 = blue - ``` - 10: - example_code: | - Hint Nested Hexagon: - ``` - distances = 100, 80, 60, 40, 20 - {for} distance {in} distances - _ - ``` - - Hint Traffic Lights: - ``` - colors = red, yellow, green - {for} chosen_color {in} colors - color _ - {repeat} _ - ``` - 12: - story_text: | - ### Exercise - Recreate the drawings with the turtle! - Hint: Bracelet designing program. Firstly, define a function **for each shape** you want to use on the bacelet. Then, add the shapes to the bacelet like this: - - Bracelet Designing program - example_code: | - ``` - {define} draw_a_square - _ - - {color} white - {turn} -90 - {forward} 300 - {turn} 180 - - {for} i {in} {range} 1 {to} 5 - {color} gray - {forward} 100 - shape = {ask} 'What kind of shape would you like next on the bracelet?' - chosen_color = {ask} 'In which color?' - {color} chosen_color - {if} shape = 'square' - {call} draw_a_square - ``` - while_command: - description: while - years: - description: Countdown to the new year! - levels: - 11: - story_text: | - In this level you can use the `{for} i {in} {range}` command to countdown to the New Year. - - ### Exercise - Fill in the blanks and make the code work! - example_code: | - ``` - for _ in _ 10 to 1 - {print} i - {print} 'Happy New Year!' - ``` diff --git a/content/adventures/bg.yaml b/content/adventures/bg.yaml index a4e06d2d00c..a8482d97a9e 100644 --- a/content/adventures/bg.yaml +++ b/content/adventures/bg.yaml @@ -31,15 +31,6 @@ adventures: Сега името й може да бъде принтирано на което и да е място в изречението. За тази цел ти ще напишеш малко повече код. Ха! - 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: | Към историята, която пишеш можеш да добавиш нещо произволно и неочаквано, примерно чудовище, животно или някаква пречка. @@ -49,17 +40,6 @@ adventures: животни is бухал, сова, броненосец, глиган, катерица print Ненадейно тя дочува звук от животни at random ``` - story_text_2: | - The command `{add}` can also come in handy in your story. For example - example_code_2: | - {print} He hears a sound - animals {is} 🐿, 🦔, 🦇, 🦉 - animal {is} {ask} What do you think it is? - {add} animal {to_list} animals - {print} it was a animals {at} {random} - ``` - story_text_3: | - This is an example of the `{remove}` command in your story 4: example_code: | ``` @@ -108,526 +88,6 @@ adventures: repeat 5 times print 'Помоооощ!' print 'А, бе защо никой не ми помага?' ``` - 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! - 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. - 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: - 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!' - add_remove_command: - name: '{add} {to} & {remove} {from}' - 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. - 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. - and_or_command: - description: introducing and or - ask_command: - description: Introduction ask command - levels: - 1: - 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. - calculator: - levels: - 6: - story_text: | - Now that you can calculate, you can also create a program to practice maths calculations. You can make up the calculations yourself, for example: - example_code: | - ``` - correct_answer = 11 * 27 - answer = {ask} 'How much is 11 times 27?' - {if} answer {is} correct_answer {print} 'good job!' - {else} {print} 'Wrong! It was ' correct_answer - ``` - story_text_2: | - You can also let the computer do random calculations on its own using {random}. - example_code_2: | - ``` - tables = 4, 5, 6, 8 - numbers = 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 - table = tables {at} {random} - number = numbers {at} {random} - correct_answer = table * number - answer = {ask} 'how much is ' table ' times ' number '?' - {if} answer {is} correct_answer {print} 'okay' - {else} {print} 'mistake! it was ' correct_answer - ``` - 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`. - 11: - example_code: | - ``` - number = 10 - {for} i {in} {range} 1 to 10 - {print} i * number - ``` - 12: - story_text: | - Now you can make a calculator that works for decimal numbers. - example_code: | - ``` - number1 = {ask} 'What is the first number?' - number2 = {ask} 'What is the second number?' - answer = number1 + number2 - {print} number1 ' plus ' number2 ' is ' answer - 14: - 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 - clear_command: - description: clear command - debugging: - levels: - 3: - 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} - ``` - 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! - 8: - 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: - 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!' - {else} - 'I'm sorry we don't sell that' - topping {is} {ask} 'What kind of topping would you like?' - sauce {is} {ask} 'What kind of sauce would you like?' - {print} One chosen_bread with topping and sauce. - price = amount * 6 - {print} 'That will be 'price dollar' please' - ``` - - price = amount * 6 - {print} 'That will be 'price dollar' please' - 10: - example_code: | - **Warning! This code needs to be debugged!** - ``` - names = Muad Hasan Samira Noura - activities = fly a kite, go swimming, go hiking, catch tan in the sun - {for} name {is} names - {print} At the beach name loves to activity at random - ``` - 11: - story_text: |- - ### Exercise - Debug this calender program. The output of this program is supposed to look like a list of dates. - For example: - - ``` - Hedy calender - Here are all the days of November - November 1 - November 2 - November 3 - ``` - And so on. - - Mind that you have to test your code extra carefully for the month February, because the amount of days in this month changes in leap years. - example_code: | - **Warning! This code needs to be debugged!** - ``` - print 'Hedy calender' - months_with_31 days = January, March, May, July, September, October, December - months_with_30_days = April, June, August, November - month = ask 'Which month would you like to see?' - if month in months_with_31_days - days = 31 - if month in months_with30_days - days = 30 - if month = February - leap_years = 2020, 2024, 2028, 2036, 2040, 2044, 2028 - year = ask 'What year is it?' - if year in leap_years - days = 29 - else - days = 28 - - print 'Here are all the days of ' moth - for i in range 1 to days - print month i - ``` - 12: - example_code: | - **Warning! This code needs to be debugged!** - ``` - define greet - greetings = 'Hello', 'Hi there', 'Goodevening' - print greetings at random - - define take_order - food = ask 'What would you like to eat?' - print 'One food' - drink = 'What would you like to drink?' - print 'One ' drink - more = ask 'Would you like anything else?' - if more is 'no' - print 'Alright' - else - print 'And ' more - print 'Thank you' - - print 'Welcome to our restaurant' - people = ask 'How many people are in your party tonight?' - for i in range 0 to people - call greet_costumer - ``` - 13: - example_code: | - **Warning! This code needs to be debugged!** - ``` - defin movie_recommendation with name - action_movies == 'Die Hard', 'Fast and Furious', 'Inglorious Bastards' - romance_movies = 'Love Actually', 'The Notebook', 'Titanic' - comedy_movies = 'Mr Bean' 'Barbie''Deadpool' - kids_movies = 'Minions', 'Paddington', 'Encanto' - if name is 'Camila' or name is 'Manuel' - recommended_movie = kids_movie at random - if name is 'Pedro' or 'Gabriella' - mood = ask 'What you in the mood for?' - if mood is 'action' - recommended_movie = comedy_movies at random - if mood is 'romance' - recommended_movie = romance_movies - if mood is 'comedy' - recommended_movie = comedy_movies at random - - print 'I would recommend ' recommended_movie ' for ' name - - name = ask 'Who is watching?' - recommendation = ask 'Would you like a recommendation?' - if recommendaion is 'yes' - print movie_recommendation with name - else - print 'No problem!' - ``` - 14: - example_code: | - **Warning! This code needs to be debugged!** - ``` - define calculate_heartbeat - print 'Press your fingertips gently against the side of your neck' - print '(just under your jawline)' - print 'Count the number of beats you feel for 15 seconds' - beats == ask 'How many beats do you feel in 15 seconds?' - heartbeat = beats*4 - print 'Your heartbeat is ' heartbeat - if heartbeat >= 60 or heartbeat <= 100 - print 'Your heartbeat seems fine' - else - if heartbeat > 60 - print 'Your heartbeat seems to be too low' - if heartbeat < 100 - print 'Your heartbeat seems to be too high' - print 'You might want to contact a medical professional' - - measure_heartbeat = ask 'Would you like to measure your heartbeat?' - if measure_heartbeat = 'yes' - call measure_heartbeat - else - 'no problem' - ``` - - print '(just under your jawline)' - print 'Count the number of beats you feel for 15 seconds' - beats == ask 'How many beats do you feel in 15 seconds?' - heartbeat = beats*4 - print 'Your heartbeat is ' heartbeat - if heartbeat >= 60 or heartbeat <= 100 - print 'Your heartbeat seems fine' - else - if heartbeat > 60 - print 'Your heartbeat seems to be too low' - if heartbeat < 100 - print 'Your heartbeat seems to be too high' - print 'You might want to contact a medical professional' - - measure_heartbeat = ask 'Would you like to measure your heartbeat?' - if measure_heartbeat = 'yes' - call measure_heartbeat - else - 'no problem' - 15: - example_code: | - **Warning! This code needs to be debugged!** - ``` - names = 'Tanya', 'Romy', 'Kayla', 'Aldrin', 'Ali' - verbs='walking', 'skipping', 'cycling', 'driving', 'running' - locations = 'on a mountaintop', 'in the supermarket', 'to the swimming pool' - hiding_spots = 'behind a tree', under a table', in a box' - sounds = 'a trumpet', 'a car crash', 'thunder' - causes_of_noise = 'a television', 'a kid with firecrackers', 'a magic elephant', 'a dream' - - chosen_ name = names at random - chosen_verb = verbs at random - chosen_location = 'locations at random' - chosen_sounds = noises at random - chosen_spot = hiding_spots random - chosen_causes = causes_of_noise at random - - print chosen_name ' was ' chosen_verb ' ' chosen_location - print 'when they suddenly heard a sound like ' sounds at random - print chosen_name ' looked around, but they couldn't discover where the noise came from' - print chosen_name ' hid ' chosen_spot' - print 'They tried to look around, but couldn't see anything from there' - hidden = 'yes' - while hidden = 'yes' - print chosen_name 'still didn't see anything' - answer = ask 'does ' chosen_name ' move from their hiding spot?' - if answer = 'yes' - hidden == 'no' - print 'chosen_name moved from' chosen_spot - print 'And then they saw it was just' chosen_cause - print chosen_name 'laughed and went on with their day' - print The End - ``` - 16: - example_code: | - **Warning! This code needs to be debugged!** - ``` - country = ['The Netherlands', 'Poland', 'Turkey', 'Zimbabwe', 'Thailand', 'Brasil', 'Peru', 'Australia', 'India', 'Romania' ] - capitals = 'Amsterdam', 'Warshaw' 'Istanbul', 'Harare', 'Bangkok', 'Brasilia', 'Lima', 'Canberra', 'New Delhi', 'Bucharest' - score = 0 - for i in range 0 to 10 - answer = ask 'What's the capital of ' countries[i] - correct = capital[i] - if answer = correct - print 'Correct!' - score = score + 1 - else - print 'Wrong,' capitals[i] 'in the capital of' countries[i] - print 'You scored ' score ' out of 10' - - ``` - 17: - example_code: | - **Warning! This code needs to be debugged!** - ``` - define food_order - toppings = ask 'pepperoni, tuna, veggie or cheese?' - size = ask 'big, medium or small?' - number_of_pizza = ask 'How many these pizzas would you like?' - - print 'YOU ORDERED' - print number_of_pizzas ' size ' topping ' pizza' - - define drinks_order - drink = ask 'water, coke, icetea, lemonade or coffee?' - number_of_drinks = ask 'How many of these drinks would you like?' - - print 'YOU ORDERED' - print number_of_drinks ' ' drink - - 'Welcome to Hedy pizza' - more_food = ask 'Would you like to order a pizza?' - while more_food = 'yes' - return food_order - more_food = ask 'Would you like to order a pizza?' - more_drinks = ask 'Would you like to order some drinks?' - while more_drinks == 'yes' - call drink_order - more_drinks == ask 'Would you like to order more drinks?' - - - print 'Thanks for ordering!' - ``` - 18: - example_code: | - **Warning! This code needs to be debugged!** - ``` - animals = ['pig', 'dog', 'cow'] - sounds = ['oink', 'woof', 'moo'] - for i in range 1 to 3 - animal = animals[i] - sound = sounds[i] - print 'Old MacDonald had a farm' - print 'E I E I O!' - print 'and on that farm he had a ' animal - print 'E I E I O!' - print 'with a ' sound sound ' here' - print 'and a ' sound sound ' there' - print 'here a ' sound - print 'there a ' sound - print 'everywhere a ' sound sound - ``` default: name: Начало description: Обяснение @@ -711,155 +171,6 @@ adventures: ``` repeat 3 times print 'Да пишеш код на Хеди е забавно!' ``` - 8: - story_text: |- - `{ask}` {and} `{print}` still work as you know them. But `{if}` {and} `{repeat}` have changed! - You can now execute groups of code together, but you will have to *indent* the code. - That means putting four spaces at the beginning of the line. You will also have to indent when you just want to create a block of one line. - example_code: | - ``` - {repeat} 5 {times} - {print} 'Hello everyone' - {print} 'This is all repeated 5 times' - ``` - 9: - story_text: |- - Great job! You've reached another new level! In the previous level you've learned to use multiple lines of code in an {if} or {repeat} command. But you can't yet combine the two... - Good news! In this level you will be allowed to put an {if} inside an {if}, or inside a {repeat} command. Putting a block of code inside another block of code is called nesting. ``` Putting a block of code inside another block of code is called nesting. - 10: - story_text: |- - In this level we learn a new code called `{for}`. With `{for}` you can make a list and use all elements. - `{for}` creates a block, like `{repeat}` and `{if}` so all lines in the block need to start with spaces. - example_code: | - ``` - animals {is} dog, cat, blobfish - {for} animal {in} animals - {print} 'I love ' animal - ``` - 12: - story_text: |- - **Decimal numbers** - So far, Hedy did not allow for decimal numbers like 1.5, but now we do allow that. Note that computers use the `.` for decimal numbers. - example_code: | - ``` - {print} 'Two and a half plus two and a half is...' - {print} 2.5 + 2.5 - ``` - - {print} 2.5 + 2.5 - 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!' - ``` - 14: - story_text: | - We are going to learn more new items. You might know them already from mathematics, the `<` and `>`. - The `<` checks if the first number is smaller than the second, for example `age < 12` checks if `age` {is} smaller than 12. - If you want to check if the first number is smaller or equal to the second, you can use `<=`, for example `age <= 11`. - The `>` checks if the first number is bigger than the second, for example `points > 10` checks if `points` is larger than 10. - If you want to check if the first number is bigger or equal to the second, you can use `>=`, for example `points >= 11`. - You use these comparisons in an `{if}`, like this: - example_code: | - ``` - age = {ask} 'How old are you?' - {if} age > 12 - {print} 'You are older than I am!' - ``` - - {if} age < 13 - {print} 'You are younger than me!' - {else} - {print} 'You are older than me!' - 15: - story_text: |- - We are going to learn a new loop, the `{while}` loop! We continue the loop as long as the statement is true. - So don't forget to change the value in the loop. - - In the example code, we continue until a correct answer has been given. - If the correct answer is never given, the loop never ends! - 16: - story_text: |- - We are going to make lists the Python way, with square brackets around the lists! We also keep the quotation marks around each item like we have learned in previous levels. - You can use the square brackets as well to point out a place in the lists. - 17: - story_text: |- - Now we are going to change indentation a little bit. Every time that we need an indentation, we need `:` at the line before the indentation. - - In this level you can also use a new command: `{elif}`. `{elif}` is short for `{else} {if}` and you need it when you want to make 3 (or more!) options. - Check it out! - 18: - story_text: |- - We arrived at real Python code! That means we need to use parentheses with {print} and {range} from now on. - {print}('My name is ', naam) - dice: - levels: - 3: - example_code: | - ``` - choices {is} 1, 2, 3, 4, 5, earthworm - {print} choices {at} {random} - ``` - 4: - story_text: | - In this level we can make sentences with the die value in the sentence, with quotes of course. - This time the sample code is not quite complete. Can you finish the code? - 5: - story_text: | - You can also make a die again in this level using the `{if}`. - Complete the sample code so that the code says "You can stop throwing" once you have thrown an earthworm. - - But maybe you want to recreate a die from a completely different game. That's fine too! Then make up your own reaction. Eg 'yes' for 6 and 'pity' for something {else}. - example_code: | - ``` - choices {is} 1, 2, 3, 4, 5, earthworm - throw {is} _ - {print} 'you have' _ 'thrown' - {if} _ {is} earthworm {print} 'You can stop throwing.' _ {print} 'You have to hear it again!' - ``` - 6: - story_text: | - You can also make an Earthworm die again in this, but now you can also calculate how many points have been rolled. - You may know that the worm counts 5 points for Earthworms. Now after a roll you can immediately calculate how many points you have thrown. - This is the code to calculate points for one die: - example_code: | - ``` - choices = 1, 2, 3, 4, 5, earthworm - points = 0 - throw = choices {at} {random} - {print} 'you threw' throw - {if} throw {is} earthworm points = points + 5 {else} points = points + throw - {print} 'those are' points ' point' - ``` - Can you make the code so that you get the total score for 8 dice? To do that, you have to cut and paste some lines of the code. - example_code_2: | - Did you manage to calculate the score for 8 dice? That required a lot of cutting and pasting, right? We are going to make that easier in level 7! - 7: - story_text: | - You can also make a die again in level 5. With the `{repeat}` code you can easily roll a whole hand of dice. - Try to finish the sample code! The dashes should contain multiple commands and characters. - - But maybe you want to make a completely different die. Of course you can! - example_code: | - ``` - choices = 1, 2, 3, 4, 5, earthworm - {repeat} _ _ {print} _ _ _ - ``` - 10: - story_text: | - Is everybody taking too long throwing the dice? In this level you can let Hedy throw all the dice at once! - example_code: | - ``` - players = Ann, John, Jesse - choices = 1, 2, 3, 4, 5, 6 - {for} player {in} players - {print} player ' throws ' choices {at} {random} - {sleep} - ``` dishes: name: Кой мие чиниите? description: Използвай компютъра, за да разбереш кой мие чиниите (от второ до шесто ниво). @@ -926,23 +237,6 @@ adventures: Ако сега копираш и добавиш програмния код от 3-ти до 5-ти ред, тоест 7 пъти за цяла седмица, програмата ще изчисли колко пъти общо Лили ще мие чинии тази седмижца. - story_text_2: | - If you are extremely unlucky the previous program might choose you to to the dishes for the whole week! That's not fair! - To create a fairer system you can use the `{remove}` command to remove the chosen person from the list. This way you don't have to do the dishes again untill everybody has had a turn. - - Monday and tuesday are ready for you! Can you add the rest of the week? - And... can you come up with a solution for when your list is empty? - example_code_2: | - ``` - people = mom, dad, Emma, Sophie - dishwasher = people {at} {random} - {print} 'Monday the dishes are done by: ' dishwasher - {remove} dishwasher {from} people - dishwasher = people {at} {random} - {print} 'Tuesday the dishes are done by: ' dishwasher - {remove} dishwasher {from} people - dishwasher = people {at} {random} - ``` 7: story_text: | С `repeat` повтори част от кода в цикъл. Довърши примерния код (като замениш '_' с команда или символ) така, че @@ -952,1147 +246,79 @@ adventures: семейство is мама, тате, Лили, Сашо repeat _ _ print 'Миячът на чинии е ' семейство _ _ '.' ``` - 10: - story_text: | - In this level you could make an even better dish washing shedule. - elif_command: - description: elif - levels: - 17: - example_code: | - ``` - prices = ['1 million dollars', 'an apple pie', 'nothing'] - your_price = prices[{random}] - {print} 'You win ' your_price - {if} your_price == '1 million dollars' : - {print} 'Yeah! You are rich!' - {elif} your_price == 'an apple pie' : - {print} 'Lovely, an apple pie!' - {else}: - {print} 'Better luck next time..' - ``` - for_command: - description: for command - levels: - 11: - story_text: |- - In this level, we add a new form of the `{for}`. In earlier levels, we used `{for}` with a list, but we can also use `{for}` with numbers. - We do that by adding a variable name, followed by `{in}` `{range}`. We then write the number to start at, `{to}` and the number to end at. - Try the example to see what happens! In this level again, you will need to use indentations in lines below the `{for}` statements. - fortune: + turtle: + name: Костенурка + default_save_name: turtle + description: Рисунка levels: 1: story_text: | - Have you ever been to a carnival and had your future predicted by a fortune teller? Or have you ever played with a magic eight ball? - Then you probably know that they can't really predict your future, but it's still fun to play! + В първо ниво ще нарисуваме нещо просто с линии и извивки. Примерно с линии и ъгли чертаем правоъгълник или стълбище. - In the upcoming levels you can learn how to create your own fortune telling machine! - In level 1 you can start off easy by letting Hedy introduce herself as a fortune teller and let her {echo} the players' answers. - Like this: - example_code: | - ``` - {print} Hello, I'm Hedy the fortune teller! - {ask} Who are you? - {print} Let me take a look in my crystal ball - {print} I see... I see... - {echo} Your name is - ``` + Командата `forward` значи "напред" и служи за рисуване на права линия. А, `forward 50` озачава + "нарисувай черта с дължина 50 пиксела" (пиксел е мерна единица на екрана). - ### Exercise - Hedy now only tells you your name. Can you expand the code so that Hedy can predict more things about you? + С командата `turn right` (завий надясно) правиш завой от 90 градуса по посока на часовниковата стрелка, а + командата `turn left` (завий наляво) правиш завой наляво - обратно на часовниковата стрелка. - Obviously, Hedy isn't a very good fortune teller yet, as she can only repeat the answers that were given by the players! - Take a look in level 2 to improve your fortune teller. - story_text_2: | - ### Exercise - Hedy now only tells you your name. Can you expand the code so that Hedy can predict more things about you? - Obviously, Hedy isn't a very good fortune teller yet, as she can only repeat the answers that were given by the players! - Take a look in level 2 to improve your fortune teller. + Да програмираме стъпала! Можеш ли да "нарисуваш" 5 стъпала? + 2: + story_text: | + В първо ниво нашата костенурка можеше да се движи само само в посока ляво или дясно. Това бързо доскучава, нали? + Във второ ниво ще програмираме тя да насочва носа си във всички посоки. + + Ползвай 90 градуса, за да завиеш 1/4 (една четвърт). Едно пълно завъртане е равно на 360 градуса. + Представи си как би могла да "нарисуваш" фигура от свързани линии с програмиране? Може би триъгълник? Кръг? 3: story_text: | - In the previous levels you've created your first fortune telling machine, but Hedy couldn't really predict anything, only {echo}. - In this level you can use a variable and the `{at} {random}` command to really let Hedy choose an answer for you. Check out this code for instance: + Докато рисуваш костенурката можеш да добавиш и командата `random`. С нея костенурката ще поеме в произволна посока всеки път. + Ползвай `at random` в комбинация с променлива с повече стойности, не само една. + Ползвай примера отдолу и увеличи листа с още стойности, освен 10, 50, 90, 150, 250. example_code: | - In this example the player can {ask} Hedy a yes-no question and Hedy will pick a random answer for you. ``` - {print} I’m Hedy the fortune teller! - question {is} {ask} What do you want to know? - {print} This is what you want to know: question - answers {is} yes, no, maybe - {print} My crystal ball says... - {sleep} 2 - {print} answers {at} {random} + ъгли is 10, 50, 90, 150, 250 + turn ъгли at random + forward 25 ``` - - ### Exercises - Now, Hedy can only answer yes, no or maybe. Can you give Hedy more answer options, like 'definitely' or '{ask} again'. - story_text_2: | - ### Exercises - Now, Hedy can only answer yes, no or maybe. Can you give Hedy more answer options, like 'definitely' or '{ask} again'. 4: - example_code: | - ``` - {print} 'Im Hedy the fortune teller!' - question {is} {ask} 'What do you want to know?' - {print} 'This is your question: ' question - answers {is} yes, no, maybe - {print} 'My crystal ball says...' - {sleep} 2 - {print} answers {at} {random} - ``` - 5: story_text: | - In this level you'll learn to (secretly) tip the odds in your favor, when using the fortune teller! - By using `{if}` and `{else}` you can make sure that you will always get a good fotune, while other people might not. - Check out this example to find out how. + В трето ниво е нужно да ползваш кавички с командите `print` and `ask`. Същото важи при рисуването! example_code: | ``` - {print} 'Im Hedy the fortune teller!' - {print} 'I can predict {if} youll win the lottery tomorrow!' - person {is} {ask} 'Who are you?' - {if} person {is} Hedy {print} 'You will definitely win!🤩' {else} {print} 'Bad luck! Someone {else} will win!😭' + print 'Рисуване на фигури' + angle is 90 + turn angle + forward 25 + turn angle + forward 25 ``` - 6: + 5: story_text: | - In this level you can use math in your predictions as a fortune teller. This allows you to make up (silly) formulas to calculate the future. - For example you could calculate how rich you'll get or how many kids you will have when you grow up. + В четвърто ниво можеш да програмираш правене на избор с командата `if`. example_code: | ``` - {print} 'I am Hedy the fortune teller!' - {print} 'I can predict how many kids youll get when you grow up!' - age = {ask} 'How old are you?' - siblings = {ask} 'How many siblings do you have?' - length = {ask} 'How tall are you in centimetres?' - kids = length / age - kids = kids - siblings - {print} 'You will get ...' - {sleep} - {print} kids ' kids!' + print 'Рисуване на фигури' + фигура is ask 'Какво да нарисуваме: четриъгълник или триъгълник?' + if фигура is триъгълник angle is 120 else angle is 90 + turn angle + forward 25 + turn angle + forward 25 + turn angle + forward 25 + turn angle + forward 25 ``` - - If the previous example wasn't silly enough for you, take a look at this one! - + example_code_2: | ``` - {print} 'Im Hedy the silly fortune teller!' - {print} 'I will predict how smart you are!' - football = {ask} 'On a scale 1-10 how much do you love football?' - bananas = {ask} 'How many bananas did you eat this week?' - hygiene = {ask} 'How many times did you wash your hands today?' - result = bananas + hygiene - result = result * football - {print} 'You are ' result ' percent smart.' + фигура is ask 'Какво да нарисуваме: четриъгълник или триъгълник?' + if фигура is триъгълник angle is 120 else angle is 90 + turn angle + forward 25 ``` - 7: - story_text: | - In this level you can use the `{repeat}` command to make your machine tell multiple fortunes at once. - example_code: | - ``` - {print} 'Im Hedy the fortune teller!' - {print} 'You can {ask} 3 questions!' - {repeat} 3 {times} question = {ask} 'What do you want to know?' - answer = yes, no, maybe - {repeat} 3 {times} {print} 'My crystal ball says... ' answer {at} {random} - ``` - - ### Exercise - As you can see, the questions aren't printed in this example. That's because the variable `question` was changed 3 times. - Every time the player fills in the new answer, Hedy overwrites the previous one, so the first answer the player gave is forgotten. - This means you can't print all the questions this way. - - By using 3 different variables instead of 1 (for example `question1` , `question2` and `question3`), you could solve the problem and print the questions. - This does mean that you can only use `{repeat}` for the answers, and you will have to ask and print all the questions separately. - Can you do it? - - In the upcoming levels the layout of {repeat} command will change, which enables you to repeat multiple lines at once. - 8: - story_text: | - In the previous levels you've learned how to use repeat to make the fortune teller answer 3 questions in a row, but we had a problem with printing the questions. - Now that problem is solved, because of the new way of using the repeat command. - In the next example you can have your fortune teller {ask} 3 questions and also print them! - example_code: | - ``` - {print} 'I am Hedy the fortune teller!' - {print} 'You can {ask} me 3 questions.' - answers = yes, no, maybe - {repeat} 3 {times} - question = {ask} 'What do you want to know?' - {print} question - {sleep} - {print} 'My crystal ball says...' answers {at} {random} - ``` - 10: - story_text: | - In this level you'll learn how to program the game MASH (mansion, apartement, shack, house). In this game you can predict for all the players at once, what their future will look like. - example_code: | - ``` - houses = mansion, apartment, shack, house - loves = nobody, a royal, their neighbour, their true love - pets = dog, cat, elephant - names = Jenna, Ryan, Jim - {for} name {in} names - {print} name ' lives in a ' houses {at} {random} - {print} name ' will marry ' loves {at} {random} - {print} name ' will get a ' pets {at} {random} ' as their pet.' - {sleep} - ``` - 12: - story_text: | - In this level you can make your fortunes multiple words. Like in this example below: - example_code: | - ``` - fortunes = 'you will be rich', 'you will fall in love', 'you will slip on a banana peel' - {print} 'I will take a look in my crystall ball for your future.' - {print} 'I see... I see...' - {sleep} - {print} fortunes {at} {random} - ``` - functions: - levels: - 12: - example_code: | - ``` - sides = 'left', 'right' - limbs = 'hand', 'foot' - colors = 'red', 'blue', 'green', 'yellow' - - {define} turn - chosen_side = sides {at} {random} - chosen_limb = limbs _ - chosen_color = colors _ - {print} chosen_side ' ' chosen_limb ' on ' chosen_color - - {print} 'Lets play a game of Twister!' - {for} i {in} {range} 1 to _ - {call} turn - {sleep} 2 - ``` - 13: - story_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. - - For example in this code we've programmed the first verse of the song 'My Bonnie is over the ocean'. - In this example code the argument `place` is used. Place is a variable that is only used in the function, so an argument. - To use `place` we have programmed the line `define song with place`. - When the function is called, computer will replace the argument `place`, with the piece of text after `call song with`. - - ### Exercise - The next verse of this song goes: - - Last night as I lay on my pillow - Last night as I lay on my bed - Last night as I lay on my pillow - I dreamed that my Bonnie is dead - - Can you program this verse in the same way as the example? - 14: - example_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?' - - new_price = _ calculate_new_price {with} old_price, _ - {print} 'The new price is ' new_price ' dollar' - ``` - haunted: - levels: - 1: - story_text: | - In this adventure you are working towards making a game in which you have to escape from a haunted house by picking the correct door. - If you pick the right door you'll survive, but {if} not a terrible monster might... - - In level 1 we start our haunted house game by making up a scary story and {ask} the player what monster they'll see in the haunted house. - story_text_2: | - Can you finish the scary story? Or make up your own haunted house story? - 2: - example_code_2: | - ``` - monster_1 {is} _ - monster_2 {is} _ - monster_3 {is} _ - {print} You enter the haunted house. - {print} Suddenly you see a monster_1 - {print} You run into the other room, but a monster_2 is waiting there for you! - {print} Oh no! Quickly get to the kitchen. - {print} But as you enter monster_3 attacks you! - ``` - 3: - story_text: | - In the previous levels you've made an introduction to your haunted house game, but as you might have noticed the story would always have a dreadful end. - In this level you can make your story more interactive by changing the outcome of the game; sometimes you'll get eaten, sometimes you'll escape! - Let Hedy decide randomly! - 4: - story_text: | - In this level you learn how to use quotation marks in your games. - Can you make your Haunted House level 4 proof? - example_code: | - ``` - {print} _Escape from the haunted house!_ - {print} _There are 3 doors in front of you..._ - choice {is} {ask} _Which door do you choose?_ - {print} _You picked door ..._ choice - monsters {is} a zombie, a vampire, NOTHING YOUVE ESCAPED - {print} _You see..._ - {sleep} - {print} monsters {at} {random} - ``` - 5: - story_text: | - Up until this level the haunted house game always asked the player to choose a door, but as you might have noticed, they didn't really have to answer correctly. - If the player filled in a completely random answer, the game would still work and the player might even win (despite not picking a door). - In this level you can only win the game by picking the same door Hedy picked randomly. - 9: - story_text: | - In this level you can use nesting, which allows you to make the haunted house even more interactive! - - Now it's very hard to win this game, can you make it easier to win? - For example by only having 1 wrong door and 2 correct doors instead of 1 correct door and 2 wrong ones? - 11: - story_text: | - In this level we've changed the repeat command and we've added a line to our haunted house that tells the player in which room they are. - if_command: - description: Introducing the if command - levels: - 9: - story_text: | - In this level you can also put an {if} command inside another {if} command. - in_command: - description: Introducing the in command - levels: - 5: - example_code_2: | - ``` - animals is dog, cow, sheep - answer is ask 'What is your favorite animal?' - _ answer _ animals _ 'Mine too!' - _ _ 'My favorite animals are dogs, cows and sheep' - ``` - is_command: - description: introducing is command - levels: - 2: - story_text_2: | - ### Exercise - Time to make your own variables! - In the example code we made an example of the variable `favorite_animal`. In line 1 the variable is set, and in line 2 we haved used the variable in a print command. - Firstly, finish our example by filling in your favorite animal on the blank. Then make at least 3 of these codes yourself. Pick a variable, and set the variable with the {is} command. Then use it with a {print} command, just like we did. - 14: - example_code: | - ``` - age = {ask} 'How old are you?' - {if} age > 12 - {print} 'You are older than I am!' - ``` - example_code_3: | - ``` - name = {ask} 'What is your name?' - {if} name != 'Hedy' - {print} 'You are not Hedy' - ``` - - {if} age < 13 - {print} 'You are younger than me!' - {else} - {print} 'You are older than me!' - language: - levels: - 5: - story_text: | - Make your own program to practice your vocabulary in a new language. - maths: - levels: - 6: - example_code: | - ``` - {print} '5 plus 5 is ' 5 + 5 - {print} '5 minus 5 is ' 5 - 5 - {print} '5 times 5 is ' 5 * 5 - ``` - 12: - example_code_2: | - ``` - a = 'Hello ' - b = 'world!' - {print} a + b - ``` - - {print} 2.5 + 2.5 - music: - levels: - 6: - story_text: "Instead of playing notes, you can also play numbers now. Simply type `{play} 1` for the lowest note, `{play} 70` for the highest note, or anything in between.\n\n### Exercise\n This calls for musical maths! Try out the example code a couple of times with different starting numbers. \nThen, see if you can compose a song using the numbers.\n" - parrot: - levels: - 1: - story_text_2: | - ### Exercise - Can you make the parrot ask a different question? Fill in the blanks in the example! - 2: - story_text: | - Create your own online pet parrot that will copy you! - example_code: | - ``` - {print} Im Hedy the parrot - name {is} {ask} whats your name? - {print} name - {sleep} - {print} squawk - {sleep} - {print} name - ``` - story_text_2: | - ### Exercise - You can use variables to make the parrot say more than only your name. Can you complete this code? - 3: - story_text: | - Teach your parrot a new word with `{add}`. - example_code: | - ``` - words {is} squawk, Hedy - {print} Train your parrot! - new_word {is} {ask} Which word do you want to teach them? - {add} new_word {to_list} words - {print} 🧒 Say new_word , Hedy! - {print} 🦜 words {at} {random} - ``` - 4: - story_text: | - In this level we have to use quotation marks with the commands `{ask}` and `{print}`. - Can you complete the code by adding quotation marks? - 5: - story_text: | - Reward your parrot {if} it says the correct word! - example_code: | - ``` - words {is} squawk, Hedy - {print} 'Train your parrot!' - new_word {is} {ask} 'Which word do you want to teach them?' - {add} new_word {to_list} words - said_word {is} words {at} {random} - {print} '🧒 Say ' new_word ', Hedy!' - {print} '🦜 ' said_word - {if} said_word {is} new_word {print} '🧒 Great job, Hedy! 🍪' - {else} {print} '🧒 No, Hedy! Say ' new_word - ``` - piggybank: - levels: - 12: - story_text: | - In this adventure you learn how to make a digital piggy bank, to calculate how much money you have and how long you need to save up to buy what you want! - example_code: | - ``` - {print} 'The digital piggy bank' - wish = {ask} 'What would you like to buy?' - price = {ask} 'How much does that cost?' - saved = {ask} 'How much money have you saved already?' - allowance = {ask} 'How much pocket money do you get per week?' - to_save = price - saved - weeks = to_save / allowance - {print} 'You can buy a ' wish ' in ' weeks ' weeks.' - 14: - example_code: | - ``` - _ calculate_budget with wish, money, allowance - to_save = wish - money - weeks = to_save / allowance - {if} wish _ money - {print} 'You need to save up some more!' - {print} 'Youll need ' weeks ' more weeks.' - {else} - {print} 'Great! You have enough' - {print} 'Lets go shopping!' - - money = {ask} 'How much money have you saved?' - wish = {ask} 'How much money do you need?' - allowance = {ask} 'How much pocket money do you get each week?' - - {call} calculate_budget with _, _, _ - ``` - pressit: - levels: - 9: - story_text: | - Now that you know how to combine statements, you can create a touch type tool with `{pressed}`. - - ### Exercise - Finish the code. Each time a random letter should be chosen, which you have to press. You get a point for a correct press, and and two points deduction for a wrong press. - **(extra)** Clear the screen after each letter, and show the user how many points they have scored. - print_command: - levels: - 18: - example_code_2: | - ``` - temperature = 25 - {print}('It is ', temperature, ' degrees outside') - ``` - - {print}('My name is ', name) - random_command: - levels: - 16: - story_text: |- - We are going to make lists the Python way, with square brackets around the lists! We also keep the quotation marks around each item like we have learned in previous levels. - We use square brackets to point out a place in a list. For example: `friends[1]` is the first name on the list of friends, as you can see in the first part of the example code. The second part of the example code shows you that we can also match 2 lists using the variable i. - repeat_command: - description: repeat command - levels: - 7: - story_text: | - ## Repeat! Repeat! Repeat! - Level 7 adds the `{repeat}` command. `{repeat}` can be used to execute one line of code multiple times. Like this: - - ### Exercise - Play around with the repeat command. Can you make the happy birthday song in only 3 lines of code instead of 4 now? - 9: - story_text: | - Great job! You've reached another new level! In the previous level you've learned to use multiple lines of code in an {if} or {repeat} command. But you can't yet combine the two... - Good news! In this level you will be allowed to put an {if} inside an {if}, or inside a {repeat} command. Putting a block of code inside another block of code is called nesting. ``` Putting a block of code inside another block of code is called nesting. - example_code: | - ``` - answer = {ask} 'Are you ready to learn something new?' - {if} answer {is} yes - {print} 'Great! You can learn to use the repeat command in the if command!' - {print} 'Hooray!' - {print} 'Hooray!' - {print} 'Hooray!' - {else} - {print} 'Maybe you should practice some more in the previous level' - repeat_command_2: - description: repeat command 2 - levels: - 7: - story_text_2: | - Another interesting thing you can so with the `{repeat}` command is using variables to set the amount of times something should be repeated. In the example code you can see that we first ask the person how old they are. - Then, in line 3, the question is repeated 'age' times. So we have used the variable 'age' with the `{repeat}` command. - restaurant: - levels: - 1: - story_text_2: | - Can you think of more lines to add to your restaurant code? For example, can you {ask} the guests what they'd like to drink, tell them the price, or wish them a pleasant meal? - example_code_2: | - ``` - {print} Welcome to Hedy's restaurant 🍟 - {ask} What would you like to order? - {echo} So you would like to order - {print} Thanks you for your order! - {print} It's on its way! - ``` - 2: - story_text: | - In level 2 you could expand your restaurant by using variables. In level 1 Hedy could only {echo} the order once and only remember the last thing that was ordered. - Now you can use variables and Hedy can remember both the food and the drinks! - example_code: | - ``` - {print} Welcome to Hedy's restaurant! - {print} Today we're serving pizza or lasagna. - food {is} {ask} What would you like to eat? - {print} Great choice! The food is my favorite! - topping {is} {ask} Would you like meat or veggies on that? - {print} food with topping is on its way! - drinks {is} {ask} What would you like to drink with that? - {print} Thank you for your order. - {print} Your food and drinks will be right there! - ``` - story_text_2: | - ### Exercise - Can you make this code more elaborate? For example by adding drinks to the order? Or...? - 3: - example_code: | - ``` - {print} Welcome to Hedy's Random Restaurant! - {print} The only restaurant that will randomly choose your meal and its price for you! - starters {is} salad, soup, carpaccio - mains {is} pizza, brussels sprouts, spaghetti - desserts {is} brownies, ice cream, french cheeses - drinks {is} cola, beer, water - prices {is} 1 dollar, 10 dollars, 100 dollars - {print} You will start with: starters {at} {random} - {print} Then we'll serve: mains {at} {random} - {print} And as dessert: desserts {at} {random} - {print} You will get a drinks {at} {random} to drink - {print} That will be: prices {at} {random} - {print} Thank you and enjoy your meal! - ``` - story_text_2: | - Does your costumer have any allergies or do they dislike certain dishes? Then you can use the `{remove}`command to remove it from your menu. - example_code_2: | - ``` - {print} Mystery milkshake - flavors {is} strawberry, chocolate, vanilla - allergies {is} {ask} Are you allergic to any falvors? - {remove} allergies {from} flavors - {print} You get a flavors {at} {random} milkshake - ``` - 4: - story_text: | - ### Exercise - Add the quotation marks to this code to make it work! Be careful: variables should not be in quotation marks. - Then, use the `{clear}` command to only show one line at a time in your output screen. - - ### Exercise 2 - Go back to the previous level and copy your restaurant code. Make the code work in this level by adding quotation marks in the right spots and add some `{clear}` commands. - 5: - story_text: | - In this level the {if} command allows you to {ask} your customers questions and give different responses to the answers. - In the example below, you see that you can {ask} the customer {if} they want to hear the specials and Hedy can respond accordingly. - example_code: | - ``` - {print} 'Welcome to Hedys restaurant!' - special {is} {ask} 'Would you like to hear our specials today?' - {if} special {is} yes {print} 'Todays special is chicken piri piri and rice.' {else} {print} 'No problem.' - food {is} {ask} 'What would you like to eat?' - {print} 'One ' food ', coming right up!' - drink {is} {ask} 'What would you like to drink with that?' - {if} drink {is} cola {print} 'Im sorry, we are out of cola!' {else} {print} 'Great choice!' - anything {is} {ask} 'Would you like anything {else}?' - {print} 'Let me repeat your order...' - {print} 'One ' food - {if} drink {is} cola {print} 'and...' {else} {print} 'One ' drink - {if} anything {is} no {print} 'Thats it!' {else} {print} 'One ' anything - {print} 'Thank you for your order and enjoy your meal!' - ``` - 6: - story_text: | - In this level you can use maths to calculate the total price of your customer's order, which can make your virtual restaurant more realistic. - example_code: | - (Simple) - You can make a simple restaurant code, like this: - ``` - {print} 'Welcome to Hedys restaurant' - {print} 'Here is our menu:' - {print} 'Our main courses are pizza, lasagne, or spaghetti' - main = {ask} 'Which main course would you like?' - price = 0 - {if} main {is} pizza price = 10 - {if} main {is} lasagne price = 12 - {if} main {is} spaghetti price = 8 - {print} 'You have ordered ' main - {print} 'That will be ' price ' dollars, please' - {print} 'Thank you, enjoy your meal!' - ``` - 7: - story_text: | - In this level you've learned how to use the {repeat} command to repeat a line of code a certain amount of times. - You can use that in your restaurant to {ask} multiple people what they'd like to eat. Like this: - example_code: | - ``` - {print} 'Welcome to Hedys restaurant!' - people = {ask} 'How many people are joining us today?' - {repeat} people times food = {ask} 'What would you like to eat?' - {print} 'Thanks for your order! Its coming right up!' - ``` - 9: - story_text: | - In this level you can use nesting to make your restaurant more realistic and more fun! - For example you would {ask} for sauce {if} somebody orders fries, but you wouldn't {if} someone orders pizza! - Check out the example, and try this at your own virtual restaurant! - 10: - story_text: | - In this level you'll learn how to easily {ask} your guests' orders in a short code. - example_code_2: | - ``` - courses = appetizer, main course, dessert - names = Timon, Onno - {for} name {in} names - {for} course {in} courses - food = {ask} name ', what would you like to eat as your ' course '?' - {print} name ' orders ' food ' as their ' course - ``` - 11: - story_text: | - We can use the `{for} i {in} {range} 1 {to} 5` to {print} the orders from multiple customers in an orderly manner. - 12: - story_text: | - From this level on you can use decimal numbers to make you menu more realistic. - 13: - story_text: | - In this level we can use the new commands to upgrade our restaurant. - We use `{and}` to see {if} two things are both the case. - rock: - default_save_name: Rock - levels: - 2: - story_text: | - In this level you can practise using the variables, so that you can make the rock, paper, scissors game in the next level! - example_code: | - ``` - choice {is} _ - {print} I choose choice - ``` - 3: - story_text_2: | - ### Exercise - Now you only have one player, so can you add a second player? - You can even use variables to name player 1 and player 2. - example_code_2: | - ``` - choices {is} rock, paper, scissors - {print} player 1 chooses... choices {at} {random} - {print} player 2 _ - ``` - 5: - story_text: | - In this level we can determine who won. - For that you need the new `{if}` code. - - Save your choice with the name of choice and the choice of computer as computer choice. - Then you can use `{if}` to see {if} they are the same or different. - Will you finish the code? - example_code: | - ``` - options {is} rock, paper, scissors - computer_choice {is} _ - choice {is} {ask} What do you choose? - {print} 'you chose ' _ - {print} 'computer chose ' _ - {if} _ {is} _ {print} 'tie!' {else} {print} 'no tie' - ``` - - Fill in the correct code on the blanks to see {if} it is a draw. - 9: - story_text: | - In this level you can program the whole rock, paper, scissors game by nesting the {if}-commands. Can you finish the code? - example_code: | - ``` - choices = rock, paper, scisscors - your_choice = {ask} 'What do you choose?' - {print} 'You choose ' your_choice - computer_choice = choices {at} {random} - {print} 'The computer chooses ' computer_choice - {if} computer_choice {is} your_choice - {print} 'Tie' - {if} computer_choice {is} 'rock' - {if} your_choice {is} 'paper' - {print} 'You win!' - {if} your_choice {is} 'scissors' - {print} 'You lose!' - ``` - 10: - story_text: | - Feeling too lazy to play the game yourself? Let Hedy play it for you! - example_code: | - ``` - choices = rock, paper, scissors - players = Marleen, Michael - {for} player {in} players - {print} player ' chooses ' choices {at} {random} - ``` - 13: - story_text: | - With the `{and}` command you can shorten your rock, paper, scissors code! Check out the example code below and try to finish it. - example_code: | - ``` - options = 'rock', 'paper', 'scissors' - your_choice = {ask} 'What do you choose?' - computer_choice = options {at} {random} - {print} 'You choose ' your_choice - {print} 'The computer chooses ' computer_choice - {if} computer_choice {is} your_choice - {print} 'Tie' - {if} computer_choice {is} 'rock' {and} your_choice {is} 'paper' - {print} 'You win!' - {if} computer_choice {is} 'rock' {and} your_choice {is} 'scissors' - {print} 'The computer wins!' - ``` - 15: - example_code: | - ``` - won = 'no' - options = 'rock', 'paper', 'scissors' - {while} won == 'no' - your_choice = {ask} 'What do you choose?' - computer_choice = options {at} {random} - {print} 'you chose ' your_choice - {print} 'the computer chose ' computer_choice - {if} computer_choice == your_choice - {print} 'Tie!' - {if} computer_choice == 'rock' {and} your_choice == 'scissors' - {print} 'You lose!' - {if} computer_choice == 'rock' {and} your_choice == 'paper' - {print} 'You win!' - won = 'yes' - rock_2: - levels: - 2: - story_text: | - Now that you have learned how to use the `{ask} command, you can make your rock, paper, scissors code interavtive too! - - ### Exercise - Make the rock, paper, scissors code interactive by adding the `{ask}` command and a question to your rock, paper, scissors code. - example_code: | - ``` - choice is _ - {print} I choose choice - ``` - secret: - default_save_name: language - levels: - 12: - story_text: | - In this adventure you can create your own super spy code. Encode a message that only the right agent can decipher. - If the enemy tries to crack the code, they will get some false info to waste their time. - example_code: | - ``` - name {is} {ask} 'What is your name?' - {if} name {is} '_' - a {is} 'Go to the airport ' - {else} - a {is} 'Go to the trainstation ' - password {is} {ask} 'What is the password?' - {if} password {is} _ - b {is} 'tomorrow at 02.00' - {else} - b {is} 'today at 10.00' - {print} _ _ _ - ``` - 13: - story_text: | - The code you made in the previous level can be made a lot easier in this one with the `{and}` command. - sleep_command: - description: introducing sleep command - levels: - 2: - story_text: | - ## The sleep command - Another new command in this level is `{sleep}`, which pauses your program for a second. If you type a number behind the {sleep} command, the program pauses for that amount of seconds. - songs: - name: Изпей песен! - levels: - 6: - story_text: | - Songs often contain a lot of repetition. Sometimes the repetition is also based on counting. - For example, in the well-known song 'Bottles of beer'. You can program that song with a little math. - example_code_2: | - ``` - number = 6 - number = number - 1 - print number ' little monkeys jumping on the bed' - print 'One fell off and bumped his head' - print 'Mama called the doctor and the doctor said' - print 'NO MORE MONKEYS JUMPING ON THE BED!' - sleep - ``` - 7: - story_text: | - Songs often contain a lot of repetition. For example... Baby Shark! If you sing it, you keep singing the same thing: - - Baby Shark tututudutudu
- Baby Shark tututudutudu
- Baby Shark tututudutudu
- Baby Shark - - You can make this song much shorter with a `{repeat}`! Can you finish the code? - 8: - story_text: | - In a previous level you've programmed the song 'Bottles of beer'. You made one verse and then had to copy the verses 99 times. In level 7 you can repeat the song 99 times, just by adding one simple line! - 10: - story_text: | - In this level you can easily make the childrens' song 'Five little monkeys'. Can you make the last chorus? - You can also make the whole baby shark song (including all the other sharks in the family) in only 6 lines! - Or you can make Old MacDonald with all the different animals. - example_code: | - ``` - monkeys = 5, 4, 3, 2 - {for} monkey {in} monkeys - {print} monkey ' little monkeys jumping on the bed' - {print} 'One fell off and bumped his head' - {print} 'Mama called the doctor and the doctor said' - {print} 'NO MORE MONKEYS JUMPING ON THE BED!' - ``` - - ``` - sharks = baby, mommy, daddy, grandma, grandpa - {for} shark {in} sharks - {print} shark 'tututututudu' - {print} shark 'tututututudu' - {print} shark 'tututututudu' - {print} shark - ``` - ``` - animals = pig, dog, cow - {for} animal {in} animals - {if} animal {is} pig - sound = oink - {if} animal {is} dog - sound = woof - {if} animal {is} cow - sound = moo - {print} 'Old MacDonald had a farm' - {print} 'E I E I O!' - {print} 'and on that farm he had a ' animal - {print} 'E I E I O!' - {print} 'with a ' sound sound ' here' - {print} 'and a ' sound sound ' there' - {print} 'here a ' sound - {print} 'there a ' sound - {print} 'everywhere a ' sound sound - ``` - story_text_2: | - ### Exercise 2 - Print the song Five little moneys jumping on the bed. Look up the text if you don't remember. - - **(extra)** Print the song Old MacDonald had a farm, and make sure all animals make a different sound, using an `{if}`. - 11: - story_text: | - In this level you can use the `{for} i {in} {range}` command to make songs that use counting. - example_code: | - ``` - {for} i {in} {range} 5 {to} 1 - {print} i ' little monkeys jumping on the bed' - {print} 'One fell off and bumped his head' - {print} 'Mama called the doctor and the doctor said' - {if} i {is} 1 - {print} 'PUT THOSE MONKEYS RIGHT TO BED!' - {else} - {print} 'NO MORE MONKEYS JUMPING ON THE BED!' - ``` - 12: - story_text: | - In this song we can make it even easier to program '{if} you're happy and you know it, clap your hands'. Because we can put all of the actions in a variable, check it out: - songs_2: - levels: - 12: - example_code: | - ``` - {define} twinkle - {print} 'Twinkle' - {print} '...' - - {call} twinkle - {print} 'Up above the world so high' - {print} 'Like a diamond in the sky' - {call} _ - ``` - turtle: - name: Костенурка - default_save_name: turtle - description: Рисунка - levels: - 1: - story_text: | - В първо ниво ще нарисуваме нещо просто с линии и извивки. Примерно с линии и ъгли чертаем правоъгълник или стълбище. - - Командата `forward` значи "напред" и служи за рисуване на права линия. А, `forward 50` озачава - "нарисувай черта с дължина 50 пиксела" (пиксел е мерна единица на екрана). - - С командата `turn right` (завий надясно) правиш завой от 90 градуса по посока на часовниковата стрелка, а - командата `turn left` (завий наляво) правиш завой наляво - обратно на часовниковата стрелка. - - Да програмираме стъпала! Можеш ли да "нарисуваш" 5 стъпала? - 2: - story_text: | - В първо ниво нашата костенурка можеше да се движи само само в посока ляво или дясно. Това бързо доскучава, нали? - Във второ ниво ще програмираме тя да насочва носа си във всички посоки. - - Ползвай 90 градуса, за да завиеш 1/4 (една четвърт). Едно пълно завъртане е равно на 360 градуса. - Представи си как би могла да "нарисуваш" фигура от свързани линии с програмиране? Може би триъгълник? Кръг? - example_code: | - ``` - answer {is} {ask} How many steps should the turtle make? - {forward} answer - ``` - story_text_2: | - Also, in level 1 the turtle could only turn left or right. That is a bit boring! - In level 2 he can point his nose in all directions. - - Use 90 to turn a quarter. We call this degrees. A full turn is 360 degrees. - Can you make a figure with this code? Maybe a triangle or a circle? - example_code_2: | - ``` - {print} Drawing figures - angle {is} 90 - {turn} angle - {forward} 25 - {turn} angle - {forward} 25 - ``` - 3: - story_text: | - Докато рисуваш костенурката можеш да добавиш и командата `random`. С нея костенурката ще поеме в произволна посока всеки път. - Ползвай `at random` в комбинация с променлива с повече стойности, не само една. - Ползвай примера отдолу и увеличи листа с още стойности, освен 10, 50, 90, 150, 250. - example_code: | - ``` - ъгли is 10, 50, 90, 150, 250 - turn ъгли at random - forward 25 - ``` - 4: - story_text: | - В трето ниво е нужно да ползваш кавички с командите `print` and `ask`. Същото важи при рисуването! - example_code: | - ``` - print 'Рисуване на фигури' - angle is 90 - turn angle - forward 25 - turn angle - forward 25 - ``` - 5: - story_text: | - В четвърто ниво можеш да програмираш правене на избор с командата `if`. - example_code: | - ``` - print 'Рисуване на фигури' - фигура is ask 'Какво да нарисуваме: четриъгълник или триъгълник?' - if фигура is триъгълник angle is 120 else angle is 90 - turn angle - forward 25 - turn angle - forward 25 - turn angle - forward 25 - turn angle - forward 25 - ``` - example_code_2: | - ``` - direction {is} {ask} 'Do you want to go left, right, or straight ahead?' - if direction is left turn _ - if direction is right turn _ - forward 100 - ``` - - фигура is ask 'Какво да нарисуваме: четриъгълник или триъгълник?' - if фигура is триъгълник angle is 120 else angle is 90 - turn angle - forward 25 - 6: + 6: story_text: | В това ниво 5 можеш да правиш изчисления, с които да рисуваш различни геометрични фигури. Вероятно знаеш от училище, че да начертаеш пълна окръжност ти трябва завъртане от 360 градуса. А, за да начертаеш квадрат са ти нужни 90 градуса завъртане (защото 360 / 4 = 90). С Хеди можем да ползваме математика, за да начертаем каквато и да е фигура! - example_code: | - ``` - ъгли is ask 'How many angles do you want?' - angle is 360 / ъгли - forward 50 - turn angle - forward 50 - turn angle - forward 50 - turn angle - forward 50 - turn angle - forward 50 - turn angle - forward 50 - turn angle - ``` - 8: - story_text: | - Now that we can repeat several lines, we can make figures more easily. - We only have to set the angle once and then use that variable in the `{repeat}`. - example_code: | - ``` - angle = 90 - {repeat} 10 {times} - {turn} angle - {forward} 50 - ``` - story_text_2: | - Also, we can now improve the program that draws different figures. - Can you figure out how far the turtle has to turn here? Finish the code and you can draw any polygon you'd like! - 9: - story_text: | - Now that we can use a `{repeat}` inside a `{repeat}`, we can create more complex figures. - - ### Exercise 1 - This code creates three black triangles, change that into five pink squares. - - **(extra)** Create a figure of your own choosing consisting of at least two different shapes types. - 10: - story_text: | - In this level you can make the turtle draw a figure. - The turtle will travel the distances in the list, one by one, making bigger and bigger steps. - ### Exercise 1 - Add a 90 degree turn in the loop, so that a spiral is drawn. - Add at least 5 numbers to the list, so the spiral grows larger. - **(extra)** can you change the spiral into another shape? Experiment with numbers for the turn! - ### Exercise 2 - The spiral is drawn outwards, make it go inwards? - turtle_draw_it: - levels: - 9: - example_code: | - Hint for the nested squares: - ``` - colors = red, blue, orange, yellow, pink, purple, green, brown, black - distance = 120 - repeat 5 times - _ - ``` - Hint for the flags: - ``` - country = ask 'which country would you like to see the flag of?' - if country is 'the Netherlands' - color_1 = red - color_2 = white - color_3 = blue - ``` - 10: - example_code: | - Hint Nested Hexagon: - ``` - distances = 100, 80, 60, 40, 20 - {for} distance {in} distances - _ - ``` - - Hint Traffic Lights: - ``` - colors = red, yellow, green - {for} chosen_color {in} colors - color _ - {repeat} _ - ``` - 12: - story_text: | - ### Exercise - Recreate the drawings with the turtle! - Hint: Bracelet designing program. Firstly, define a function **for each shape** you want to use on the bacelet. Then, add the shapes to the bacelet like this: - - Bracelet Designing program - example_code: | - ``` - {define} draw_a_square - _ - - {color} white - {turn} -90 - {forward} 300 - {turn} 180 - - {for} i {in} {range} 1 {to} 5 - {color} gray - {forward} 100 - shape = {ask} 'What kind of shape would you like next on the bracelet?' - chosen_color = {ask} 'In which color?' - {color} chosen_color - {if} shape = 'square' - {call} draw_a_square - ``` - while_command: - description: while - years: - description: Countdown to the new year! - levels: - 11: - story_text: | - In this level you can use the `{for} i {in} {range}` command to countdown to the New Year. - - ### Exercise - Fill in the blanks and make the code work! - example_code: | - ``` - for _ in _ 10 to 1 - {print} i - {print} 'Happy New Year!' - ``` diff --git a/content/adventures/bn.yaml b/content/adventures/bn.yaml index ba7a06466fd..c2cfb73e167 100644 --- a/content/adventures/bn.yaml +++ b/content/adventures/bn.yaml @@ -1,578 +1,4 @@ adventures: - story: - levels: - 1: - story_text_2: | - ### Exercise - Can you make your own story in Hedy now by using `{print}` , `{ask}` and `{echo}`? - 2: - 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: - example_code_2: | - ``` - {print} He hears a sound - animals {is} 🐿, 🦔, 🦇, 🦉 - animal {is} {ask} What do you think it is? - {add} animal {to_list} animals - {print} it was a animals {at} {random} - ``` - story_text_3: | - This is an example of the `{remove}` command in your story - 5: - story_text: | - In this level you can program different endings, which will make your story even more fun. - - 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 'encounter 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}`. - 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! - 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. - 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' - ``` - add_remove_command: - name: '{add} {to} & {remove} {from}' - 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. - 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. - and_or_command: - 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। - ask_command: - description: Introduction ask command - levels: - 1: - 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. - 2: - example_code_2: | - ``` - favorite_animal is ask What is your favorite animal? - print I like favorite_animal - ``` - calculator: - levels: - 6: - story_text: | - Now that you can calculate, you can also create a program to practice maths calculations. You can make up the calculations yourself, for example: - example_code: | - ``` - correct_answer = 11 * 27 - answer = {ask} 'How much is 11 times 27?' - {if} answer {is} correct_answer {print} 'good job!' - {else} {print} 'Wrong! It was ' correct_answer - ``` - story_text_2: | - You can also let the computer do random calculations on its own using {random}. - example_code_2: | - ``` - tables = 4, 5, 6, 8 - numbers = 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 - table = tables {at} {random} - number = numbers {at} {random} - correct_answer = table * number - answer = {ask} 'how much is ' table ' times ' number '?' - {if} answer {is} correct_answer {print} 'okay' - {else} {print} 'mistake! it was ' correct_answer - ``` - 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`. - 11: - example_code: | - ``` - number = 10 - {for} i {in} {range} 1 to 10 - {print} i * number - ``` - 12: - story_text: | - Now you can make a calculator that works for decimal numbers. - example_code: | - ``` - number1 = {ask} 'What is the first number?' - number2 = {ask} 'What is the second number?' - answer = number1 + number2 - {print} number1 ' plus ' number2 ' is ' answer - ``` - 14: - 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 - clear_command: - description: clear command - debugging: - levels: - 3: - 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} - ``` - 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! - 8: - 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: - 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!' - {else} - 'I'm sorry we don't sell that' - topping {is} {ask} 'What kind of topping would you like?' - sauce {is} {ask} 'What kind of sauce would you like?' - {print} One chosen_bread with topping and sauce. - price = amount * 6 - {print} 'That will be 'price dollar' please' - ``` - - price = amount * 6 - {print} 'That will be 'price dollar' please' - 10: - example_code: | - **Warning! This code needs to be debugged!** - ``` - names = Muad Hasan Samira Noura - activities = fly a kite, go swimming, go hiking, catch tan in the sun - {for} name {is} names - {print} At the beach name loves to activity at random - ``` - 11: - story_text: |- - ### Exercise - Debug this calender program. The output of this program is supposed to look like a list of dates. - For example: - - ``` - Hedy calender - Here are all the days of November - November 1 - November 2 - November 3 - ``` - And so on. - - Mind that you have to test your code extra carefully for the month February, because the amount of days in this month changes in leap years। - example_code: | - **Warning! This code needs to be debugged!** - ``` - print 'Hedy calender' - months_with_31 days = January, March, May, July, September, October, December - months_with_30_days = April, June, August, November - month = ask 'Which month would you like to see?' - if month in months_with_31_days - days = 31 - if month in months_with30_days - days = 30 - if month = February - leap_years = 2020, 2024, 2028, 2036, 2040, 2044, 2028 - year = ask 'What year is it?' - if year in leap_years - days = 29 - else - days = 28 - - print 'Here are all the days of ' moth - for i in range 1 to days - print month i - ``` - 12: - example_code: | - **Warning! This code needs to be debugged!** - ``` - define greet - greetings = 'Hello', 'Hi there', 'Goodevening' - print greetings at random - - define take_order - food = ask 'What would you like to eat?' - print 'One food' - drink = 'What would you like to drink?' - print 'One ' drink - more = ask 'Would you like anything else?' - if more is 'no' - print 'Alright' - else - print 'And ' more - print 'Thank you' - - print 'Welcome to our restaurant' - people = ask 'How many people are in your party tonight?' - for i in range 0 to people - call greet_costumer - ``` - 13: - example_code: | - **Warning! This code needs to be debugged!** - ``` - defin movie_recommendation with name - action_movies == 'Die Hard', 'Fast and Furious', 'Inglorious Bastards' - romance_movies = 'Love Actually', 'The Notebook', 'Titanic' - comedy_movies = 'Mr Bean' 'Barbie''Deadpool' - kids_movies = 'Minions', 'Paddington', 'Encanto' - if name is 'Camila' or name is 'Manuel' - recommended_movie = kids_movie at random - if name is 'Pedro' or 'Gabriella' - mood = ask 'What you in the mood for?' - if mood is 'action' - recommended_movie = comedy_movies at random - if mood is 'romance' - recommended_movie = romance_movies - if mood is 'comedy' - recommended_movie = comedy_movies at random - - print 'I would recommend ' recommended_movie ' for ' name - - name = ask 'Who is watching?' - recommendation = ask 'Would you like a recommendation?' - if recommendaion is 'yes' - print movie_recommendation with name - else - print 'No problem!' - ``` - 14: - example_code: | - **Warning! This code needs to be debugged!** - ``` - define calculate_heartbeat - print 'Press your fingertips gently against the side of your neck' - print '(just under your jawline)' - print 'Count the number of beats you feel for 15 seconds' - beats == ask 'How many beats do you feel in 15 seconds?' - heartbeat = beats*4 - print 'Your heartbeat is ' heartbeat - if heartbeat >= 60 or heartbeat <= 100 - print 'Your heartbeat seems fine' - else - if heartbeat > 60 - print 'Your heartbeat seems to be too low' - if heartbeat < 100 - print 'Your heartbeat seems to be too high' - print 'You might want to contact a medical professional' - - measure_heartbeat = ask 'Would you like to measure your heartbeat?' - if measure_heartbeat = 'yes' - call measure_heartbeat - else - 'no problem' - ``` - - print '(just under your jawline)' - print 'Count the number of beats you feel for 15 seconds' - beats == ask 'How many beats do you feel in 15 seconds?' - heartbeat = beats*4 - print 'Your heartbeat is ' heartbeat - if heartbeat >= 60 or heartbeat <= 100 - print 'Your heartbeat seems fine' - else - if heartbeat > 60 - print 'Your heartbeat seems to be too low' - if heartbeat < 100 - print 'Your heartbeat seems to be too high' - print 'You might want to contact a medical professional' - - measure_heartbeat = ask 'Would you like to measure your heartbeat?' - if measure_heartbeat = 'yes' - call measure_heartbeat - else - 'no problem' - 15: - example_code: | - **Warning! This code needs to be debugged!** - ``` - names = 'Tanya', 'Romy', 'Kayla', 'Aldrin', 'Ali' - verbs='walking', 'skipping', 'cycling', 'driving', 'running' - locations = 'on a mountaintop', 'in the supermarket', 'to the swimming pool' - hiding_spots = 'behind a tree', under a table', in a box' - sounds = 'a trumpet', 'a car crash', 'thunder' - causes_of_noise = 'a television', 'a kid with firecrackers', 'a magic elephant', 'a dream' - - chosen_ name = names at random - chosen_verb = verbs at random - chosen_location = 'locations at random' - chosen_sounds = noises at random - chosen_spot = hiding_spots random - chosen_causes = causes_of_noise at random - - print chosen_name ' was ' chosen_verb ' ' chosen_location - print 'when they suddenly heard a sound like ' sounds at random - print chosen_name ' looked around, but they couldn't discover where the noise came from' - print chosen_name ' hid ' chosen_spot' - print 'They tried to look around, but couldn't see anything from there' - hidden = 'yes' - while hidden = 'yes' - print chosen_name 'still didn't see anything' - answer = ask 'does ' chosen_name ' move from their hiding spot?' - if answer = 'yes' - hidden == 'no' - print 'chosen_name moved from' chosen_spot - print 'And then they saw it was just' chosen_cause - print chosen_name 'laughed and went on with their day' - print The End - ``` - 16: - story_text: |- - ### Exercise - Debug this code. Good luck! - Tip: Make sure that you only see your score once in the end। - example_code: | - **Warning! This code needs to be debugged!** - ``` - country = ['The Netherlands', 'Poland', 'Turkey', 'Zimbabwe', 'Thailand', 'Brasil', 'Peru', 'Australia', 'India', 'Romania' ] - capitals = 'Amsterdam', 'Warshaw' 'Istanbul', 'Harare', 'Bangkok', 'Brasilia', 'Lima', 'Canberra', 'New Delhi', 'Bucharest' - score = 0 - for i in range 0 to 10 - answer = ask 'What's the capital of ' countries[i] - correct = capital[i] - if answer = correct - print 'Correct!' - score = score + 1 - else - print 'Wrong,' capitals[i] 'in the capital of' countries[i] - print 'You scored ' score ' out of 10' - - ``` - 17: - example_code: | - **Warning! This code needs to be debugged!** - ``` - define food_order - toppings = ask 'pepperoni, tuna, veggie or cheese?' - size = ask 'big, medium or small?' - number_of_pizza = ask 'How many these pizzas would you like?' - - print 'YOU ORDERED' - print number_of_pizzas ' size ' topping ' pizza' - - define drinks_order - drink = ask 'water, coke, icetea, lemonade or coffee?' - number_of_drinks = ask 'How many of these drinks would you like?' - - print 'YOU ORDERED' - print number_of_drinks ' ' drink - - 'Welcome to Hedy pizza' - more_food = ask 'Would you like to order a pizza?' - while more_food = 'yes' - return food_order - more_food = ask 'Would you like to order a pizza?' - more_drinks = ask 'Would you like to order some drinks?' - while more_drinks == 'yes' - call drink_order - more_drinks == ask 'Would you like to order more drinks?' - - - print 'Thanks for ordering!' - ``` - 18: - example_code: | - **Warning! This code needs to be debugged!** - ``` - animals = ['pig', 'dog', 'cow'] - sounds = ['oink', 'woof', 'moo'] - for i in range 1 to 3 - animal = animals[i] - sound = sounds[i] - print 'Old MacDonald had a farm' - print 'E I E I O!' - print 'and on that farm he had a ' animal - print 'E I E I O!' - print 'with a ' sound sound ' here' - print 'and a ' sound sound ' there' - print 'here a ' sound - print 'there a ' sound - print 'everywhere a ' sound sound - ``` default: levels: 1: @@ -581,1452 +7,18 @@ adventures: story_text: 'আপনি এখন এই নির্দেশ গুলোর ব্যবহার, করতে পারেন ' 4: story_text: স্তর 3 তিনে `ask` ঠিক একই ভাবেই কাজ করবে, কিন্তু `print` এখন বদলে গেছে যে বাক্যটি আপনি print করতে চান সেটি কোটেশন চিহ্নের ভেতরে লিখতে হবে - example_code: | - ``` - print 'You need to use quotation marks from now on!' - answer is ask 'What do we need to use from now on?' - print 'We need to use ' answer - ``` 5: story_text: স্তর 3 তিনের মতই `ask` আর `print` ঠিক একই ভাবেই কাজ করবে | স্তর 4 চার থেকে `if` যুক্ত হয়ে যায় - example_code: | - ``` - name {is} {ask} 'what is your name?' - {if} name {is} Hedy {print} 'nice' {else} {print} 'boo!' - ``` 6: story_text: | স্তর 4 চার এবং পাঁচে `ask`, `print` এবং `if` ঠিক একই ভাবেই কাজ করবে. স্তর 5 ছয়ে একটা নতুন নির্দেশ যুক্ত হয়ে যায়.. আপনি এখন গণণা করতে পারবেন - example_code: | - ``` - {print} '5 plus 5 is ' 5 + 5 - {print} '5 minus 5 is ' 5 - 5 - {print} '5 {times} 5 is ' 5 * 5 - ``` 7: story_text: স্তর 4 & 5 চারের মতই {ask}, {if} আর {print} ঠিক একই ভাবেই কাজ করবে | স্তর 6 থেকে “পুনরাবৃত্তি” যুক্ত হয়ে যায় “পুনরাবৃত্তি” ব্যবহার করতে পারেন যে কোন বাক্য একাধিকবার এক্সিকিউট করার জন্যে - example_code: | - ``` - {repeat} 3 {times} {print} 'Hedy is fun!' - ``` 8: story_text: "ask এবং print ঠিক একই ভাবেই কাজ করবে. কিন্তু if এবং repeat পরিবর্তিত হয়েছে! আপনি এখন কোডের গ্রুপ গুলোকে একসাথে এক্সিকিউট করতে পারেন , তবে আপনাকে কোডটিকে ইন্ডেণ্ট করতে হবে . তার মানে লাইনের শুরুতে চারটা স্পেশ দেওয়া. একটি লাইনের ব্লক তৈরি করেতে চাইলেও ঠিক একই কাজ করতে হবে\tif আপনি একটি `পুনরাবৃত্তি` এবং একটি `if ` একত্রিত করতে চান আপনাকে প্রত্রেকটি ব্লক ইন্ডেণ্ট করতে হবে. আরও বিশদের জন্যে উদাহরণ কোডটি দেখুন!\n" example_code: | ``` {repeat} 5 {times} - {print} 'Hello everyone' - {print} 'This is all repeated 5 times' - ``` - - print 'ওহে বন্ধুরা' - print 'এটি পাঁচ বার মুদ্রণ করা হবে' - 10: - story_text: |- - In this level we learn a new code called `{for}`. With `{for}` you can make a list and use all elements. - `{for}` creates a block, like `{repeat}` and `{if}` so all lines in the block need to start with spaces. - example_code: | - ``` - animals {is} dog, cat, blobfish - {for} animal {in} animals - {print} 'I love ' animal - ``` - 12: - story_text: |- - **Decimal numbers** - So far, Hedy did not allow for decimal numbers like 1.5, but now we do allow that. Note that computers use the `.` for decimal numbers. - example_code: | - ``` - {print} 'Two and a half plus two and a half is...' - {print} 2.5 + 2.5 - ``` - - {print} 2.5 + 2.5 - 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!' - ``` - 14: - story_text: | - We are going to learn more new items. You might know them already from mathematics, the `<` and `>`. - The `<` checks if the first number is smaller than the second, for example `age < 12` checks if `age` {is} smaller than 12. - If you want to check if the first number is smaller or equal to the second, you can use `<=`, for example `age <= 11`. - The `>` checks if the first number is bigger than the second, for example `points > 10` checks if `points` is larger than 10. - If you want to check if the first number is bigger or equal to the second, you can use `>=`, for example `points >= 11`. - You use these comparisons in an `{if}`, like this: - example_code: | - ``` - age = {ask} 'How old are you?' - {if} age > 12 - {print} 'You are older than I am!' - ``` - - {if} age < 13 - {print} 'You are younger than me!' - {else} - {print} 'You are older than me!' - 15: - story_text: |- - We are going to learn a new loop, the `{while}` loop! We continue the loop as long as the statement is true. - So don't forget to change the value in the loop. - - In the example code, we continue until a correct answer has been given. - If the correct answer is never given, the loop never ends! - example_code: | - ``` - answer = 0 - {while} answer != 25 - answer = {ask} 'What is 5 times 5?' - {print} 'A correct answer has been given' - ``` - 16: - story_text: |- - We are going to make lists the Python way, with square brackets around the lists! We also keep the quotation marks around each item like we have learned in previous levels. - You can use the square brackets as well to point out a place in the lists. - example_code: | - ``` - friends = ['Ahmed', 'Ben', 'Cayden'] - {print} friends[1] ' is the first friend on the list.' - {print} friends[2] ' is the second friend on the list.' - {print} friends[3] ' is the third friend on the list.' - #now we will match 2 lists using the variable i - lucky_numbers = [15, 18, 6] - {for} i {in} {range} 1 {to} 3 - {print} friends[i] 's lucky number is ' lucky_numbers[i] - ``` - 17: - story_text: |- - Now we are going to change indentation a little bit. Every time that we need an indentation, we need `:` at the line before the indentation. - - In this level you can also use a new command: `{elif}`. `{elif}` is short for `{else} {if}` and you need it when you want to make 3 (or more!) options. - Check it out! - 18: - story_text: |- - We arrived at real Python code! That means we need to use parentheses with {print} and {range} from now on. - {print}('My name is ', naam) - dice: - levels: - 3: - example_code: | - ``` - choices {is} 1, 2, 3, 4, 5, earthworm - {print} choices {at} {random} - ``` - 4: - story_text: | - In this level we can make sentences with the die value in the sentence, with quotes of course. - This time the sample code is not quite complete. Can you finish the code? - 5: - story_text: | - You can also make a die again in this level using the `{if}`. - Complete the sample code so that the code says "You can stop throwing" once you have thrown an earthworm. - - But maybe you want to recreate a die from a completely different game. That's fine too! Then make up your own reaction. Eg 'yes' for 6 and 'pity' for something {else}. - example_code: | - ``` - choices {is} 1, 2, 3, 4, 5, earthworm - throw {is} _ - {print} 'you have' _ 'thrown' - {if} _ {is} earthworm {print} 'You can stop throwing.' _ {print} 'You have to hear it again!' - ``` - 6: - story_text: | - You can also make an Earthworm die again in this, but now you can also calculate how many points have been rolled. - You may know that the worm counts 5 points for Earthworms. Now after a roll you can immediately calculate how many points you have thrown. - This is the code to calculate points for one die: - example_code: | - ``` - choices = 1, 2, 3, 4, 5, earthworm - points = 0 - throw = choices {at} {random} - {print} 'you threw' throw - {if} throw {is} earthworm points = points + 5 {else} points = points + throw - {print} 'those are' points ' point' - ``` - Can you make the code so that you get the total score for 8 dice? To do that, you have to cut and paste some lines of the code. - example_code_2: | - Did you manage to calculate the score for 8 dice? That required a lot of cutting and pasting, right? We are going to make that easier in level 7! - 7: - story_text: | - You can also make a die again in level 5. With the `{repeat}` code you can easily roll a whole hand of dice. - Try to finish the sample code! The dashes should contain multiple commands and characters. - - But maybe you want to make a completely different die. Of course you can! - example_code: | - ``` - choices = 1, 2, 3, 4, 5, earthworm - {repeat} _ _ {print} _ _ _ - ``` - 10: - story_text: | - Is everybody taking too long throwing the dice? In this level you can let Hedy throw all the dice at once! - example_code: | - ``` - players = Ann, John, Jesse - choices = 1, 2, 3, 4, 5, 6 - {for} player {in} players - {print} player ' throws ' choices {at} {random} - {sleep} - ``` - dishes: - description: Use the computer to see who does the dishes (Start at level 2) - levels: - 3: - story_text: | - Do you always disagree at home about who should wash the dishes or change the litter box today? - Then you can let the computer choose very fairly. You can program that in this level! - You first make a list of the members of your family. Then choose '{at} {random}' from the list. - example_code: | - ``` - people {is} mom, dad, Emma, Sophie - {print} people {at} {random} - ``` - story_text_2: | - Don't feel like doing the dishes yourself? Hack the program to remove your name from the list. - 4: - story_text: | - With quotation marks you can make your dishwashing planning more beautiful. - This time the sample code is not quite complete. - - Can you complete the code by filling the blanks? Every blank must be replaced with one word of symbol. - - Tip: Don't forget the quotation marks! - 5: - story_text: | - With the `{if}` you can now have more fun with choice in the program. You can have your program respond to the choice that the computer has made. - - Can you finish the code so that it prints 'too bad' when it is your turn and otherwise 'yes!'? - Don't forget the quotes! - example_code: | - ``` - people {is} mom, dad, Emma, Sophie - dishwasher {is} people {at} {random} - {if} dishwasher {is} Sophie {print} _ too bad I have to do the dishes _ {else} {print} 'luckily no dishes because' _ 'is already washing up' - ``` - 6: - story_text_2: | - If you are extremely unlucky the previous program might choose you to to the dishes for the whole week! That's not fair! - To create a fairer system you can use the `{remove}` command to remove the chosen person from the list. This way you don't have to do the dishes again untill everybody has had a turn. - - Monday and tuesday are ready for you! Can you add the rest of the week? - And... can you come up with a solution for when your list is empty? - example_code_2: | - ``` - people = mom, dad, Emma, Sophie - dishwasher = people {at} {random} - {print} 'Monday the dishes are done by: ' dishwasher - {remove} dishwasher {from} people - dishwasher = people {at} {random} - {print} 'Tuesday the dishes are done by: ' dishwasher - {remove} dishwasher {from} people - dishwasher = people {at} {random} - ``` - 7: - story_text: | - With the `{repeat}` you can repeat pieces of code. You can use this to calculate who will be washing dishes for the entire week. - example_code: | - ``` - people = mom, dad, Emma, Sophie - {repeat} _ _ {print} 'the dishwasher is' _ - ``` - 10: - story_text: | - In this level you could make an even better dish washing shedule. - elif_command: - description: elif - levels: - 17: - example_code: | - ``` - prices = ['1 million dollars', 'an apple pie', 'nothing'] - your_price = prices[{random}] - {print} 'You win ' your_price - {if} your_price == '1 million dollars' : - {print} 'Yeah! You are rich!' - {elif} your_price == 'an apple pie' : - {print} 'Lovely, an apple pie!' - {else}: - {print} 'Better luck next time..' - ``` - for_command: - description: for command - levels: - 10: - story_text: |- - ## For - In this level we learn a new code called `{for}`. With `{for}` you can make a list and use all elements. - `{for}` creates a block, like `{repeat}` and `{if}` so all lines in the block need to start with 4 spaces। - 11: - story_text: |- - In this level, we add a new form of the `{for}`. In earlier levels, we used `{for}` with a list, but we can also use `{for}` with numbers. - We do that by adding a variable name, followed by `{in}` `{range}`. We then write the number to start at, `{to}` and the number to end at. - Try the example to see what happens! In this level again, you will need to use indentations in lines below the `{for}` statements. - fortune: - levels: - 1: - story_text: | - Have you ever been to a carnival and had your future predicted by a fortune teller? Or have you ever played with a magic eight ball? - Then you probably know that they can't really predict your future, but it's still fun to play! - - In the upcoming levels you can learn how to create your own fortune telling machine! - In level 1 you can start off easy by letting Hedy introduce herself as a fortune teller and let her {echo} the players' answers. - Like this: - example_code: | - ``` - {print} Hello, I'm Hedy the fortune teller! - {ask} Who are you? - {print} Let me take a look in my crystal ball - {print} I see... I see... - {echo} Your name is - ``` - story_text_2: | - Hedy now only tells you your name. Can you expand the code so that Hedy can predict more things about you? - Obviously, Hedy isn't a very good fortune teller yet, as she can only repeat the answers that were given by the players! - Take a look in level 2 to improve your fortune teller. - 3: - story_text: | - In the previous levels you've created your first fortune telling machine, but Hedy couldn't really predict anything, only {echo}. - In this level you can use a variable and the `{at} {random}` command to really let Hedy choose an answer for you. Check out this code for instance: - story_text_2: | - Now, Hedy can only answer yes, no or maybe. Can you give Hedy more answer options, like 'definitely' or '{ask} again'. - 4: - example_code: | - ``` - {print} 'Im Hedy the fortune teller!' - question {is} {ask} 'What do you want to know?' - {print} 'This is your question: ' question - answers {is} yes, no, maybe - {print} 'My crystal ball says...' - {sleep} 2 - {print} answers {at} {random} - ``` - 5: - story_text: | - In this level you'll learn to (secretly) tip the odds in your favor, when using the fortune teller! - By using `{if}` and `{else}` you can make sure that you will always get a good fotune, while other people might not. - Check out this example to find out how. - example_code: | - ``` - {print} 'Im Hedy the fortune teller!' - {print} 'I can predict {if} youll win the lottery tomorrow!' - person {is} {ask} 'Who are you?' - {if} person {is} Hedy {print} 'You will definitely win!🤩' {else} {print} 'Bad luck! Someone {else} will win!😭' - ``` - 6: - story_text: | - In this level you can use math in your predictions as a fortune teller. This allows you to make up (silly) formulas to calculate the future. - For example you could calculate how rich you'll get or how many kids you will have when you grow up. - example_code: | - ``` - {print} 'I am Hedy the fortune teller!' - {print} 'I can predict how many kids youll get when you grow up!' - age = {ask} 'How old are you?' - siblings = {ask} 'How many siblings do you have?' - length = {ask} 'How tall are you in centimetres?' - kids = length / age - kids = kids - siblings - {print} 'You will get ...' - {sleep} - {print} kids ' kids!' - ``` - - If the previous example wasn't silly enough for you, take a look at this one! - - ``` - {print} 'Im Hedy the silly fortune teller!' - {print} 'I will predict how smart you are!' - football = {ask} 'On a scale 1-10 how much do you love football?' - bananas = {ask} 'How many bananas did you eat this week?' - hygiene = {ask} 'How many times did you wash your hands today?' - result = bananas + hygiene - result = result * football - {print} 'You are ' result ' percent smart.' - ``` - 7: - story_text: | - In this level you can use the `{repeat}` command to make your machine tell multiple fortunes at once. - example_code: | - ``` - {print} 'Im Hedy the fortune teller!' - {print} 'You can {ask} 3 questions!' - {repeat} 3 {times} question = {ask} 'What do you want to know?' - answer = yes, no, maybe - {repeat} 3 {times} {print} 'My crystal ball says... ' answer {at} {random} - ``` - 8: - story_text: | - In the previous levels you've learned how to use repeat to make the fortune teller answer 3 questions in a row, but we had a problem with printing the questions. - Now that problem is solved, because of the new way of using the repeat command. - In the next example you can have your fortune teller {ask} 3 questions and also print them! - example_code: | - ``` - {print} 'I am Hedy the fortune teller!' - {print} 'You can {ask} me 3 questions.' - answers = yes, no, maybe - {repeat} 3 {times} - question = {ask} 'What do you want to know?' - {print} question - {sleep} - {print} 'My crystal ball says...' answers {at} {random} - ``` - 10: - story_text: | - In this level you'll learn how to program the game MASH (mansion, apartement, shack, house). In this game you can predict for all the players at once, what their future will look like. - example_code: | - ``` - houses = mansion, apartment, shack, house - loves = nobody, a royal, their neighbour, their true love - pets = dog, cat, elephant - names = Jenna, Ryan, Jim - {for} name {in} names - {print} name ' lives in a ' houses {at} {random} - {print} name ' will marry ' loves {at} {random} - {print} name ' will get a ' pets {at} {random} ' as their pet.' - {sleep} - ``` - 12: - story_text: | - In this level you can make your fortunes multiple words. Like in this example below: - example_code: | - ``` - fortunes = 'you will be rich', 'you will fall in love', 'you will slip on a banana peel' - {print} 'I will take a look in my crystall ball for your future.' - {print} 'I see... I see...' - {sleep} - {print} fortunes {at} {random} - ``` - functions: - levels: - 12: - example_code: | - ``` - sides = 'left', 'right' - limbs = 'hand', 'foot' - colors = 'red', 'blue', 'green', 'yellow' - - {define} turn - chosen_side = sides {at} {random} - chosen_limb = limbs _ - chosen_color = colors _ - {print} chosen_side ' ' chosen_limb ' on ' chosen_color - - {print} 'Lets play a game of Twister!' - {for} i {in} {range} 1 to _ - {call} turn - {sleep} 2 - ``` - 13: - story_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. - - For example in this code we've programmed the first verse of the song 'My Bonnie is over the ocean'. - In this example code the argument `place` is used. Place is a variable that is only used in the function, so an argument. - To use `place` we have programmed the line `define song with place`. - When the function is called, computer will replace the argument `place`, with the piece of text after `call song with`. - - ### Exercise - The next verse of this song goes: - - Last night as I lay on my pillow - Last night as I lay on my bed - Last night as I lay on my pillow - I dreamed that my Bonnie is dead - - Can you program this verse in the same way as the example? - 14: - example_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?' - - new_price = _ calculate_new_price {with} old_price, _ - {print} 'The new price is ' new_price ' dollar' - ``` - haunted: - levels: - 1: - story_text: | - In this adventure you are working towards making a game in which you have to escape from a haunted house by picking the correct door. - If you pick the right door you'll survive, but {if} not a terrible monster might... - - In level 1 we start our haunted house game by making up a scary story and {ask} the player what monster they'll see in the haunted house. - story_text_2: | - Can you finish the scary story? Or make up your own haunted house story? - 2: - example_code: | - ``` - monster_1 {is} 👻 - monster_2 {is} 🤡 - monster_3 {is} 👶 - {print} You enter the haunted house. - {print} Suddenly you see a monster_1 - {print} You run into the other room, but a monster_2 is waiting there for you! - {print} Oh no! Quickly get to the kitchen. - {print} But as you enter monster_3 attacks you! - ``` - example_code_2: | - ``` - monster_1 {is} _ - monster_2 {is} _ - monster_3 {is} _ - {print} You enter the haunted house. - {print} Suddenly you see a monster_1 - {print} You run into the other room, but a monster_2 is waiting there for you! - {print} Oh no! Quickly get to the kitchen. - {print} But as you enter monster_3 attacks you! - ``` - 3: - story_text: | - In the previous levels you've made an introduction to your haunted house game, but as you might have noticed the story would always have a dreadful end. - In this level you can make your story more interactive by changing the outcome of the game; sometimes you'll get eaten, sometimes you'll escape! - Let Hedy decide randomly! - 4: - story_text: | - In this level you learn how to use quotation marks in your games. - Can you make your Haunted House level 4 proof? - example_code: | - ``` - {print} _Escape from the haunted house!_ - {print} _There are 3 doors in front of you..._ - choice {is} {ask} _Which door do you choose?_ - {print} _You picked door ..._ choice - monsters {is} a zombie, a vampire, NOTHING YOUVE ESCAPED - {print} _You see..._ - {sleep} - {print} monsters {at} {random} - ``` - 5: - story_text: | - Up until this level the haunted house game always asked the player to choose a door, but as you might have noticed, they didn't really have to answer correctly. - If the player filled in a completely random answer, the game would still work and the player might even win (despite not picking a door). - In this level you can only win the game by picking the same door Hedy picked randomly. - example_code: | - ``` - {print} 'Escape from the haunted house!' - {print} 'There are 3 doors in front of you...' - doors {is} 1, 2, 3 - monsters {is} werewolf, mummy, vampire, zombie - chosen_door {is} {ask} 'Which door do you choose?' - {print} 'You chose door...' chosen_door - {sleep} - correct_door {is} doors {at} {random} - {if} chosen_door {is} correct_door {print} 'Great! Youve escaped!' - {else} {print} 'Oh no! You are being eaten by a...' monsters {at} {random} - ``` - 9: - story_text: | - In this level you can use nesting, which allows you to make the haunted house even more interactive! - - Now it's very hard to win this game, can you make it easier to win? - For example by only having 1 wrong door and 2 correct doors instead of 1 correct door and 2 wrong ones? - 11: - story_text: | - In this level we've changed the repeat command and we've added a line to our haunted house that tells the player in which room they are. - example_code: | - ``` - {print} 'Escape from the Haunted House!' - player {is} alive - doors = 1, 2, 3 - monsters = zombie, vampire, giant spider - {for} i {in} {range} 1 {to} 3 - {if} player {is} alive - correct_door = doors {at} {random} - {print} 'Room ' i - {print} 'There are 3 doors in front of you...' - chosendoor = {ask} 'Which door do you choose?' - {if} chosendoor {is} correct_door - {print} 'No monsters here!' - {else} - {print} 'You are eaten by a ' monsters {at} {random} - player = dead - {else} - {print} 'GAME OVER' - {if} player {is} alive - {print} 'Great! You survived!' - ``` - if_command: - description: Introducing the if command - levels: - 9: - story_text: | - In this level you can also put an {if} command inside another {if} command. - in_command: - description: Introducing the in command - levels: - 5: - example_code_2: | - ``` - animals is dog, cow, sheep - answer is ask 'What is your favorite animal?' - _ answer _ animals _ 'Mine too!' - _ _ 'My favorite animals are dogs, cows and sheep' - ``` - is_command: - description: introducing is command - levels: - 2: - story_text_2: | - ### Exercise - Time to make your own variables! - In the example code we made an example of the variable `favorite_animal`. In line 1 the variable is set, and in line 2 we haved used the variable in a print command. - Firstly, finish our example by filling in your favorite animal on the blank. Then make at least 3 of these codes yourself. Pick a variable, and set the variable with the {is} command. Then use it with a {print} command, just like we did. - 14: - example_code: | - ``` - age = {ask} 'How old are you?' - {if} age > 12 - {print} 'You are older than I am!' - ``` - example_code_3: | - ``` - name = {ask} 'What is your name?' - {if} name != 'Hedy' - {print} 'You are not Hedy' - ``` - - {if} age < 13 - {print} 'You are younger than me!' - {else} - {print} 'You are older than me!' - language: - levels: - 5: - story_text: | - Make your own program to practice your vocabulary in a new language. - maths: - levels: - 6: - example_code: | - ``` - {print} '5 plus 5 is ' 5 + 5 - {print} '5 minus 5 is ' 5 - 5 - {print} '5 times 5 is ' 5 * 5 - ``` - 12: - story_text: |- - **Decimal numbers** - So far, Hedy did not allow for decimal numbers like 1.5, but now we do allow that. Note that computers use the `.` for decimal numbers। - example_code_2: | - ``` - a = 'Hello ' - b = 'world!' - {print} a + b - ``` - - {print} 2.5 + 2.5 - music: - levels: - 1: - story_text: |- - In this level you'll learn how to use the `{play}` command to play a tune! - - Type `{play}` followed by the note you want to play. The scale goes C-D-E-F-G-A-B. - As you can see there are 7 different letters, but we can play more than just 7 notes. - Type a number between 0 and 9 behind the letter to choose the scale, for example after B4 comes C5. - C0 is the lowest note you can play, B9 is the highest. - - ### Exercise - Try out the example code and then play around with it! Can you create your own melody? - In the next level you'll learn how to play some existing songs। - 2: - story_text: | - ### Exercise - Finish the songs! We have started the codes for some melodies। - story_text_2: As you can see, you can also use the `{sleep}` command to add a little pause in the song। - 6: - story_text: "Instead of playing notes, you can also play numbers now. Simply type `{play} 1` for the lowest note, `{play} 70` for the highest note, or anything in between.\n\n### Exercise\n This calls for musical maths! Try out the example code a couple of times with different starting numbers. \nThen, see if you can compose a song using the numbers.\n" - parrot: - levels: - 1: - story_text_2: | - ### Exercise - Can you make the parrot ask a different question? Fill in the blanks in the example! - 2: - story_text: | - Create your own online pet parrot that will copy you! - example_code: | - ``` - {print} Im Hedy the parrot - name {is} {ask} whats your name? - {print} name - {sleep} - {print} squawk - {sleep} - {print} name - ``` - story_text_2: | - ### Exercise - You can use variables to make the parrot say more than only your name. Can you complete this code? - 3: - story_text: | - Teach your parrot a new word with `{add}`. - example_code: | - ``` - words {is} squawk, Hedy - {print} Train your parrot! - new_word {is} {ask} Which word do you want to teach them? - {add} new_word {to_list} words - {print} 🧒 Say new_word , Hedy! - {print} 🦜 words {at} {random} - ``` - 4: - story_text: | - In this level we have to use quotation marks with the commands `{ask}` and `{print}`. - Can you complete the code by adding quotation marks? - 5: - story_text: | - Reward your parrot {if} it says the correct word! - example_code: | - ``` - words {is} squawk, Hedy - {print} 'Train your parrot!' - new_word {is} {ask} 'Which word do you want to teach them?' - {add} new_word {to_list} words - said_word {is} words {at} {random} - {print} '🧒 Say ' new_word ', Hedy!' - {print} '🦜 ' said_word - {if} said_word {is} new_word {print} '🧒 Great job, Hedy! 🍪' - {else} {print} '🧒 No, Hedy! Say ' new_word - ``` - piggybank: - levels: - 12: - story_text: | - In this adventure you learn how to make a digital piggy bank, to calculate how much money you have and how long you need to save up to buy what you want! - example_code: | - ``` - {print} 'The digital piggy bank' - wish = {ask} 'What would you like to buy?' - price = {ask} 'How much does that cost?' - saved = {ask} 'How much money have you saved already?' - allowance = {ask} 'How much pocket money do you get per week?' - to_save = price - saved - weeks = to_save / allowance - {print} 'You can buy a ' wish ' in ' weeks ' weeks.' - ``` - 14: - example_code: | - ``` - _ calculate_budget with wish, money, allowance - to_save = wish - money - weeks = to_save / allowance - {if} wish _ money - {print} 'You need to save up some more!' - {print} 'Youll need ' weeks ' more weeks.' - {else} - {print} 'Great! You have enough' - {print} 'Lets go shopping!' - - money = {ask} 'How much money have you saved?' - wish = {ask} 'How much money do you need?' - allowance = {ask} 'How much pocket money do you get each week?' - - {call} calculate_budget with _, _, _ - ``` - pressit: - levels: - 9: - story_text: | - Now that you know how to combine statements, you can create a touch type tool with `{pressed}`. - - ### Exercise - Finish the code. Each time a random letter should be chosen, which you have to press. You get a point for a correct press, and and two points deduction for a wrong press. - **(extra)** Clear the screen after each letter, and show the user how many points they have scored. - print_command: - levels: - 18: - story_text: |- - We arrived at real Python code! That means we need to use parentheses with `{print}` and `{range}` from now on. - It also means you can use Hedy code from this level in any Python environment as long as you use the English commands. If you haven't until now, you can switch the toggle in the commands menu to do so। - story_text_2: If you want to print more than one item, you need to separate them by commas। - example_code_2: | - ``` - temperature = 25 - {print}('It is ', temperature, ' degrees outside') - ``` - - {print}('My name is ', name) - random_command: - levels: - 16: - story_text: |- - We are going to make lists the Python way, with square brackets around the lists! We also keep the quotation marks around each item like we have learned in previous levels. - We use square brackets to point out a place in a list. The {at} {random} command can not be used anymore। - repeat_command: - description: repeat command - levels: - 7: - story_text: | - ## Repeat! Repeat! Repeat! - Level 7 adds the `{repeat}` command. `{repeat}` can be used to execute one line of code multiple times. Like this: - - ### Exercise - Play around with the repeat command. Can you make the happy birthday song in only 3 lines of code instead of 4 now? - 9: - story_text: | - Great job! You've reached another new level! In the previous level you've learned to use multiple lines of code in an {if} or {repeat} command. But you can't yet combine the two... - Good news! In this level you will be allowed to put an {if} inside an {if}, or inside a {repeat} command. Putting a block of code inside another block of code is called nesting. ``` Putting a block of code inside another block of code is called nesting. - example_code: | - ``` - answer = {ask} 'Are you ready to learn something new?' - {if} answer {is} yes - {print} 'Great! You can learn to use the repeat command in the if command!' - {print} 'Hooray!' - {print} 'Hooray!' - {print} 'Hooray!' - {else} - {print} 'Maybe you should practice some more in the previous level' - repeat_command_2: - description: repeat command 2 - levels: - 7: - story_text_2: | - Another interesting thing you can so with the `{repeat}` command is using variables to set the amount of times something should be repeated. In the example code you can see that we first ask the person how old they are. - Then, in line 3, the question is repeated 'age' times. So we have used the variable 'age' with the `{repeat}` command. - restaurant: - levels: - 1: - story_text_2: | - Can you think of more lines to add to your restaurant code? For example, can you {ask} the guests what they'd like to drink, tell them the price, or wish them a pleasant meal? - example_code_2: | - ``` - {print} Welcome to Hedy's restaurant 🍟 - {ask} What would you like to order? - {echo} So you would like to order - {print} Thanks you for your order! - {print} It's on its way! - ``` - 2: - story_text: | - In level 2 you could expand your restaurant by using variables. In level 1 Hedy could only {echo} the order once and only remember the last thing that was ordered. - Now you can use variables and Hedy can remember both the food and the drinks! - example_code: | - ``` - {print} Welcome to Hedy's restaurant! - {print} Today we're serving pizza or lasagna. - food {is} {ask} What would you like to eat? - {print} Great choice! The food is my favorite! - topping {is} {ask} Would you like meat or veggies on that? - {print} food with topping is on its way! - drinks {is} {ask} What would you like to drink with that? - {print} Thank you for your order. - {print} Your food and drinks will be right there! - ``` - story_text_2: | - ### Exercise - Can you make this code more elaborate? For example by adding drinks to the order? Or...? - 3: - example_code: | - ``` - {print} Welcome to Hedy's Random Restaurant! - {print} The only restaurant that will randomly choose your meal and its price for you! - starters {is} salad, soup, carpaccio - mains {is} pizza, brussels sprouts, spaghetti - desserts {is} brownies, ice cream, french cheeses - drinks {is} cola, beer, water - prices {is} 1 dollar, 10 dollars, 100 dollars - {print} You will start with: starters {at} {random} - {print} Then we'll serve: mains {at} {random} - {print} And as dessert: desserts {at} {random} - {print} You will get a drinks {at} {random} to drink - {print} That will be: prices {at} {random} - {print} Thank you and enjoy your meal! - ``` - story_text_2: | - Does your costumer have any allergies or do they dislike certain dishes? Then you can use the `{remove}`command to remove it from your menu. - example_code_2: | - ``` - {print} Mystery milkshake - flavors {is} strawberry, chocolate, vanilla - allergies {is} {ask} Are you allergic to any falvors? - {remove} allergies {from} flavors - {print} You get a flavors {at} {random} milkshake - ``` - 4: - story_text: | - ### Exercise - Add the quotation marks to this code to make it work! Be careful: variables should not be in quotation marks. - Then, use the `{clear}` command to only show one line at a time in your output screen. - - ### Exercise 2 - Go back to the previous level and copy your restaurant code. Make the code work in this level by adding quotation marks in the right spots and add some `{clear}` commands. - 5: - story_text: | - In this level the {if} command allows you to {ask} your customers questions and give different responses to the answers. - In the example below, you see that you can {ask} the customer {if} they want to hear the specials and Hedy can respond accordingly. - example_code: | - ``` - {print} 'Welcome to Hedys restaurant!' - special {is} {ask} 'Would you like to hear our specials today?' - {if} special {is} yes {print} 'Todays special is chicken piri piri and rice.' {else} {print} 'No problem.' - food {is} {ask} 'What would you like to eat?' - {print} 'One ' food ', coming right up!' - drink {is} {ask} 'What would you like to drink with that?' - {if} drink {is} cola {print} 'Im sorry, we are out of cola!' {else} {print} 'Great choice!' - anything {is} {ask} 'Would you like anything {else}?' - {print} 'Let me repeat your order...' - {print} 'One ' food - {if} drink {is} cola {print} 'and...' {else} {print} 'One ' drink - {if} anything {is} no {print} 'Thats it!' {else} {print} 'One ' anything - {print} 'Thank you for your order and enjoy your meal!' - ``` - 6: - story_text: | - In this level you can use maths to calculate the total price of your customer's order, which can make your virtual restaurant more realistic. - 7: - story_text: | - In this level you've learned how to use the {repeat} command to repeat a line of code a certain amount of times. - You can use that in your restaurant to {ask} multiple people what they'd like to eat. Like this: - example_code: | - ``` - {print} 'Welcome to Hedys restaurant!' - people = {ask} 'How many people are joining us today?' - {repeat} people times food = {ask} 'What would you like to eat?' - {print} 'Thanks for your order! Its coming right up!' - ``` - 9: - story_text: | - In this level you can use nesting to make your restaurant more realistic and more fun! - For example you would {ask} for sauce {if} somebody orders fries, but you wouldn't {if} someone orders pizza! - Check out the example, and try this at your own virtual restaurant! - example_code: | - ``` - {print} 'Welcome to Hedys restaurant!' - people = {ask} 'How many people will be joining us today?' - {print} 'Great!' - price = 0 - {repeat} people {times} - food = {ask} 'What would you like to order?' - {print} food - {if} food {is} fries - price = price + 3 - sauce = {ask} 'What kind of sauce would you like with your fries?' - {if} sauce {is} no - {print} 'no sauce' - {else} - price = price + 1 - {print} 'with ' sauce - {if} food {is} pizza - price = price + 4 - {print} 'That will be ' price ' dollar' - {print} 'Enjoy your meal!' - ``` - 10: - story_text: | - In this level you'll learn how to easily {ask} your guests' orders in a short code. - example_code: | - ``` - courses = appetizer, main course, dessert - {for} course {in} courses - food = {ask} 'What would you like to eat as your ' course '?' - {print} food ' will be your ' course - ``` - example_code_2: | - ``` - courses = appetizer, main course, dessert - names = Timon, Onno - {for} name {in} names - {for} course {in} courses - food = {ask} name ', what would you like to eat as your ' course '?' - {print} name ' orders ' food ' as their ' course - ``` - 11: - story_text: | - We can use the `{for} i {in} {range} 1 {to} 5` to {print} the orders from multiple customers in an orderly manner. - example_code: | - ``` - {print} 'Welcome to Restaurant Hedy!' - people = {ask} 'For how many people would you like to order?' - {for} i {in} {range} 1 {to} people - {print} 'Order number ' i - food = {ask} 'What would you like to eat?' - {print} food - {if} food {is} fries - sauce = {ask} 'What kind of sauce would you like with that?' - {print} sauce - drinks = {ask} 'What would you like to drink?' - {print} drinks - price = 4 * people - {print} 'That will be ' price ' dollars, please!' - ``` - 12: - story_text: | - From this level on you can use decimal numbers to make you menu more realistic. - example_code: | - ``` - price = 0 - food = {ask} 'What would you like to order?' - drink = {ask} 'What would you like to drink?' - {if} food {is} 'hamburger' - price = price + 6.50 - {if} food {is} 'pizza' - price = price + 5.75 - {if} drink {is} 'water' - price = price + 1.20 - {if} drink {is} 'soda' - price = price + 2.35 - {print} 'That will be ' price ' dollar, please' - ``` - 13: - story_text: | - In this level we can use the new commands to upgrade our restaurant. - We use `{and}` to see {if} two things are both the case. - example_code: | - ``` - price = 10 - food = {ask} 'What would you like to eat?' - drinks = {ask} 'What would you like to drink?' - {if} food {is} 'sandwich' {and} drinks {is} 'juice' - {print} 'Thats our discount menu' - price = price - 3 - {print} 'That will be ' price ' dollars' - ``` - rock: - default_save_name: Rock - levels: - 1: - example_code: | - ``` - {print} what do you choose? - {ask} choose from rock, paper or scissors - {echo} so your choice was: - ``` - Instead of using words, you could also use emojis of course: ✊✋✌ - 2: - story_text: | - In this level you can practise using the variables, so that you can make the rock, paper, scissors game in the next level! - example_code: | - ``` - choice {is} _ - {print} I choose choice - ``` - 3: - example_code: | - ``` - choices {is} rock, paper, scissors - {print} choices {at} {random} - ``` - story_text_2: | - ### Exercise - Now you only have one player, so can you add a second player? - You can even use variables to name player 1 and player 2. - example_code_2: | - ``` - choices {is} rock, paper, scissors - {print} player 1 chooses... choices {at} {random} - {print} player 2 _ - ``` - 5: - story_text: | - In this level we can determine who won. - For that you need the new `{if}` code. - - Save your choice with the name of choice and the choice of computer as computer choice. - Then you can use `{if}` to see {if} they are the same or different. - Will you finish the code? - example_code: | - ``` - options {is} rock, paper, scissors - computer_choice {is} _ - choice {is} {ask} 'What do you choose?' - {print} 'you chose ' _ - {print} 'computer chose ' _ - {if} _ {is} _ {print} 'tie!' {else} {print} 'no tie' - ``` - - Fill in the correct code on the blanks to see {if} it is a draw. - 9: - story_text: | - In this level you can program the whole rock, paper, scissors game by nesting the {if}-commands. Can you finish the code? - example_code: | - ``` - choices = rock, paper, scissors - your_choice = {ask} 'What do you choose?' - {print} 'You choose ' your_choice - computer_choice = choices {at} {random} - {print} 'The computer chooses ' computer_choice - {if} computer_choice {is} your_choice - {print} 'Tie' - {if} computer_choice {is} rock - {if} your_choice {is} paper - {print} 'You win!' - {if} your_choice {is} scissors - {print} 'You lose!' - # finish this code - ``` - 10: - story_text: | - Feeling too lazy to play the game yourself? Let Hedy play it for you! - example_code: | - ``` - choices = rock, paper, scissors - players = Marleen, Michael - {for} player {in} players - {print} player ' chooses ' choices {at} {random} - ``` - 13: - story_text: | - With the `{and}` command you can shorten your rock, paper, scissors code! Check out the example code below and try to finish it. - example_code: | - ``` - options = 'rock', 'paper', 'scissors' - your_choice = {ask} 'What do you choose?' - computer_choice = options {at} {random} - {print} 'You choose ' your_choice - {print} 'The computer chooses ' computer_choice - {if} computer_choice {is} your_choice - {print} 'Tie' - {if} computer_choice {is} 'rock' {and} your_choice {is} 'paper' - {print} 'You win!' - {if} computer_choice {is} 'rock' {and} your_choice {is} 'scissors' - {print} 'The computer wins!' - ``` - 15: - example_code: | - ``` - won = 'no' - options = 'rock', 'paper', 'scissors' - {while} won == 'no' - your_choice = {ask} 'What do you choose?' - computer_choice = options {at} {random} - {print} 'you chose ' your_choice - {print} 'the computer chose ' computer_choice - {if} computer_choice == your_choice - {print} 'Tie!' - {if} computer_choice == 'rock' {and} your_choice == 'scissors' - {print} 'You lose!' - {if} computer_choice == 'rock' {and} your_choice == 'paper' - {print} 'You win!' - won = 'yes' - ``` - rock_2: - levels: - 2: - story_text: | - Now that you have learned how to use the `{ask} command, you can make your rock, paper, scissors code interavtive too! - - ### Exercise - Make the rock, paper, scissors code interactive by adding the `{ask}` command and a question to your rock, paper, scissors code. - example_code: | - ``` - choice is _ - {print} I choose choice - ``` - secret: - levels: - 12: - story_text: | - In this adventure you can create your own super spy code. Encode a message that only the right agent can decipher. - If the enemy tries to crack the code, they will get some false info to waste their time. - example_code: | - ``` - name {is} {ask} 'What is your name?' - {if} name {is} '_' - a {is} 'Go to the airport ' - {else} - a {is} 'Go to the trainstation ' - password {is} {ask} 'What is the password?' - {if} password {is} _ - b {is} 'tomorrow at 02.00' - {else} - b {is} 'today at 10.00' - {print} _ _ _ - ``` - 13: - story_text: | - The code you made in the previous level can be made a lot easier in this one with the `{and}` command. - sleep_command: - description: introducing sleep command - levels: - 2: - story_text: | - ## The sleep command - Another new command in this level is `{sleep}`, which pauses your program for a second. If you type a number behind the {sleep} command, the program pauses for that amount of seconds. - songs: - levels: - 6: - story_text: | - Songs often contain a lot of repetition. Sometimes the repetition is also based on counting. - For example, in the well-known song 'Bottles of beer'. You can program that song with a little math. - example_code: | - ``` - verse = 99 - {print} verse ' bottles of beer on the wall' - {print} verse ' bottles of beer' - {print} 'Take one down, pass it around' - verse = verse - 1 - {print} verse ' bottles of beer on the wall' - ``` - - You can now repeat lines 2 to 9 as many times as you want by copying the lines. - example_code_2: | - ``` - number = 6 - number = number - 1 - print number ' little monkeys jumping on the bed' - print 'One fell off and bumped his head' - print 'Mama called the doctor and the doctor said' - print 'NO MORE MONKEYS JUMPING ON THE BED!' - sleep - ``` - 7: - story_text: | - Songs often contain a lot of repetition. For example... Baby Shark! If you sing it, you keep singing the same thing: - - Baby Shark tututudutudu
- Baby Shark tututudutudu
- Baby Shark tututudutudu
- Baby Shark - - You can make this song much shorter with a `{repeat}`! Can you finish the code? - example_code: | - ``` - {repeat} _ _ {print} 'Baby Shark tututudutudu' - {print} 'Baby Shark' - ``` - - After Baby Shark you can of course also program other songs. There are many songs with repetition. - 8: - story_text: | - In a previous level you've programmed the song 'Bottles of beer'. You made one verse and then had to copy the verses 99 times. In level 7 you can repeat the song 99 times, just by adding one simple line! - example_code: | - ``` - verse = 99 - {repeat} 99 {times} - {print} verse ' bottles of beer on the wall' - {print} verse ' bottles of beer' - {print} 'Take one down, pass it around' - verse = verse - 1 - {print} verse ' bottles of beer on the wall' - ``` - 10: - story_text: | - In this level you can easily make the childrens' song 'Five little monkeys'. Can you make the last chorus? - You can also make the whole baby shark song (including all the other sharks in the family) in only 6 lines! - Or you can make Old MacDonald with all the different animals. - example_code: | - ``` - monkeys = 5, 4, 3, 2 - {for} monkey {in} monkeys - {print} monkey ' little monkeys jumping on the bed' - {print} 'One fell off and bumped his head' - {print} 'Mama called the doctor and the doctor said' - {print} 'NO MORE MONKEYS JUMPING ON THE BED!' - ``` - - ``` - sharks = baby, mommy, daddy, grandma, grandpa - {for} shark {in} sharks - {print} shark 'tututututudu' - {print} shark 'tututututudu' - {print} shark 'tututututudu' - {print} shark - ``` - ``` - animals = pig, dog, cow - {for} animal {in} animals - {if} animal {is} pig - sound = oink - {if} animal {is} dog - sound = woof - {if} animal {is} cow - sound = moo - {print} 'Old MacDonald had a farm' - {print} 'E I E I O!' - {print} 'and on that farm he had a ' animal - {print} 'E I E I O!' - {print} 'with a ' sound sound ' here' - {print} 'and a ' sound sound ' there' - {print} 'here a ' sound - {print} 'there a ' sound - {print} 'everywhere a ' sound sound - ``` - story_text_2: | - ### Exercise 2 - Print the song Five little moneys jumping on the bed. Look up the text if you don't remember. - - **(extra)** Print the song Old MacDonald had a farm, and make sure all animals make a different sound, using an `{if}`. - 11: - story_text: | - In this level you can use the `{for} i {in} {range}` command to make songs that use counting. - example_code: | - ``` - {for} i {in} {range} 5 {to} 1 - {print} i ' little monkeys jumping on the bed' - {print} 'One fell off and bumped his head' - {print} 'Mama called the doctor and the doctor said' - {if} i {is} 1 - {print} 'PUT THOSE MONKEYS RIGHT TO BED!' - {else} - {print} 'NO MORE MONKEYS JUMPING ON THE BED!' - ``` - songs_2: - levels: - 12: - example_code: | - ``` - {define} twinkle - {print} 'Twinkle' - {print} '...' - - {call} twinkle - {print} 'Up above the world so high' - {print} 'Like a diamond in the sky' - {call} _ - ``` - turtle: - levels: - 1: - story_text: | - You can also use Hedy to draw. By combining turns and lines, you can make a square or stairs! - - Using `{forward}` you draw a line forwards. The number behind it determines how far the turtle will walk. `{turn} {right}` turns a quarter turn in clockwise direction, `{turn} {left}` turns counter clockwise. - example_code_2: | - ``` - {turn} {right} - {forward} 50 - {turn} {left} - {forward} 50 - ``` - 3: - story_text: | - In this level you can use use `{at} {random}` with the drawing turtle. A random choice makes the turtle walk a different path each time. - Use `{at} {random}` to choose a value from a list. You can copy and paste lines 2 and 3 to create a longer random path. - 4: - example_code: | - ``` - {print} 'Drawing figures' - angle {is} 90 - {turn} angle - {forward} 25 - {turn} angle - {forward} 25 - ``` - 5: - example_code_2: | - ``` - direction {is} {ask} 'Do you want to go left, right, or straight ahead?' - if direction is left turn _ - if direction is right turn _ - forward 100 - ``` - 8: - story_text: | - Now that we can repeat several lines, we can make figures more easily. - We only have to set the angle once and then use that variable in the `{repeat}`. - example_code: | - ``` - angle = 90 - {repeat} 10 {times} - {turn} angle - {forward} 50 - ``` - story_text_2: | - Also, we can now improve the program that draws different figures. - Can you figure out how far the turtle has to turn here? Finish the code and you can draw any polygon you'd like! - 9: - story_text: | - Now that we can use a `{repeat}` inside a `{repeat}`, we can create more complex figures. - - ### Exercise 1 - This code creates three black triangles, change that into five pink squares. - - **(extra)** Create a figure of your own choosing consisting of at least two different shapes types. - 10: - story_text: | - In this level you can make the turtle draw a figure. - The turtle will travel the distances in the list, one by one, making bigger and bigger steps. - ### Exercise 1 - Add a 90 degree turn in the loop, so that a spiral is drawn. - Add at least 5 numbers to the list, so the spiral grows larger. - **(extra)** can you change the spiral into another shape? Experiment with numbers for the turn! - ### Exercise 2 - The spiral is drawn outwards, make it go inwards? - turtle_draw_it: - levels: - 9: - example_code: | - Hint for the nested squares: - ``` - colors = red, blue, orange, yellow, pink, purple, green, brown, black - distance = 120 - repeat 5 times - _ - ``` - Hint for the flags: - ``` - country = ask 'which country would you like to see the flag of?' - if country is 'the Netherlands' - color_1 = red - color_2 = white - color_3 = blue - ``` - 10: - example_code: | - Hint Nested Hexagon: - ``` - distances = 100, 80, 60, 40, 20 - {for} distance {in} distances - _ - ``` - - Hint Traffic Lights: - ``` - colors = red, yellow, green - {for} chosen_color {in} colors - color _ - {repeat} _ - ``` - 12: - story_text: | - ### Exercise - Recreate the drawings with the turtle! - Hint: Bracelet designing program. Firstly, define a function **for each shape** you want to use on the bacelet. Then, add the shapes to the bacelet like this: - - Bracelet Designing program - example_code: | - ``` - {define} draw_a_square - _ - - {color} white - {turn} -90 - {forward} 300 - {turn} 180 - - {for} i {in} {range} 1 {to} 5 - {color} gray - {forward} 100 - shape = {ask} 'What kind of shape would you like next on the bracelet?' - chosen_color = {ask} 'In which color?' - {color} chosen_color - {if} shape = 'square' - {call} draw_a_square - ``` - while_command: - description: while - years: - description: Countdown to the new year! - levels: - 11: - story_text: | - In this level you can use the `{for} i {in} {range}` command to countdown to the New Year. - - ### Exercise - Fill in the blanks and make the code work! - example_code: | - ``` - for _ in _ 10 to 1 - {print} i - {print} 'Happy New Year!' + {print} 'ওহে বন্ধুরা' + {print} 'এটি পাঁচ বার মুদ্রণ করা হবে' ``` diff --git a/content/adventures/ca.yaml b/content/adventures/ca.yaml index d177ae9f7b5..2b9dad936e8 100644 --- a/content/adventures/ca.yaml +++ b/content/adventures/ca.yaml @@ -167,27 +167,8 @@ adventures: {print} "Oh no! En Ricard és massa lent..." {print} _ ``` - 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 = _ , _ , _ @@ -195,18 +176,12 @@ adventures: {print} 'Què veus?' ``` 12: - story_text: In this level you can use the quotation marks to save multiple words in a variable. example_code: | ``` nom = "La Reina d'Englaterra" {print} nom ' menjava un tall de pastís, quan de sopte…' ``` 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: | ``` {print} 'El nostre heroïna camina dins el bosc' @@ -411,14 +386,6 @@ adventures: story_text_2: "### Exercici\nLa calculadora de més amunt calcularà la resposta per a tu, però també pots fer un programa per posar a prova les teves habilitats matemàtiques, com aquest:\nOmple els espais en blanc per completar-lo!\n" story_text: "Ara que ja pots fer mates, pots fer la teva pròpia calculadora!\n" 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: "```\npunts = 0\n{repeat} 10 {times}\n nombres = 1, 2, 3, 4, 5, 6, 7, 8, 9, 10\n nombre_1 = nombres {at} {random}\n nombre_2 = nombres {at} {random}\n resposta_correcta = nombre_1 * nombre_2\n {print} 'Quant fa ' nombre_1 ' per ' nombre_2 '?'\n answer = {ask} 'Escriu la teva resposta aquí...'\n {print} 'La teva resposta és ' answer\n {if} _ {is} _\n punts = punts + 1\n{print} 'Bona feina! la teva puntuació és ... ' punts ' sobre 10!'\n```\n" 12: story_text: | @@ -448,24 +415,6 @@ adventures: ``` story_text: "### Exercici 1\nFem que el programa de pràctica sigui una mica més difícil. Ara el jugador ha de respondre correctament dues preguntes. Omple els espais en blanc per completar el programa.\n\n### Exercici 2\nDe vegades, els càlculs tenen múltiples respostes correctes. Per exemple, 10 es pot dividir entre 5 i entre 2. Així, la pregunta \"Quin nombre divideix 10?\" es pot respondre amb 2 o amb 5.\nPlanteja una pregunta de càlcul que tingui múltiples respostes correctes, demana al jugador que la respongui i determina si és correcta utilitzant `{or}`.\nNeteja l'editor de codi i crea la teva pròpia solució.\n" 14: - 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 story_text: "En aquesta aventura construiràs una calculadora que calcula la teva nota mitjana. Si aconsegueixes que la teva calculadora funcioni, pots continuar amb la pròxima aventura, que et permetrà afegir dues funcions extres.\n\n### Exercici 1\nOmple els espais en blanc per fer que la calculadora funcioni.\n* Comença amb la quarta línia, afegeix una pregunta per saber quina nota ha tret l’estudiant.\n* A la cinquena línia vols calcular el total de totes les notes, així que el total = total + nota.\n* Després fixem el valor de retorn. Volem retornar la mitjana, així que el total dividit pel nombre de proves (4).\n* Finalment, acabem el codi cridant la funció a la línia 8.\n\nHo has aconseguit? Genial! T’agradaria afegir encara més funcions a la teva calculadora? **Aquesta aventura continua a la pròxima pestanya!**\n" 10: story_text: "Aquest joc de la calculadora t'ajuda a practicar les taules de multiplicar!\n### Exercici\nOmple els espais en blanc. Volem que aquest programa faci aquestes preguntes al jugador:\n```\nQuant fa 1 per 1?\nQuant fa 1 per 2?\nQuant fa 1 per 3?\nQuant fa 2 per 1?\nQuant fa 2 per 2?\nQuant fa 2 per 3?\nQuant fa 3 per 1?\nQuant fa 3 per 2?\nQuant fa 3 per 3?\n_\n```\n" @@ -1150,10 +1099,6 @@ adventures: opcions {is} _ ``` story_text_2: "### Exercici\nEls daus de l'exemple anterior són per a un joc específic. Pots fer daus normals?\nO altres daus especials d'un joc diferent?\n" - 4: - story_text: | - In this level we can make sentences with the die value in the sentence, with quotes of course. - This time the sample code is not quite complete. Can you finish the code? 5: story_text: | Afegirem les comandes `{if}` i `{else}` als nostres daus! @@ -1221,25 +1166,12 @@ adventures: description: Utilitza l'ordinador per veure qui renta els plats. levels: 3: - story_text: | - Do you always disagree at home about who should wash the dishes or change the litter box today? - Then you can let the computer choose very fairly. You can program that in this level! - You first make a list of the members of your family. Then choose `{at} {random}` from the list. example_code: | ``` gent {is} mama, papa, Emma, Sofia {print} gent {at} {random} li toca rentar plats ``` - story_text_2: | - Don't feel like doing the dishes yourself? Hack the program by removing your name from the list with the `{remove}` `{from}` command. 4: - story_text: | - With quotation marks you can make your dishwashing planning more beautiful. - This time the sample code is not quite complete. - - Can you complete the code by filling the blanks? Every blank must be replaced with one word of symbol. - - Tip: Don't forget the quotation marks! example_code: | ``` gent {is} mama, papa, Emma, Sofia @@ -1248,11 +1180,6 @@ adventures: {print} gent {at} _ ``` 5: - story_text: | - With the `{if}` you can now have more fun with choice in the program. You can have your program respond to the choice that the computer has made. - - Can you finish the code so that it prints 'too bad' when it is your turn and otherwise 'yes!'? - Don't forget the quotes! example_code: "```\ngent {is} mama, papa, Emma, Sofia\nnetejador {is} gent {at} {random}\n_ netejador {is} Sofia {print} _ Pffff... em toca rentar plats _\n_ {print} 'per sort no hi ha plats perquè ' _ ' ja els està rentant'\n```\n" 6: example_code: | @@ -1264,9 +1191,6 @@ adventures: {if} netejador {is} Emma emma_renta = emma_renta + 1 {print} "L'Emma rentarà els plats aquesta setmana" emma_renta "vegades" ``` - - Now you can copy lines 3 to 5 a few times (e.g. 7 times for a whole week) to calculate for a whole week again. - Do you make the code for the whole week? story_text_2: | Si tens molta mala sort, el programa anterior podria triar-te per a rentar plats de tota la setmana! I això no és just! Per crear un sistema més just, pots utilitzar l'ordre `{remove}` per eliminar la persona escollida de la llista. D'aquesta manera no haureu de tornar a rentar els plats fins que tothom hagi tingut el seu torn. @@ -1302,13 +1226,6 @@ adventures: ### Exercici Afegeix-hi una segona tasca, com passar l'aspiradora o endreçar, i assegura't que també estigui dividida durant tota la setmana.
**Extra** El programa no és just, pots tenir mala sort i haver de rentar durnat tota la setmana. Com pots fer el programa més just? - example_code: | - ``` - days = Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday - names = mom, dad, Emma, Sophie - _ day _ days - {print} names {at} {random} ' does the dishes on ' day - ``` elif_command: default_save_name: sino levels: @@ -1330,10 +1247,6 @@ adventures: story_text_2: "### Exercici\nAcaba aquest codi afegint `{for} action {in} actions` a la línia 2.\n" example_code_2: "```\naccions = pica de mans, pica de peus, crida Hurra!\n_\n {repeat} 2 {times}\n {print} 'Si ets feliç i ho saps, ' action\n {sleep} 2\n {print} 'Si ets feliç i ho saps, i ho vols fer saber a tothom'\n {print} 'Si ets feliç i ho saps, ' action\n {sleep} 3\n```\n" 11: - story_text: |- - In this level, we add a new form of the `{for}`. In earlier levels, we used `{for}` with a list, but we can also use `{for}` with numbers. - We do that by adding a variable name, followed by `{in}` `{range}`. We then write the number to start at, `{to}` and the number to end at. - Try the example to see what happens! In this level again, you will need to use indentations in lines below the `{for}` statements. example_code: "```\n{for} comptador {in} {range} 1 {to} 10\n {print} comptador\n{print} 'Llest o no. Ves que vinc!'\n```\n" 17: story_text: "Ara canviem una mica la indentació. Cada vegada que necessitem una indentació, hem de posar `:` a la línia abans de la indentació.\n" @@ -1348,13 +1261,6 @@ adventures: description: Deixa que Hedy predigui el futur levels: 1: - story_text: | - Have you ever been to a carnival and had your future predicted by a fortune teller? Or have you ever played with a magic eight ball? - Then you probably know that they can't really predict your future, but it's still fun to play! - - In the upcoming levels you can learn how to create your own fortune telling machine! - In level 1 you can start off easy by letting Hedy introduce herself as a fortune teller and let her {echo} the players' answers. - Like this: example_code: | ``` _ Hola, soc Hedy l'endevina @@ -1368,9 +1274,6 @@ adventures: Copia el codi d'exemple a la teva pantalla d'entrada i omple els espais en blanc per fer funcionar el teu codi. **Extra** Canvia el codi i deixa que l'endevina no només predigui el teu nom, sinó també la teva edat, el teu esport preferit o alguna altra cosa sobre tu mateix. 3: - story_text: | - In the previous levels you've created your first fortune telling machine, but Hedy couldn't really predict anything, only {echo}. - In this level you can use a variable and the `{at} {random}` command to really let Hedy choose an answer for you. Check out this code for instance: example_code: "```\n{print} Sóc Hedy, l'endeví!\npregunta {is} {ask} Què vols saber?\n{print} Això és el que vols saber: pregunta\nrespostes {is} sí, no, potser\n{print} La meva bola de cristall diu...\n{sleep} 2\n{print} respostes {at} {random}\n```\n" story_text_2: "### Exercici\nAra, Hedy només pot respondre sí, no o potser. Pots donar-li més opcions de resposta, com 'definitivament' o 'pregunta de nou'?\n" 4: @@ -1463,8 +1366,6 @@ adventures: {sleep} ``` 12: - story_text: | - In this level you can make your fortunes multiple words. Can you add more different fortunes to the list? example_code: | ``` destí = "relliscaràs amb una pela de platan," _ @@ -1494,26 +1395,6 @@ adventures: {sleep} 2 ``` story_text: "En aquest nivell aprendràs a utilitzar **funcions**. Una funció és un bloc de codi que pots fer servir fàcilment diverses vegades. Usar funcions ens ajuda a organitzar fragments de codi que podem usar una vegada i una altra.\nPer crear una funció, usa `{define}` i dona-li un nom a la funció. Després, posa totes les línies que vols dins de la funció en un bloc indentat sota la línia `{define}`.\nDeixa una línia buida al teu codi per fer-lo més net i organitzat. Bona feina! Ja has creat una funció!\n\nAra, sempre que necessitem aquest fragment de codi, només hem d'utilitzar {call} amb el nom de la funció per cridar-la! No cal tornar a escriure i repetir el codi.\n\nMira aquest exemple de codi d'un joc de Twister. La funció 'turn' conté un bloc de codi que tria quina part del cos ha d'anar a cada color.\n\n### Exercici\nAcaba aquest codi establint les dues variables 'extremitat_escollida' i 'color_escollit'.\nDesprés, tria quantes vegades vols cridar la funció per fer girar la roda de Twister.\n\n### Exercici 2\nMillora el teu codi afegint una variable anomenada 'persones'. Utilitza la variable per donar a tots els jugadors el seu propi comandament en el joc.\nPer exemple: 'Ahmed, mà dreta al verd' o 'Jessica, peu esquerre al groc'.\n" - 13: - story_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. - - For example in this code we've programmed the first verse of the song 'My Bonnie is over the ocean'. - In this example code the argument `place` is used. Place is a variable that is only used in the function, so an argument. - To use `place` we have programmed the line `define song with place`. - When the function is called, computer will replace the argument `place`, with the piece of text after `call song with`. - - ### Exercise - The next verse of this song goes: - - Last night as I lay on my pillow - Last night as I lay on my bed - Last night as I lay on my pillow - I dreamed that my Bonnie is dead - - Can you program this verse in the same way as the example? - example_code: "```\n{define} song {with} place\n {print} 'My Bonnie is over the ' place\n\n{call} song {with} 'ocean'\n{call} song {with} 'sea'\n{call} song {with} 'ocean'\n```\n" 14: example_code: | ``` @@ -1536,109 +1417,9 @@ adventures: default_save_name: funcions description: funcions haunted: - levels: - 1: - story_text_2: | - ### Exercise - Can you finish the scary story? Or make up your own haunted house story? - 2: - example_code: | - ``` - monster_1 {is} 👻 - monster_2 {is} 🤡 - monster_3 {is} 👶 - {print} You enter the haunted house. - {print} Suddenly you see a monster_1 - {print} You run into the other room, but a monster_2 is waiting there for you! - {print} Oh no! Quickly get to the kitchen. - {print} But as you enter monster_3 attacks you! - ``` - example_code_2: | - ``` - monster_1 {is} _ - monster_2 {is} _ - monster_3 {is} _ - {print} You enter the haunted house. - {print} Suddenly you see a monster_1 - {print} You run into the other room, but a monster_2 is waiting there for you! - {print} Oh no! Quickly get to the kitchen. - {print} But as you enter monster_3 attacks you! - ``` - 3: - story_text: | - In the previous levels you've made an introduction to your haunted house game, but as you might have noticed the story would always have a dreadful end. - In this level you can make your story more interactive by changing the outcome of the game; sometimes you'll get eaten, sometimes you'll escape! - Let Hedy decide randomly! - 4: - story_text: | - In this level you learn how to use quotation marks in your games. - Can you make your Haunted House level 4 proof? - example_code: | - ``` - {print} _ Escape from the haunted house! _ - {print} _ There are 3 doors in front of you... _ - choice {is} {ask} _ Which door do you choose? _ - {print} _ You picked door ... _ choice - monsters {is} a zombie, a vampire, NOTHING YOUVE ESCAPED - {print} _ You see... _ - {sleep} - {print} monsters {at} {random} - ``` - 9: - story_text: | - In this level you can use nesting, which allows you to make the haunted house even more interactive! - - ### Exercise - Now it's very hard to win this game, can you make it easier to win? - For example by only having 1 wrong door and 2 correct doors instead of 1 correct door and 2 wrong ones? - 11: - story_text: | - In this level we've changed the repeat command and we've added a line to our haunted house that tells the player in which room they are. - - ### Exercise - Finish the program with the correct line of code. Mind: There are 3 rooms that the player needs to survive before they win! - example_code: | - ``` - {print} 'Escape from the Haunted House!' - player {is} alive - doors = 1, 2, 3 - monsters = zombie, vampire, giant spider - _ - {if} player {is} alive - correct_door = doors {at} {random} - {print} 'Room ' i - {print} 'There are 3 doors in front of you...' - chosendoor = {ask} 'Which door do you choose?' - {if} chosendoor {is} correct_door - {print} 'No monsters here!' - {else} - {print} 'You are eaten by a ' monsters {at} {random} - player = dead - {else} - {print} 'GAME OVER' - {if} player {is} alive - {print} 'Great! You survived!' - ``` name: Casa encantada description: Escapa de la casa encantada default_save_name: Casa encantada - if_command: - description: Introducing the if command - levels: - 9: - story_text: | - In this level you can also put an {if} command inside another {if} command. - in_command: - description: Introducing the in command - levels: - 5: - example_code_2: | - ``` - animals is dog, cow, sheep - answer is ask 'What is your favorite animal?' - _ answer _ animals _ 'Mine too!' - _ _ 'My favorite animals are dogs, cows and sheep' - ``` is_command: default_save_name: comanda_es description: Introducció a la comanda {is} @@ -1659,135 +1440,14 @@ adventures: En el codi d'exemple hem fet un exemple de la variable `animal_preferit`. A la línia 1 es defineix la variable, i a la línia 2 hem utilitzat la variable dins una comanda d'impressió. En primer lloc, acabeu el nostre exemple omplint el vostre animal preferit als espais en blanc. A continuació, feu vosaltres mateixos almenys 3 d'aquests codis. Trieu una variable i configureu-la amb la comanda {is}. A continuació, utilitzeu-lo amb una comanda {print}, tal com hem fet abans. example_code_2: "```\nanimal_preferit {is} _\n{print} M'agraden els/les animal_preferit \n```\n" - 14: - example_code: | - ``` - age = {ask} 'How old are you?' - {if} age > 12 - {print} 'You are older than I am!' - ``` - example_code_3: | - ``` - name = {ask} 'What is your name?' - {if} name != 'Hedy' - {print} 'You are not Hedy' - ``` - - {if} age < 13 - {print} 'You are younger than me!' - {else} - {print} 'You are older than me!' - language: - levels: - 5: - story_text: | - Make your own program to practice your vocabulary in a new language. - - ### Exercise - Can you make this program for a different language? Or can you add more words to the French one? - maths: - levels: - 6: - example_code: | - ``` - {print} '5 plus 5 is ' 5 + 5 - {print} '5 minus 5 is ' 5 - 5 - {print} '5 times 5 is ' 5 * 5 - ``` - 12: - example_code_2: | - ``` - a = 'Hello ' - b = 'world!' - {print} a + b - ``` - - {print} 2.5 + 2.5 - music: - levels: - 6: - story_text: "Instead of playing notes, you can also play numbers now. Simply type `{play} 1` for the lowest note, `{play} 70` for the highest note, or anything in between.\n\n### Exercise\n This calls for musical maths! Try out the example code a couple of times with different starting numbers. \nThen, see if you can compose a song using the numbers.\n" parrot: name: Lloro description: Crea el teu lloro i fes que repeteixi el que li dius! levels: - 1: - story_text_2: | - ### Exercise - Can you make the parrot ask a different question? Fill in the blanks in the example! 2: story_text: | En el nivell anterior has fet un lloro que repetia el que li deies. En aquest nivell farem que el lloro sigui interactiu utilitzant una variable i la comanda `{ask}` . També farem el lloro sigui més real afegint la comanda `{sleep}` després de dir una cosa. - example_code: | - ``` - {print} Im Hedy the parrot - name {is} {ask} whats your name? - {print} name - {sleep} - {print} squawk - {sleep} - {print} name - ``` - story_text_2: | - ### Exercise - You can use variables to make the parrot say more than only your name. Can you complete this code? - 3: - story_text: | - Teach your parrot a new word with `{add}`. - ### Exercise - How can you make your parrot say multiple words? - example_code: | - ``` - words {is} squawk, Hedy - {print} Train your parrot! - new_word {is} {ask} Which word do you want to teach them? - {add} new_word {to_list} words - {print} 🧒 Say new_word, Hedy! - {print} 🦜 words {at} {random} - ``` - 4: - story_text: | - In this level we have to use quotation marks with the commands `{ask}` and `{print}`. - Can you complete the code by adding quotation marks? - 5: - story_text: | - Reward your parrot if it says the correct word! - Finish the code by filling in the 4 missing commands. - piggybank: - levels: - 12: - story_text: | - In this adventure you learn how to make a digital piggy bank. - Finish the code to calculate how much money you have and how long you need to save up to buy what you want! - 14: - example_code: | - ``` - _ calculate_budget with wish, money, allowance - to_save = wish - money - weeks = to_save / allowance - {if} wish _ money - {print} 'You need to save up some more!' - {print} 'Youll need ' weeks ' more weeks.' - {else} - {print} 'Great! You have enough' - {print} 'Lets go shopping!' - - money = {ask} 'How much money have you saved?' - wish = {ask} 'How much money do you need?' - allowance = {ask} 'How much pocket money do you get each week?' - - {call} calculate_budget with _, _, _ - ``` - pressit: - levels: - 9: - story_text: | - Now that you know how to combine statements, you can create a touch type tool with `{pressed}`. - - ### Exercise - Finish the code. Each time a random letter should be chosen, which you have to press. You get a point for a correct press, and and two points deduction for a wrong press. - **(extra)** Clear the screen after each letter, and show the user how many points they have scored. print_command: description: Introducció a la comanda imprimir levels: @@ -1838,495 +1498,6 @@ adventures: {print} 'Amb l'Anna hem d'anar a fer de cangur als meus nebots' {print} 'M'encanta! la meva germana n'estarà orgullosa' ``` - random_command: - levels: - 16: - story_text: |- - We are going to make lists the Python way, with square brackets around the lists! We also keep the quotation marks around each item like we have learned in previous levels. - We use square brackets to point out a place in a list. For example: `friends[1]` is the first name on the list of friends, as you can see in the first part of the example code. The second part of the example code shows you that we can also match 2 lists using the variable i. - repeat_command: - description: repeat command - levels: - 7: - story_text: | - ## Repeat! Repeat! Repeat! - Level 7 adds the `{repeat}` command. `{repeat}` can be used to execute one line of code multiple times. Like this: - - ### Exercise - Play around with the repeat command. Can you make the happy birthday song in only 3 lines of code instead of 4 now? - 9: - story_text: | - Great job! You've reached another new level! In the previous level you've learned to use multiple lines of code in an {if} or {repeat} command. But you can't yet combine the two... - Good news! In this level you will be allowed to put an {if} inside an {if}, or inside a {repeat} command. Putting a block of code inside another block of code is called nesting. ``` Putting a block of code inside another block of code is called nesting. - example_code: | - ``` - answer = {ask} 'Are you ready to learn something new?' - {if} answer {is} yes - {print} 'Great! You can learn to use the repeat command in the if command!' - {print} 'Hooray!' - {print} 'Hooray!' - {print} 'Hooray!' - {else} - {print} 'Maybe you should practice some more in the previous level' - repeat_command_2: - description: repeat command 2 - levels: - 7: - story_text_2: | - Another interesting thing you can so with the `{repeat}` command is using variables to set the amount of times something should be repeated. In the example code you can see that we first ask the person how old they are. - Then, in line 3, the question is repeated 'age' times. So we have used the variable 'age' with the `{repeat}` command. - restaurant: - levels: - 1: - story_text_2: | - ### Exercise - Can you think of more lines to add to your restaurant code? For example, can you {ask} the guests what they'd like to drink, tell them the price, or wish them a pleasant meal? - example_code_2: | - ``` - {print} Welcome to Hedy's restaurant 🍟 - {ask} What would you like to order? - {echo} So you would like to order - {print} Thanks you for your order! - {print} It's on its way! - ``` - 2: - story_text: | - In level 2 you could expand your restaurant by using variables. In level 1 Hedy could only {echo} the order once and only remember the last thing that was ordered. - Now you can use variables and Hedy can remember both the food and the toppings! - story_text_2: | - ### Exercise - Can you make this code more elaborate? For example by adding drinks to the order? Or...? - 3: - story_text: | - Having trouble to decide what you wanna have for dinner? You can let Hedy choose for you! - Simply add lists of your favorite (or least favorite) meals and Hedy can randomly choose your dinner. - You can also have a bit of fun, by letting Hedy choose the price for your dinner as well! What will you get? - ### Exercise - Can you make your own version of the random restaurant? - example_code: | - ``` - {print} Welcome to Hedy's Random Restaurant! - {print} The only restaurant that will randomly choose your meal and its price for you! - starters {is} salad, soup, carpaccio - mains {is} pizza, brussels sprouts, spaghetti - desserts {is} brownies, ice cream, french cheeses - drinks {is} cola, beer, water - prices {is} 1 dollar, 10 dollars, 100 dollars - {print} You will start with: starters {at} {random} - {print} Then we'll serve: mains {at} {random} - {print} And as dessert: desserts {at} {random} - {print} You will get a drinks {at} {random} to drink - {print} That will be: prices {at} {random} - {print} Thank you and enjoy your meal! - ``` - story_text_2: | - Does your costumer have any allergies or do they dislike certain dishes? Then you can use the `{remove}`command to remove it from your menu. - example_code_2: | - ``` - {print} Mystery milkshake - flavors {is} strawberry, chocolate, vanilla - allergies {is} {ask} Are you allergic to any falvors? - _ - {print} You get a flavors {at} {random} milkshake - ``` - 4: - story_text: | - ### Exercise - Add the quotation marks to this code to make it work! Be careful: variables should not be in quotation marks. - example_code: | - ``` - _ Add the quotation marks to this code _ - {print} Welcome to Hedys restaurant! - {print} Today we are serving pizza or lasagna. - food {is} {ask} What would you like to eat? - {print} Great choice! The food is my favorite! - topping {is} {ask} Would you like meat or veggies on that? - {print} food with topping is on its way! - drinks {is} {ask} What would you like to drink with that? - {print} Thank you for your order. - {print} Your food and drinks will be right there! - ``` - 5: - story_text: | - In this level the `{if}` command allows you to `{ask}` your customers questions and give different responses to the answers. - In the example below, you see that you can `{ask}` the customer `{if}` they want to hear the specials and Hedy can respond accordingly. - example_code: | - ``` - {print} 'Welcome to Hedys restaurant!' - special {is} {ask} 'Would you like to hear our specials today?' - {if} special {is} yes {print} 'Todays special is chicken piri piri and rice.' {else} {print} 'No problem.' - food {is} {ask} 'What would you like to eat?' - {print} 'One ' food ', coming right up!' - drink {is} {ask} 'What would you like to drink with that?' - {if} drink {is} cola {print} 'Im sorry, we are out of cola!' {else} {print} 'Great choice!' - anything {is} {ask} 'Would you like anything {else}?' - {print} 'Let me repeat your order...' - {print} 'One ' food - {if} drink {is} cola {print} 'and...' {else} {print} 'One ' drink - {if} anything {is} no {print} 'Thats it!' {else} {print} 'One ' anything - {print} 'Thank you for your order and enjoy your meal!' - ``` - 6: - story_text: | - In this level you can use maths to calculate the total price of your customer's order, which can make your virtual restaurant more realistic. - 7: - story_text: | - In this level you've learned how to use the `{repeat}` command to repeat a line of code a certain amount of times. - You can use that in your restaurant to `{ask}` multiple people what they'd like to eat. - - ### Exercise - Can you fill in the blanks? Hedy needs to repeat this question as many times as there are people. So of there are 5 people, the question needs to be asked 5 times. - example_code: | - ``` - {print} 'Welcome to Hedys restaurant!' - people = {ask} 'How many people are joining us today?' - {repeat} _ {times} food = {ask} 'What would you like to eat?' - {print} 'Thanks for your order! Its coming right up!' - ``` - 9: - story_text: | - In this level you can use nesting to make your restaurant more realistic and more fun! - For example you would ask for sauce if somebody orders fries, but you wouldn't if someone orders pizza! - - ### Exercise - This is a challenge for the real brainiacs! Each line that needs indentation has been given a blank. - Can you figure out how much indentation each line needs in order for the code to work propperly? - Good luck! - TIP: If the customer orders pizza, Hedy shouldn't ask what sauce the costumer wants. - example_code: | - ``` - {print} 'Welcome to Hedys restaurant!' - people = {ask} 'How many people will be joining us today?' - {print} 'Great!' - price = 0 - {repeat} people {times} - _ food = {ask} 'What would you like to order?' - _ {print} food - _ {if} food {is} fries - _ price = price + 3 - _ sauce = {ask} 'What kind of sauce would you like with your fries?' - _ {if} sauce {is} no - _ {print} 'no sauce' - _ {else} - _ price = price + 1 - _ {print} 'with ' sauce - _ {if} food {is} pizza - _ price = price + 4 - {print} 'That will be ' price ' dollar' - {print} 'Enjoy your meal!' - ``` - 10: - story_text: | - In this level you'll learn how to easily {ask} your guests' orders in a short code. - example_code: | - ``` - courses = appetizer, main course, dessert - {for} course {in} courses - food = {ask} 'What would you like to eat as your ' course '?' - {print} food ' will be your ' course - ``` - story_text_2: | - ### Exercise - Of course, you could also order for multiple people! - Can you add the correct amount of indentation before each line to make the code work properly? - TIP: some lines don't need any indentation at all. - example_code_2: | - ``` - _ courses = appetizer, main course, dessert - _ names = Timon, Onno - _ {for} name {in} names - _ {for} course {in} courses - _ food = {ask} name ', what would you like to eat as your ' course '?' - _ {print} name ' orders ' food ' as their ' course - ``` - 11: - story_text: | - We can use the `{for} i {in} {range} 1 {to} 5` to `{print}` the orders from multiple customers in an orderly manner. - - ### Exercise - Can you handle another indentation challenge? Get the code to work properly by adding the right amount of indentation before each line! - example_code: | - ``` - {print} 'Welcome to Restaurant Hedy!' - people = {ask} 'For how many people would you like to order?' - {for} i {in} {range} 1 {to} people - _ {print} 'Order number ' i - _ food = {ask} 'What would you like to eat?' - _ {print} food - _ {if} food {is} fries - _ sauce = {ask} 'What kind of sauce would you like with that?' - _ {print} sauce - _ drinks = {ask} 'What would you like to drink?' - _ {print} drinks - price = 4 * people - {print} 'That will be ' price ' dollars, please!' - ``` - 12: - story_text: | - From this level on you can use decimal numbers to make you menu more realistic. - - ### Exercise - Can you think of a code to give your friends and family a 15% discount? - example_code: | - ``` - price = 0 - food = {ask} 'What would you like to order?' - drink = {ask} 'What would you like to drink?' - {if} food {is} 'hamburger' - price = price + 6.50 - {if} food {is} 'pizza' - price = price + 5.75 - {if} drink {is} 'water' - price = price + 1.20 - {if} drink {is} 'soda' - price = price + 2.35 - {print} 'That will be ' price ' dollar, please' - ``` - 13: - story_text: | - In this level we can use the new commands to upgrade our restaurant. - We use `{and}` to see {if} two things are both the case. - example_code: | - ``` - price = 10 - food = {ask} 'What would you like to eat?' - drinks = {ask} 'What would you like to drink?' - {if} food {is} 'sandwich' {and} drinks {is} 'juice' - {print} 'Thats our discount menu' - price = price - 3 - {print} 'That will be ' price ' dollars' - ``` - rock: - default_save_name: Rock - levels: - 2: - story_text: | - In this level you can practise using the variables, so that you can make the rock, paper, scissors game in the next level! - example_code: | - ``` - _ {is} {ask} rock, paper, or scissors? - {print} I choose _ - ``` - 3: - example_code: | - ``` - choices {is} rock, paper, scissors - {print} choices {at} {random} - ``` - story_text_2: | - ### Exercise - Now you only have one player, so can you add a second player? - You can even use variables to name player 1 and player 2. - example_code_2: | - ``` - choices {is} rock, paper, scissors - {print} player 1 chooses... choices {at} {random} - {print} player 2 _ - ``` - 5: - story_text: | - In this level we can determine who won. - For that you need the new `{if}` code. - - Save your choice with the name of choice and the choice of computer as computer choice. - Then you can use `{if}` to see if they are the same or different. - Will you finish the code? - example_code: | - ``` - options {is} rock, paper, scissors - computer_choice {is} _ - choice {is} {ask} 'What do you choose?' - {print} 'you chose ' _ - {print} 'computer chose ' _ - {if} _ {is} _ {print} 'tie!' {else} {print} 'no tie' - ``` - - Fill in the correct code on the blanks to see {if} it is a draw. - 9: - story_text: | - In this level you can program the whole rock, paper, scissors game by nesting the `{if}` commands. Can you finish the code? - example_code: | - ``` - choices = rock, paper, scissors - your_choice = {ask} 'What do you choose?' - {print} 'You choose ' your_choice - computer_choice = choices {at} {random} - {print} 'The computer chooses ' computer_choice - {if} computer_choice {is} your_choice - {print} 'Tie' - {if} computer_choice {is} rock - {if} your_choice {is} paper - {print} 'You win!' - {if} your_choice {is} scissors - {print} 'You lose!' - # finish this code - ``` - 10: - story_text: | - Feeling too lazy to play the game yourself? Let Hedy play it for you! - You only have to fill in the names of the players. - example_code: | - ``` - choices = rock, paper, scissors - players = _ - {for} player {in} players - {print} player ' chooses ' choices {at} {random} - ``` - 13: - story_text: | - With the `{and}` command you can shorten your rock, paper, scissors code! Check out the example code below and try to finish it. - rock_2: - levels: - 2: - story_text: | - Now that you have learned how to use the `{ask} command, you can make your rock, paper, scissors code interavtive too! - - ### Exercise - Make the rock, paper, scissors code interactive by adding the `{ask}` command and a question to your rock, paper, scissors code. - example_code: | - ``` - choice is _ - {print} I choose choice - ``` - secret: - levels: - 12: - story_text: | - In this adventure you can create your own super spy code. Encode a message that only the right agent can decipher. - If the enemy tries to crack the code, they will get some false info to waste their time. - - ### Exercise - Make your own secret code for your superspy. Can you make it consist of even more variables? - example_code: | - ``` - name = {ask} 'What is your name?' - {if} name {is} '_' - a = 'Go to the airport ' - {else} - a = 'Go to the trainstation ' - password = {ask} 'What is the password?' - {if} password {is} _ - b = 'tomorrow at 02.00' - {else} - b = 'today at 10.00' - {print} _ _ _ - ``` - 13: - story_text: | - Can you fill in the right command on the blank? Mind: The superspy has to answer BOTH questions correctly, before they get the confidential information! - sleep_command: - description: introducing sleep command - levels: - 2: - story_text: | - ## The sleep command - Another new command in this level is `{sleep}`, which pauses your program for a second. If you type a number behind the {sleep} command, the program pauses for that amount of seconds. - songs: - levels: - 7: - story_text: | - Songs often contain a lot of repetition. For example... Baby Shark! If you sing it, you keep singing the same thing: - - Baby Shark tututudutudu
- Baby Shark tututudutudu
- Baby Shark tututudutudu
- Baby Shark - - You can make this song much shorter with a `{repeat}`! Can you finish the code? - example_code: | - ``` - {repeat} _ _ {print} 'Baby Shark tututudutudu' - {print} 'Baby Shark' - ``` - - After Baby Shark you can of course also program other songs. There are many songs with repetition. - 8: - story_text: | - In a previous level you've programmed the song 'Bottles of beer'. You made one verse and then had to copy the verses 99 times. In this level you can repeat the song 99 times, just by adding one simple line! - Do you know which line of code to add on the blanks? - example_code: | - ``` - verse = 99 - _ _ _ - {print} verse ' bottles of beer on the wall' - {print} verse ' bottles of beer' - {print} 'Take one down, pass it around' - verse = verse - 1 - {print} verse ' bottles of beer on the wall' - ``` - 10: - story_text: | - In this level you can easily make the childrens' song 'Five little monkeys'. Can you make the last chorus? - You can also make the whole baby shark song (including all the other sharks in the family) in only 6 lines, using `{for}`! - Or you can make Old MacDonald with all the different animals. - - - - ### Exercises - Can you add the last verse of the monkeys on the bed, when there is only one monkey left? - - Can you make the baby shark code even shorter by using a `{repeat}` command? - - Can you add new animals to Old MacDonald's farm? - example_code: | - ``` - monkeys = 5, 4, 3, 2 - {for} monkey {in} monkeys - {print} monkey ' little monkeys jumping on the bed' - {print} 'One fell off and bumped his head' - {print} 'Mama called the doctor and the doctor said' - {print} 'NO MORE MONKEYS JUMPING ON THE BED!' - ``` - - ``` - sharks = baby, mommy, daddy, grandma, grandpa - {for} shark {in} sharks - {print} shark ' shark tututututudu' - {print} shark ' shark tututututudu' - {print} shark ' shark tututututudu' - {print} shark ' shark' - ``` - ``` - animals = pig, dog, cow - {for} animal {in} animals - {if} animal {is} pig - sound = oink - {if} animal {is} dog - sound = woof - {if} animal {is} cow - sound = moo - {print} 'Old MacDonald had a farm' - {print} 'E I E I O!' - {print} 'and on that farm he had a ' animal - {print} 'E I E I O!' - {print} 'with a ' sound sound ' here' - {print} 'and a ' sound sound ' there' - {print} 'here a ' sound - {print} 'there a ' sound - {print} 'everywhere a ' sound sound - ``` - story_text_2: | - ### Exercise 2 - Print the song Five little moneys jumping on the bed. Look up the text if you don't remember. - - **(extra)** Print the song Old MacDonald had a farm, and make sure all animals make a different sound, using an `{if}`. - 11: - story_text: | - In this level you can use the `{for} i {in} {range}` command to make songs that use counting, like the 5 little monkeys. - - ### Exercise - Fill in the blanks and make the code work! - example_code: | - ``` - _ _ _ _ 5 _ 1 - {print} i ' little monkeys jumping on the bed' - {print} 'One fell off and bumped his head' - {print} 'Mama called the doctor and the doctor said' - {if} i {is} 1 - {print} 'PUT THOSE MONKEYS RIGHT TO BED!' - {else} - {print} 'NO MORE MONKEYS JUMPING ON THE BED!' - ``` 12: example_code: | ``` @@ -2339,171 +1510,6 @@ adventures: _ {print} "si ets feliç i ho saps" _ {print} accio ``` - songs_2: - levels: - 12: - example_code: | - ``` - {define} twinkle - {print} 'Twinkle' - {print} '...' - - {call} twinkle - {print} 'Up above the world so high' - {print} 'Like a diamond in the sky' - {call} _ - ``` - turtle: - levels: - 2: - story_text: | - In this level you can use variables to make the turtle interactive. For example you can ask the player how many steps the turtle must make. - example_code: | - ``` - answer {is} {ask} How many steps should the turtle make? - {forward} answer - ``` - story_text_2: | - Also, in level 1 the turtle could only turn left or right. That is a bit boring! - In level 2 he can point his nose in all directions. - - Use 90 to turn a quarter. We call this degrees. A full turn is 360 degrees. - - ### Exercise - Can you make a figure with this code? Maybe a triangle or a circle? - example_code_2: | - ``` - {print} Drawing figures - angle {is} 90 - {turn} angle - {forward} 25 - {turn} angle - {forward} 25 - ``` - 3: - story_text: | - In this level you can use use `{at} {random}` with the drawing turtle. A random choice makes the turtle walk a different path each time. - Use `{at} {random}` to choose a value from a list. - ### Exercise - Can you copy and paste lines 2 and 3 to create a longer random path? - 5: - example_code_2: | - ``` - direction {is} {ask} 'Do you want to go left, right, or straight ahead?' - if direction is left turn _ - if direction is right turn _ - forward 100 - ``` - 8: - story_text: | - Now that we can repeat several lines, we can make figures more easily. - We only have to set the angle once and then use that variable in the `{repeat}`. - example_code: | - ``` - angle = 90 - {repeat} 10 {times} - {turn} angle - {forward} 50 - ``` - story_text_2: | - Also, we can now improve the program that draws different figures. - Can you figure out how far the turtle has to turn here? Finish the code and you can draw any polygon you'd like! - 9: - story_text: | - Now that we can use a `{repeat}` inside a `{repeat}`, we can create more complex figures. - - ### Exercise 1 - This code creates three black triangles, change that into five pink squares. - - **(extra)** Create a figure of your own choosing consisting of at least two different shapes types. - 10: - story_text: | - In this level you can make the turtle draw a figure. - The turtle will travel the distances in the list, one by one, making bigger and bigger steps. - ### Exercise 1 - Add a 90 degree turn in the loop, so that a spiral is drawn. - Add at least 5 numbers to the list, so the spiral grows larger. - **(extra)** can you change the spiral into another shape? Experiment with numbers for the turn! - ### Exercise 2 - The spiral is drawn outwards, make it go inwards? - turtle_draw_it: - levels: - 9: - example_code: | - Hint for the nested squares: - ``` - colors = red, blue, orange, yellow, pink, purple, green, brown, black - distance = 120 - repeat 5 times - _ - ``` - Hint for the flags: - ``` - country = ask 'which country would you like to see the flag of?' - if country is 'the Netherlands' - color_1 = red - color_2 = white - color_3 = blue - ``` - 10: - example_code: | - Hint Nested Hexagon: - ``` - distances = 100, 80, 60, 40, 20 - {for} distance {in} distances - _ - ``` - - Hint Traffic Lights: - ``` - colors = red, yellow, green - {for} chosen_color {in} colors - color _ - {repeat} _ - ``` - 12: - story_text: | - ### Exercise - Recreate the drawings with the turtle! - Hint: Bracelet designing program. Firstly, define a function **for each shape** you want to use on the bacelet. Then, add the shapes to the bacelet like this: - - Bracelet Designing program - example_code: | - ``` - {define} draw_a_square - _ - - {color} white - {turn} -90 - {forward} 300 - {turn} 180 - - {for} i {in} {range} 1 {to} 5 - {color} gray - {forward} 100 - shape = {ask} 'What kind of shape would you like next on the bracelet?' - chosen_color = {ask} 'In which color?' - {color} chosen_color - {if} shape = 'square' - {call} draw_a_square - ``` - while_command: - description: while - years: - description: Countdown to the new year! - levels: - 11: - story_text: | - In this level you can use the `{for} i {in} {range}` command to countdown to the New Year. - - ### Exercise - Fill in the blanks and make the code work! - example_code: | - ``` - {for} _ {in} _ 10 {to} 1 - {print} i - {print} 'Happy New Year!' - ``` blackjack_3: levels: 17: diff --git a/content/adventures/cs.yaml b/content/adventures/cs.yaml index 58b3509eb59..533dbb2fad0 100644 --- a/content/adventures/cs.yaml +++ b/content/adventures/cs.yaml @@ -53,8 +53,6 @@ adventures: **Extra** Přidejte příkaz `{sleep}` do svého kódu, abyste zvýšili napětí ve svém příběhu. 3: - story_text_2: | - The command `{add}` can also come in handy in your story. For example example_code_2: | ``` {print} Slyší zvuk @@ -63,30 +61,6 @@ adventures: {add} zvire {to_list} zvířata {print} to byla zvířata {at} {random} ``` - story_text_3: | - This is an example of the `{remove}` command in your story - 5: - story_text: | - In this level you can program different endings, which will make your story even more fun. - - 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 'encounter 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: | V příběhu někdo opakuje slova několikrát. Například, když někdo volá o pomoc nebo zpívá píseň. @@ -116,9 +90,7 @@ adventures: {print} _ ``` 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: | + example_code: | ``` {print} 'Robin jde do centra města' location = {ask} 'Jde Robin do obchodu, nebo jde domů?' @@ -134,8 +106,6 @@ adventures: {print} 'Robin jde domů' ``` 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: | ``` zvirata = _ , _ , _ @@ -143,16 +113,12 @@ adventures: {print} 'Co vidíš?' ``` 12: - story_text: | - In this level you can use the quotation marks to save multiple words in a variable. example_code: | ``` jmeno = 'Královna Velké Británie' {print} jmeno ' jedla kousek dortu, když najednou…' ``` 13: - story_text: | - By using the `{and}` and `{or}` commands, you can shorten your stories. For example, check out the dragon story. example_code: | ``` {print} 'Náš hrdina kráčí lesem' @@ -162,46 +128,13 @@ adventures: {if} cesta {is} 'levou' {and} zbran {is} 'mec' _ ``` - 15: - 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: example_code: | ``` {print}('Vítejte v tomto příběhu!') ``` - add_remove_command: - name: '{add} {to} & {remove} {from}' - 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. - 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. - and_or_command: - description: introducing and or ask_command: - description: Introduction ask command levels: - 1: - 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. 2: story_text: | ## Příkaz ask @@ -224,403 +157,6 @@ adventures: Nyní místo nastavování proměnných chceme, abyste proměnné učinili interaktivními, jak jsme to udělali v našem příkladu. Zkopírujte svůj kód z předchozího panelu a učiňte proměnné interaktivními pomocí příkazů `{ask}`. - calculator: - levels: - 6: - story_text: | - Now that you can calculate, you can also create a program to practice maths calculations. You can make up the calculations yourself, for example: - example_code: | - ``` - correct_answer = 11 * 27 - answer = {ask} 'How much is 11 times 27?' - {if} answer {is} correct_answer {print} 'good job!' - {else} {print} 'Wrong! It was ' correct_answer - ``` - story_text_2: | - You can also let the computer do random calculations on its own using {random}. - example_code_2: | - ``` - tables = 4, 5, 6, 8 - numbers = 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 - table = tables {at} {random} - number = numbers {at} {random} - correct_answer = table * number - answer = {ask} 'how much is ' table ' times ' number '?' - {if} answer {is} correct_answer {print} 'okay' - {else} {print} 'mistake! it was ' correct_answer - ``` - 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`. - 11: - example_code: | - ``` - number = 10 - {for} i {in} {range} 1 to 10 - {print} i * number - ``` - 12: - story_text: | - Now you can make a calculator that works for decimal numbers. - example_code: | - ``` - number1 = {ask} 'What is the first number?' - number2 = {ask} 'What is the second number?' - answer = number1 + number2 - {print} number1 ' plus ' number2 ' is ' answer - 14: - 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 - clear_command: - description: clear command - debugging: - levels: - 3: - 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} - ``` - 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! - 8: - 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: - 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!' - {else} - 'I'm sorry we don't sell that' - topping {is} {ask} 'What kind of topping would you like?' - sauce {is} {ask} 'What kind of sauce would you like?' - {print} One chosen_bread with topping and sauce. - price = amount * 6 - {print} 'That will be 'price dollar' please' - ``` - - price = amount * 6 - {print} 'That will be 'price dollar' please' - 10: - example_code: | - **Warning! This code needs to be debugged!** - ``` - names = Muad Hasan Samira Noura - activities = fly a kite, go swimming, go hiking, catch tan in the sun - {for} name {is} names - {print} At the beach name loves to activity at random - ``` - 11: - story_text: |- - ### Exercise - Debug this calender program. The output of this program is supposed to look like a list of dates. - For example: - - ``` - Hedy calender - Here are all the days of November - November 1 - November 2 - November 3 - ``` - And so on. - - Mind that you have to test your code extra carefully for the month February, because the amount of days in this month changes in leap years. - example_code: | - **Warning! This code needs to be debugged!** - ``` - print 'Hedy calender' - months_with_31 days = January, March, May, July, September, October, December - months_with_30_days = April, June, August, November - month = ask 'Which month would you like to see?' - if month in months_with_31_days - days = 31 - if month in months_with30_days - days = 30 - if month = February - leap_years = 2020, 2024, 2028, 2036, 2040, 2044, 2028 - year = ask 'What year is it?' - if year in leap_years - days = 29 - else - days = 28 - - print 'Here are all the days of ' moth - for i in range 1 to days - print month i - ``` - 12: - example_code: | - **Warning! This code needs to be debugged!** - ``` - define greet - greetings = 'Hello', 'Hi there', 'Goodevening' - print greetings at random - - define take_order - food = ask 'What would you like to eat?' - print 'One food' - drink = 'What would you like to drink?' - print 'One ' drink - more = ask 'Would you like anything else?' - if more is 'no' - print 'Alright' - else - print 'And ' more - print 'Thank you' - - print 'Welcome to our restaurant' - people = ask 'How many people are in your party tonight?' - for i in range 0 to people - call greet_costumer - ``` - 13: - example_code: | - **Warning! This code needs to be debugged!** - ``` - defin movie_recommendation with name - action_movies == 'Die Hard', 'Fast and Furious', 'Inglorious Bastards' - romance_movies = 'Love Actually', 'The Notebook', 'Titanic' - comedy_movies = 'Mr Bean' 'Barbie''Deadpool' - kids_movies = 'Minions', 'Paddington', 'Encanto' - if name is 'Camila' or name is 'Manuel' - recommended_movie = kids_movie at random - if name is 'Pedro' or 'Gabriella' - mood = ask 'What you in the mood for?' - if mood is 'action' - recommended_movie = comedy_movies at random - if mood is 'romance' - recommended_movie = romance_movies - if mood is 'comedy' - recommended_movie = comedy_movies at random - - print 'I would recommend ' recommended_movie ' for ' name - - name = ask 'Who is watching?' - recommendation = ask 'Would you like a recommendation?' - if recommendaion is 'yes' - print movie_recommendation with name - else - print 'No problem!' - ``` - 14: - example_code: | - **Warning! This code needs to be debugged!** - ``` - define calculate_heartbeat - print 'Press your fingertips gently against the side of your neck' - print '(just under your jawline)' - print 'Count the number of beats you feel for 15 seconds' - beats == ask 'How many beats do you feel in 15 seconds?' - heartbeat = beats*4 - print 'Your heartbeat is ' heartbeat - if heartbeat >= 60 or heartbeat <= 100 - print 'Your heartbeat seems fine' - else - if heartbeat > 60 - print 'Your heartbeat seems to be too low' - if heartbeat < 100 - print 'Your heartbeat seems to be too high' - print 'You might want to contact a medical professional' - - measure_heartbeat = ask 'Would you like to measure your heartbeat?' - if measure_heartbeat = 'yes' - call measure_heartbeat - else - 'no problem' - ``` - - print '(just under your jawline)' - print 'Count the number of beats you feel for 15 seconds' - beats == ask 'How many beats do you feel in 15 seconds?' - heartbeat = beats*4 - print 'Your heartbeat is ' heartbeat - if heartbeat >= 60 or heartbeat <= 100 - print 'Your heartbeat seems fine' - else - if heartbeat > 60 - print 'Your heartbeat seems to be too low' - if heartbeat < 100 - print 'Your heartbeat seems to be too high' - print 'You might want to contact a medical professional' - - measure_heartbeat = ask 'Would you like to measure your heartbeat?' - if measure_heartbeat = 'yes' - call measure_heartbeat - else - 'no problem' - 15: - example_code: | - **Warning! This code needs to be debugged!** - ``` - names = 'Tanya', 'Romy', 'Kayla', 'Aldrin', 'Ali' - verbs='walking', 'skipping', 'cycling', 'driving', 'running' - locations = 'on a mountaintop', 'in the supermarket', 'to the swimming pool' - hiding_spots = 'behind a tree', under a table', in a box' - sounds = 'a trumpet', 'a car crash', 'thunder' - causes_of_noise = 'a television', 'a kid with firecrackers', 'a magic elephant', 'a dream' - - chosen_ name = names at random - chosen_verb = verbs at random - chosen_location = 'locations at random' - chosen_sounds = noises at random - chosen_spot = hiding_spots random - chosen_causes = causes_of_noise at random - - print chosen_name ' was ' chosen_verb ' ' chosen_location - print 'when they suddenly heard a sound like ' sounds at random - print chosen_name ' looked around, but they couldn't discover where the noise came from' - print chosen_name ' hid ' chosen_spot' - print 'They tried to look around, but couldn't see anything from there' - hidden = 'yes' - while hidden = 'yes' - print chosen_name 'still didn't see anything' - answer = ask 'does ' chosen_name ' move from their hiding spot?' - if answer = 'yes' - hidden == 'no' - print 'chosen_name moved from' chosen_spot - print 'And then they saw it was just' chosen_cause - print chosen_name 'laughed and went on with their day' - print The End - ``` - 16: - example_code: | - **Warning! This code needs to be debugged!** - ``` - country = ['The Netherlands', 'Poland', 'Turkey', 'Zimbabwe', 'Thailand', 'Brasil', 'Peru', 'Australia', 'India', 'Romania' ] - capitals = 'Amsterdam', 'Warshaw' 'Istanbul', 'Harare', 'Bangkok', 'Brasilia', 'Lima', 'Canberra', 'New Delhi', 'Bucharest' - score = 0 - for i in range 0 to 10 - answer = ask 'What's the capital of ' countries[i] - correct = capital[i] - if answer = correct - print 'Correct!' - score = score + 1 - else - print 'Wrong,' capitals[i] 'in the capital of' countries[i] - print 'You scored ' score ' out of 10' - - ``` - 17: - example_code: | - **Warning! This code needs to be debugged!** - ``` - define food_order - toppings = ask 'pepperoni, tuna, veggie or cheese?' - size = ask 'big, medium or small?' - number_of_pizza = ask 'How many these pizzas would you like?' - - print 'YOU ORDERED' - print number_of_pizzas ' size ' topping ' pizza' - - define drinks_order - drink = ask 'water, coke, icetea, lemonade or coffee?' - number_of_drinks = ask 'How many of these drinks would you like?' - - print 'YOU ORDERED' - print number_of_drinks ' ' drink - - 'Welcome to Hedy pizza' - more_food = ask 'Would you like to order a pizza?' - while more_food = 'yes' - return food_order - more_food = ask 'Would you like to order a pizza?' - more_drinks = ask 'Would you like to order some drinks?' - while more_drinks == 'yes' - call drink_order - more_drinks == ask 'Would you like to order more drinks?' - - - print 'Thanks for ordering!' - ``` - 18: - example_code: | - **Warning! This code needs to be debugged!** - ``` - animals = ['pig', 'dog', 'cow'] - sounds = ['oink', 'woof', 'moo'] - for i in range 1 to 3 - animal = animals[i] - sound = sounds[i] - print 'Old MacDonald had a farm' - print 'E I E I O!' - print 'and on that farm he had a ' animal - print 'E I E I O!' - print 'with a ' sound sound ' here' - print 'and a ' sound sound ' there' - print 'here a ' sound - print 'there a ' sound - print 'everywhere a ' sound sound - ``` default: description: Vysvětlení úrovně levels: @@ -668,12 +204,6 @@ adventures: print '5 mínus 5 je ' 5 - 5 print '5 krát 5 je ' 5 * 5 ``` - example_code: | - ``` - {print} '5 plus 5 is ' 5 + 5 - {print} '5 minus 5 is ' 5 - 5 - {print} '5 {times} 5 is ' 5 * 5 - ``` 7: story_text: |- `ask`, `print` a `if` fungují stejně jako na úrovni 5 a 6. @@ -687,53 +217,17 @@ adventures: `ask` a `print` stále fungují tak, jak je znáš. Ale `if` a `repeat` se změnily! Od teď můžeš spouštět víc řádků kódu společně, ale musíš je odsadit. To znamená, že na začátek řádku dáš čtyři mezery. To platí i v případě, že chceš vytvořit blok z pouze jednoho řádku. - - - ``` - repeat 5 times - print 'Ahoj všichni' - print 'Tohle všechno se 5krát zopakuje' - ``` example_code: | ``` {repeat} 5 {times} - {print} 'Hello everyone' - {print} 'This is all repeated 5 times' - ``` - 10: - story_text: | - In this level we learn a new code called `for`. With `for` you can make a list and use all elements. - `for` creates a block, like `repeat` and `if` so all lines in the block need to start with spaces. - - ``` - animals is dog, cat, blobfish - for animal in animals - print 'I love ' animal - ``` - example_code: | - ``` - animals {is} dog, cat, blobfish - {for} animal {in} animals - {print} 'I love ' animal + {print} 'Ahoj všichni' + {print} 'Tohle všechno se 5krát zopakuje' ``` 12: story_text: Hedy doteď neumožňovala používat čísla s desetinami jako je 1.5, ale odteď už ano. Pozor, Hedy používá desetinnou tečku `.` namísto desetinné čárky. - example_code: | - ``` - {print} 'Two and a half plus two and a half is...' - {print} 2.5 + 2.5 - ``` - print 2.5 + 2.5 13: story_text: Teď se naučíme `and` (česky a) a `or` (nebo)! Když chceš ověřit dvě podmínky, nemusíš k tomu použít dva `if`y, ale stačí ti k tomu `and` a `or`. Pokud použiješ `and`, musí být obě podmínky, napravo i nalevo, pravdivé. S `or` stačí, aby byla pravdivá alespoň jedna z nich. - 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!' - ``` 14: story_text: |- Pojďme se naučit pár nových věcí! Možná už je znáš z matematiky, jde o `<` a `>`. @@ -741,33 +235,26 @@ adventures: `>` naopak zjišťuje, jestli je první číslo větší, jako v `6 > 5`. example_code: | ``` - age = {ask} 'How old are you?' - {if} age > 12 - {print} 'You are older than I am!' - ``` - if vek < 13 print 'Jsi mladší než já!' else print 'Jsi starší než já!' + ``` 15: story_text: Naučíme se nový cyklus, konkrátně `while` cyklus! Tento cyklus se opakuje tak dlouho, dokud je jeho podmínka pravdivá. V příkladu vidíte, že kód opakujeme, dokud nedostaneme správnou odpověď. Pokud bychom ji nikdy nedostali, bude cyklus nekonečný! example_code: | ``` answer = 0 - while answer != 25 - answer = ask 'What is 5 times 5?' - print 'A correct answer has been given' + {while} answer != 25 + odpoved = {ask} 'Kolik je 5 * 5?' + {print} 'Dostala jsem správnou odpověď!' ``` - - odpoved = ask 'Kolik je 5 * 5?' - print 'Dostala jsem správnou odpověď!' 16: story_text: Už i naše seznamy mají vlastní závorky! Budeme je psát do hranatých závorek a jejich jednotlivé položky do jednoduchých uvozovek ('), které už známe. example_code: | ``` ovoce = ['jablko', 'banán', 'třešně'] - print ovoce + {print} ovoce ``` 17: story_text: |- @@ -775,652 +262,98 @@ adventures: V této úrovni můžete také použít nový příkaz: `{elif}`. Příkaz `{elif}` je zkratka z `{else} {if}` a využijete jej, když chcete provést tři (nebo více!) možností. Vyzkoušejte jej! - 18: - story_text: |- - We arrived at real Python code! That means we need to use parentheses with {print} and {range} from now on. - {print}('My name is ', naam) - dice: + haunted: + description: escape from the haunted house levels: - 3: - example_code: | - ``` - choices {is} 1, 2, 3, 4, 5, earthworm - {print} choices {at} {random} - ``` - 4: - story_text: | - In this level we can make sentences with the die value in the sentence, with quotes of course. - This time the sample code is not quite complete. Can you finish the code? - 5: + 1: story_text: | - You can also make a die again in this level using the `{if}`. - Complete the sample code so that the code says "You can stop throwing" once you have thrown an earthworm. + V tomto dobrodružství pracujete na vytvoření hry, ve které se musíte dostat z strašidelného domu tím, že si vyberete správné dveře. + Pokud vyberete správné dveře, přežijete, ale pokud ne, strašidelný monster může... - But maybe you want to recreate a die from a completely different game. That's fine too! Then make up your own reaction. Eg 'yes' for 6 and 'pity' for something {else}. + V úrovni 1 začneme naši hru ve strašidelném domě tím, že vytvoříme děsivý příběh a zeptáme se hráče, jaké monstrum uvidí ve strašidelném domě. example_code: | ``` - choices {is} 1, 2, 3, 4, 5, earthworm - throw {is} _ - {print} 'you have' _ 'thrown' - {if} _ {is} earthworm {print} 'You can stop throwing.' _ {print} 'You have to hear it again!' + {print} Jak jsem se sem dostal? + {print} Pamatuji si, jak mi kamarád řekl, abych šel do starého sídla... + {print} a najednou vše zčernalo. + {print} Ale jak jsem skončil na podlaze...? + {print} Hlava mě bolí, jako bych dostal ránu baseballovou pálkou! + {print} Co je to za zvuk? + {print} Oh ne! Mám pocit, že nejsem v tomto domě sám! + {print} Musím se odsud dostat! + {print} Před sebou mám 3 dveře... + {ask} Které dveře mám vybrat? + {echo} Vybral jsem si dveře + {print} ...? ``` - 6: + story_text_2: | + ### Cvičení + Zkopírujte ukázkový kód do své vstupní obrazovky kliknutím na žluté tlačítko. + Nyní dokončete příběh přidáním alespoň 5 řádků kódu. + Nezapomeňte začít každý řádek kódu příkazem `{print}`. + 2: story_text: | - You can also make an Earthworm die again in this, but now you can also calculate how many points have been rolled. - You may know that the worm counts 5 points for Earthworms. Now after a roll you can immediately calculate how many points you have thrown. - This is the code to calculate points for one die: + V tomto strašidelném domě si můžete vybrat svá monstra pomocí emoji. Samozřejmě můžete také použít slova. example_code: | ``` - choices = 1, 2, 3, 4, 5, earthworm - points = 0 - throw = choices {at} {random} - {print} 'you threw' throw - {if} throw {is} earthworm points = points + 5 {else} points = points + throw - {print} 'those are' points ' point' + monster_1 {is} 👻 + monster_2 {is} 🤡 + monster_3 {is} 👶 + {print} Vstupujete do strašidelného domu. + {print} Najednou uvidíte monster_1 + {print} Utíkáte do jiné místnosti... + {print} Ale monster_2 na vás tam čeká! + {print} Oh ne! Rychle se dostaňte do kuchyně. + {print} Ale když vstoupíte, monster_3 vás napadne! ``` - Can you make the code so that you get the total score for 8 dice? To do that, you have to cut and paste some lines of the code. + story_text_2: | + ### Cvičení + V příkladu výše jsou monstra předem určena. Takže pokaždé, když spustíte svůj kód, je výstup stejný. + Dokážete přidat příkazy `{ask}`, aby byl strašidelný dům interaktivní a hráči si mohli vybrat monstra, se kterými se setkají? example_code_2: | - Did you manage to calculate the score for 8 dice? That required a lot of cutting and pasting, right? We are going to make that easier in level 7! - 7: - story_text: | - You can also make a die again in level 5. With the `{repeat}` code you can easily roll a whole hand of dice. - Try to finish the sample code! The dashes should contain multiple commands and characters. - - But maybe you want to make a completely different die. Of course you can! - example_code: | - ``` - choices = 1, 2, 3, 4, 5, earthworm - {repeat} _ _ {print} _ _ _ ``` - 10: - story_text: | - Is everybody taking too long throwing the dice? In this level you can let Hedy throw all the dice at once! - example_code: | - ``` - players = Ann, John, Jesse - choices = 1, 2, 3, 4, 5, 6 - {for} player {in} players - {print} player ' throws ' choices {at} {random} - {sleep} + monster_1 {is} _ + monster_2 {is} _ + monster_3 {is} _ + {print} Vstupujete do strašidelného domu. + {print} Najednou uvidíte monster_1 + {print} Utíkáte do jiné místnosti... + {print} Ale monster_2 na vás tam čeká! + {print} Oh ne! Rychle se dostaňte do kuchyně. + {print} Ale když vstoupíte, monster_3 vás napadne! ``` - dishes: - description: Use the computer to see who does the dishes (Start at level 2) + music: + default_save_name: Hudba levels: - 3: - story_text: | - Do you always disagree at home about who should wash the dishes or change the litter box today? - Then you can let the computer choose very fairly. You can program that in this level! - You first make a list of the members of your family. Then choose '{at} {random}' from the list. - example_code: | - ``` - people {is} mom, dad, Emma, Sophie - {print} people {at} {random} - ``` - Don't feel like doing the dishes yourself? Hack the program to remove your name from the list. - - ``` - people {is} mom, dad, Emma, Sophie - your_name {is} {ask} Who are you? - {remove} your_name {from} people - {print} people {at} {random} does the dishes - ``` - story_text_2: | - Don't feel like doing the dishes yourself? Hack the program to remove your name from the list. - 4: - story_text: | - With quotation marks you can make your dishwashing planning more beautiful. - This time the sample code is not quite complete. + 1: + story_text: |- + V této úrovni se naučíte používat příkaz `{play}` k zahrání melodie! - Can you complete the code by filling the blanks? Every blank must be replaced with one word of symbol. + Napište `{play}` následované notou, kterou chcete zahrát. Stupnice obsahuje C-D-E-F-G-A-H. + Jak vidíte, je zde 7 různých písmen, ale můžeme hrát více než jen 7 not. + Za písmenem zadejte číslo mezi 0 a 9, abyste vybrali stupnici, například po H4 následuje C5. + C0 je nejnižší nota, kterou můžete zahrát, B9 je nejvyšší. - Tip: Don't forget the quotation marks! - 5: + ### Cvičení + Vyzkoušejte si ukázkový kód a pak si s ním pohrajte! Dokážete vytvořit vlastní melodii? + V další úrovni se naučíte, jak zahrát některé existující písně. + parrot: + name: Papoušek + default_save_name: Papoušek + description: Vytvořte si svého vlastního online mazlíčka papouška, který vás bude kopírovat! + levels: + 1: story_text: | - With the `{if}` you can now have more fun with choice in the program. You can have your program respond to the choice that the computer has made. - - Can you finish the code so that it prints 'too bad' when it is your turn and otherwise 'yes!'? - Don't forget the quotes! + Vytvořte si svého vlastního online mazlíčka papouška, který vás bude kopírovat! example_code: | ``` - people {is} mom, dad, Emma, Sophie - dishwasher {is} people {at} {random} - {if} dishwasher {is} Sophie {print} _ too bad I have to do the dishes _ {else} {print} 'luckily no dishes because' _ 'is already washing up' + {print} Jsem papoušek Hedy + {ask} Jaké je tvé jméno? + {echo} + {echo} ``` - 6: story_text_2: | - If you are extremely unlucky the previous program might choose you to to the dishes for the whole week! That's not fair! - To create a fairer system you can use the `{remove}` command to remove the chosen person from the list. This way you don't have to do the dishes again untill everybody has had a turn. - - Monday and tuesday are ready for you! Can you add the rest of the week? - And... can you come up with a solution for when your list is empty? - example_code_2: | - ``` - people = mom, dad, Emma, Sophie - dishwasher = people {at} {random} - {print} 'Monday the dishes are done by: ' dishwasher - {remove} dishwasher {from} people - dishwasher = people {at} {random} - {print} 'Tuesday the dishes are done by: ' dishwasher - {remove} dishwasher {from} people - dishwasher = people {at} {random} - ``` - 7: - story_text: | - With the `{repeat}` you can repeat pieces of code. You can use this to calculate who will be washing dishes for the entire week. - example_code: | - ``` - people = mom, dad, Emma, Sophie - {repeat} _ _ {print} 'the dishwasher is' _ - ``` - 10: - story_text: | - In this level you could make an even better dish washing shedule. - elif_command: - description: elif - levels: - 17: - example_code: | - ``` - prices = ['1 million dollars', 'an apple pie', 'nothing'] - your_price = prices[{random}] - {print} 'You win ' your_price - {if} your_price == '1 million dollars' : - {print} 'Yeah! You are rich!' - {elif} your_price == 'an apple pie' : - {print} 'Lovely, an apple pie!' - {else}: - {print} 'Better luck next time..' - ``` - for_command: - description: for command - levels: - 11: - story_text: |- - In this level, we add a new form of the `{for}`. In earlier levels, we used `{for}` with a list, but we can also use `{for}` with numbers. - We do that by adding a variable name, followed by `{in}` `{range}`. We then write the number to start at, `{to}` and the number to end at. - Try the example to see what happens! In this level again, you will need to use indentations in lines below the `{for}` statements. - fortune: - levels: - 1: - story_text: | - Have you ever been to a carnival and had your future predicted by a fortune teller? Or have you ever played with a magic eight ball? - Then you probably know that they can't really predict your future, but it's still fun to play! - - In the upcoming levels you can learn how to create your own fortune telling machine! - In level 1 you can start off easy by letting Hedy introduce herself as a fortune teller and let her {echo} the players' answers. - Like this: - example_code: | - ``` - {print} Hello, I'm Hedy the fortune teller! - {ask} Who are you? - {print} Let me take a look in my crystal ball - {print} I see... I see... - {echo} Your name is - ``` - - ### Exercise - Hedy now only tells you your name. Can you expand the code so that Hedy can predict more things about you? - - Obviously, Hedy isn't a very good fortune teller yet, as she can only repeat the answers that were given by the players! - Take a look in level 2 to improve your fortune teller. - story_text_2: | - ### Exercise - Hedy now only tells you your name. Can you expand the code so that Hedy can predict more things about you? - Obviously, Hedy isn't a very good fortune teller yet, as she can only repeat the answers that were given by the players! - Take a look in level 2 to improve your fortune teller. - 3: - story_text: | - In the previous levels you've created your first fortune telling machine, but Hedy couldn't really predict anything, only {echo}. - In this level you can use a variable and the `{at} {random}` command to really let Hedy choose an answer for you. Check out this code for instance: - example_code: | - In this example the player can {ask} Hedy a yes-no question and Hedy will pick a random answer for you. - ``` - {print} I’m Hedy the fortune teller! - question {is} {ask} What do you want to know? - {print} This is what you want to know: question - answers {is} yes, no, maybe - {print} My crystal ball says... - {sleep} 2 - {print} answers {at} {random} - ``` - - ### Exercises - Now, Hedy can only answer yes, no or maybe. Can you give Hedy more answer options, like 'definitely' or '{ask} again'. - story_text_2: | - ### Exercises - Now, Hedy can only answer yes, no or maybe. Can you give Hedy more answer options, like 'definitely' or '{ask} again'. - 4: - example_code: | - ``` - {print} 'Im Hedy the fortune teller!' - question {is} {ask} 'What do you want to know?' - {print} 'This is your question: ' question - answers {is} yes, no, maybe - {print} 'My crystal ball says...' - {sleep} 2 - {print} answers {at} {random} - ``` - 5: - story_text: | - In this level you'll learn to (secretly) tip the odds in your favor, when using the fortune teller! - By using `{if}` and `{else}` you can make sure that you will always get a good fotune, while other people might not. - Check out this example to find out how. - example_code: | - ``` - {print} 'Im Hedy the fortune teller!' - {print} 'I can predict {if} youll win the lottery tomorrow!' - person {is} {ask} 'Who are you?' - {if} person {is} Hedy {print} 'You will definitely win!🤩' {else} {print} 'Bad luck! Someone {else} will win!😭' - ``` - 6: - story_text: | - In this level you can use math in your predictions as a fortune teller. This allows you to make up (silly) formulas to calculate the future. - For example you could calculate how rich you'll get or how many kids you will have when you grow up. - example_code: | - ``` - {print} 'I am Hedy the fortune teller!' - {print} 'I can predict how many kids youll get when you grow up!' - age = {ask} 'How old are you?' - siblings = {ask} 'How many siblings do you have?' - length = {ask} 'How tall are you in centimetres?' - kids = length / age - kids = kids - siblings - {print} 'You will get ...' - {sleep} - {print} kids ' kids!' - ``` - - If the previous example wasn't silly enough for you, take a look at this one! - - ``` - {print} 'Im Hedy the silly fortune teller!' - {print} 'I will predict how smart you are!' - football = {ask} 'On a scale 1-10 how much do you love football?' - bananas = {ask} 'How many bananas did you eat this week?' - hygiene = {ask} 'How many times did you wash your hands today?' - result = bananas + hygiene - result = result * football - {print} 'You are ' result ' percent smart.' - ``` - 7: - story_text: | - In this level you can use the `{repeat}` command to make your machine tell multiple fortunes at once. - example_code: | - ``` - {print} 'Im Hedy the fortune teller!' - {print} 'You can {ask} 3 questions!' - {repeat} 3 {times} question = {ask} 'What do you want to know?' - answer = yes, no, maybe - {repeat} 3 {times} {print} 'My crystal ball says... ' answer {at} {random} - ``` - - ### Exercise - As you can see, the questions aren't printed in this example. That's because the variable `question` was changed 3 times. - Every time the player fills in the new answer, Hedy overwrites the previous one, so the first answer the player gave is forgotten. - This means you can't print all the questions this way. - - By using 3 different variables instead of 1 (for example `question1` , `question2` and `question3`), you could solve the problem and print the questions. - This does mean that you can only use `{repeat}` for the answers, and you will have to ask and print all the questions separately. - Can you do it? - - In the upcoming levels the layout of {repeat} command will change, which enables you to repeat multiple lines at once. - 8: - story_text: | - In the previous levels you've learned how to use repeat to make the fortune teller answer 3 questions in a row, but we had a problem with printing the questions. - Now that problem is solved, because of the new way of using the repeat command. - In the next example you can have your fortune teller {ask} 3 questions and also print them! - example_code: | - ``` - {print} 'I am Hedy the fortune teller!' - {print} 'You can {ask} me 3 questions.' - answers = yes, no, maybe - {repeat} 3 {times} - question = {ask} 'What do you want to know?' - {print} question - {sleep} - {print} 'My crystal ball says...' answers {at} {random} - ``` - 10: - story_text: | - In this level you'll learn how to program the game MASH (mansion, apartement, shack, house). In this game you can predict for all the players at once, what their future will look like. - example_code: | - ``` - houses = mansion, apartment, shack, house - loves = nobody, a royal, their neighbour, their true love - pets = dog, cat, elephant - names = Jenna, Ryan, Jim - {for} name {in} names - {print} name ' lives in a ' houses {at} {random} - {print} name ' will marry ' loves {at} {random} - {print} name ' will get a ' pets {at} {random} ' as their pet.' - {sleep} - ``` - 12: - story_text: | - In this level you can make your fortunes multiple words. Like in this example below: - example_code: | - ``` - fortunes = 'you will be rich', 'you will fall in love', 'you will slip on a banana peel' - {print} 'I will take a look in my crystall ball for your future.' - {print} 'I see... I see...' - {sleep} - {print} fortunes {at} {random} - ``` - functions: - levels: - 12: - example_code: | - ``` - sides = 'left', 'right' - limbs = 'hand', 'foot' - colors = 'red', 'blue', 'green', 'yellow' - - {define} turn - chosen_side = sides {at} {random} - chosen_limb = limbs _ - chosen_color = colors _ - {print} chosen_side ' ' chosen_limb ' on ' chosen_color - - {print} 'Lets play a game of Twister!' - {for} i {in} {range} 1 to _ - {call} turn - {sleep} 2 - ``` - 13: - story_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. - - For example in this code we've programmed the first verse of the song 'My Bonnie is over the ocean'. - In this example code the argument `place` is used. Place is a variable that is only used in the function, so an argument. - To use `place` we have programmed the line `define song with place`. - When the function is called, computer will replace the argument `place`, with the piece of text after `call song with`. - - ### Exercise - The next verse of this song goes: - - Last night as I lay on my pillow - Last night as I lay on my bed - Last night as I lay on my pillow - I dreamed that my Bonnie is dead - - Can you program this verse in the same way as the example? - 14: - example_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?' - - new_price = _ calculate_new_price {with} old_price, _ - {print} 'The new price is ' new_price ' dollar' - ``` - haunted: - description: escape from the haunted house - levels: - 1: - story_text: | - V tomto dobrodružství pracujete na vytvoření hry, ve které se musíte dostat z strašidelného domu tím, že si vyberete správné dveře. - Pokud vyberete správné dveře, přežijete, ale pokud ne, strašidelný monster může... - - V úrovni 1 začneme naši hru ve strašidelném domě tím, že vytvoříme děsivý příběh a zeptáme se hráče, jaké monstrum uvidí ve strašidelném domě. - example_code: | - ``` - {print} Jak jsem se sem dostal? - {print} Pamatuji si, jak mi kamarád řekl, abych šel do starého sídla... - {print} a najednou vše zčernalo. - {print} Ale jak jsem skončil na podlaze...? - {print} Hlava mě bolí, jako bych dostal ránu baseballovou pálkou! - {print} Co je to za zvuk? - {print} Oh ne! Mám pocit, že nejsem v tomto domě sám! - {print} Musím se odsud dostat! - {print} Před sebou mám 3 dveře... - {ask} Které dveře mám vybrat? - {echo} Vybral jsem si dveře - {print} ...? - ``` - story_text_2: | - ### Cvičení - Zkopírujte ukázkový kód do své vstupní obrazovky kliknutím na žluté tlačítko. - Nyní dokončete příběh přidáním alespoň 5 řádků kódu. - Nezapomeňte začít každý řádek kódu příkazem `{print}`. - 2: - story_text: | - V tomto strašidelném domě si můžete vybrat svá monstra pomocí emoji. Samozřejmě můžete také použít slova. - example_code: | - ``` - monster_1 {is} 👻 - monster_2 {is} 🤡 - monster_3 {is} 👶 - {print} Vstupujete do strašidelného domu. - {print} Najednou uvidíte monster_1 - {print} Utíkáte do jiné místnosti... - {print} Ale monster_2 na vás tam čeká! - {print} Oh ne! Rychle se dostaňte do kuchyně. - {print} Ale když vstoupíte, monster_3 vás napadne! - ``` - story_text_2: | - ### Cvičení - V příkladu výše jsou monstra předem určena. Takže pokaždé, když spustíte svůj kód, je výstup stejný. - Dokážete přidat příkazy `{ask}`, aby byl strašidelný dům interaktivní a hráči si mohli vybrat monstra, se kterými se setkají? - example_code_2: | - ``` - monster_1 {is} _ - monster_2 {is} _ - monster_3 {is} _ - {print} Vstupujete do strašidelného domu. - {print} Najednou uvidíte monster_1 - {print} Utíkáte do jiné místnosti... - {print} Ale monster_2 na vás tam čeká! - {print} Oh ne! Rychle se dostaňte do kuchyně. - {print} Ale když vstoupíte, monster_3 vás napadne! - ``` - 3: - story_text: | - In the previous levels you've made an introduction to your haunted house game, but as you might have noticed the story would always have a dreadful end. - In this level you can make your story more interactive by changing the outcome of the game; sometimes you'll get eaten, sometimes you'll escape! - Let Hedy decide randomly! - 4: - story_text: | - In this level you learn how to use quotation marks in your games. - Can you make your Haunted House level 4 proof? - example_code: | - ``` - {print} _Escape from the haunted house!_ - {print} _There are 3 doors in front of you..._ - choice {is} {ask} _Which door do you choose?_ - {print} _You picked door ..._ choice - monsters {is} a zombie, a vampire, NOTHING YOUVE ESCAPED - {print} _You see..._ - {sleep} - {print} monsters {at} {random} - ``` - 5: - story_text: | - Up until this level the haunted house game always asked the player to choose a door, but as you might have noticed, they didn't really have to answer correctly. - If the player filled in a completely random answer, the game would still work and the player might even win (despite not picking a door). - In this level you can only win the game by picking the same door Hedy picked randomly. - example_code: | - ``` - {print} 'Escape from the haunted house!' - {print} 'There are 3 doors in front of you...' - doors {is} 1, 2, 3 - monsters {is} werewolf, mummy, vampire, zombie - chosen_door {is} {ask} 'Which door do you choose?' - {print} 'You chose door...' chosen_door - {sleep} - correct_door {is} doors {at} {random} - {if} chosen_door {is} correct_door {print} 'Great! Youve escaped!' - {else} {print} 'Oh no! You are being eaten by a...' monsters {at} {random} - ``` - 9: - story_text: | - In this level you can use nesting, which allows you to make the haunted house even more interactive! - example_code: | - ``` - {print} 'Escape from the Haunted House!' - player = alive - doors = 1, 2, 3 - monsters = zombie, vampire, giant spider - {repeat} 3 {times} - {if} player {is} alive - correct_door {is} doors {at} {random} - {print} 'There are 3 doors in front of you...' - chosen_door = {ask} 'Which door do you choose?' - {if} chosen_door {is} correct_door - {print} 'No monsters here!' - {else} - {print} 'You are eaten by a ' monsters {at} {random} - player = dead - {else} - {print} 'GAME OVER' - {if} player {is} alive - {print} 'Great! You survived!' - ``` - ### Exercise - Now it's very hard to win this game, can you make it easier to win? - For example by only having 1 wrong door and 2 correct doors instead of 1 correct door en 2 wrong ones? - 11: - story_text: | - In this level we've changed the repeat command and we've added a line to our haunted house that tells the player in which room they are. - example_code: | - ``` - {print} 'Escape from the Haunted House!' - player {is} alive - doors = 1, 2, 3 - monsters = zombie, vampire, giant spider - {for} i {in} {range} 1 {to} 3 - {if} player {is} alive - correct_door = doors {at} {random} - {print} 'Room ' i - {print} 'There are 3 doors in front of you...' - chosendoor = {ask} 'Which door do you choose?' - {if} chosendoor {is} correct_door - {print} 'No monsters here!' - {else} - {print} 'You are eaten by a ' monsters {at} {random} - player = dead - {else} - {print} 'GAME OVER' - {if} player {is} alive - {print} 'Great! You survived!' - ``` - if_command: - description: Introducing the if command - levels: - 9: - story_text: | - In this level you can also put an {if} command inside another {if} command. - in_command: - description: Introducing the in command - levels: - 5: - example_code_2: | - ``` - animals is dog, cow, sheep - answer is ask 'What is your favorite animal?' - _ answer _ animals _ 'Mine too!' - _ _ 'My favorite animals are dogs, cows and sheep' - ``` - is_command: - description: introducing is command - levels: - 2: - story_text_2: | - ### Exercise - Time to make your own variables! - In the example code we made an example of the variable `favorite_animal`. In line 1 the variable is set, and in line 2 we haved used the variable in a print command. - Firstly, finish our example by filling in your favorite animal on the blank. Then make at least 3 of these codes yourself. Pick a variable, and set the variable with the {is} command. Then use it with a {print} command, just like we did. - 14: - example_code: | - ``` - age = {ask} 'How old are you?' - {if} age > 12 - {print} 'You are older than I am!' - ``` - example_code_3: | - ``` - name = {ask} 'What is your name?' - {if} name != 'Hedy' - {print} 'You are not Hedy' - ``` - - {if} age < 13 - {print} 'You are younger than me!' - {else} - {print} 'You are older than me!' - language: - default_save_name: language - levels: - 5: - story_text: | - Make your own program to practice your vocabulary in a new language. - - ``` - {print} 'Learn French!' - cat {is} {ask} '🐱' - {if} cat {is} chat {print} 'Terrific!' - {else} {print} 'No, cat is chat' - frog {is} {ask} '🐸' - {if} frog {is} grenouille {print} 'Super!' - {else} {print} 'No, frog is grenouille' - ``` - maths: - levels: - 6: - example_code: | - ``` - {print} '5 plus 5 is ' 5 + 5 - {print} '5 minus 5 is ' 5 - 5 - {print} '5 times 5 is ' 5 * 5 - ``` - 12: - example_code_2: | - ``` - a = 'Hello ' - b = 'world!' - {print} a + b - ``` - - {print} 2.5 + 2.5 - music: - default_save_name: Hudba - levels: - 1: - story_text: |- - V této úrovni se naučíte používat příkaz `{play}` k zahrání melodie! - - Napište `{play}` následované notou, kterou chcete zahrát. Stupnice obsahuje C-D-E-F-G-A-H. - Jak vidíte, je zde 7 různých písmen, ale můžeme hrát více než jen 7 not. - Za písmenem zadejte číslo mezi 0 a 9, abyste vybrali stupnici, například po H4 následuje C5. - C0 je nejnižší nota, kterou můžete zahrát, B9 je nejvyšší. - - ### Cvičení - Vyzkoušejte si ukázkový kód a pak si s ním pohrajte! Dokážete vytvořit vlastní melodii? - V další úrovni se naučíte, jak zahrát některé existující písně. - 6: - story_text: "Instead of playing notes, you can also play numbers now. Simply type `{play} 1` for the lowest note, `{play} 70` for the highest note, or anything in between.\n\n### Exercise\n This calls for musical maths! Try out the example code a couple of times with different starting numbers. \nThen, see if you can compose a song using the numbers.\n" - parrot: - name: Papoušek - default_save_name: Papoušek - description: Vytvořte si svého vlastního online mazlíčka papouška, který vás bude kopírovat! - levels: - 1: - story_text: | - Vytvořte si svého vlastního online mazlíčka papouška, který vás bude kopírovat! - example_code: | - ``` - {print} Jsem papoušek Hedy - {ask} Jaké je tvé jméno? - {echo} - {echo} - ``` - story_text_2: | - Můžete papouška přimět, aby se zeptal na jinou otázku? Doplňte prázdná místa v příkladu! + Můžete papouška přimět, aby se zeptal na jinou otázku? Doplňte prázdná místa v příkladu! example_code_2: | ``` {print} Jsem papoušek Hedy @@ -1455,115 +388,6 @@ adventures: {print} 🧒 Say new_word , Hedy! {print} 🦜 words {at} {random} ``` - 4: - story_text: | - In this level we have to use quotation marks with the commands `{ask}` and `{print}`. - Can you complete the code by adding quotation marks? - 5: - story_text: | - Reward your parrot {if} it says the correct word! - example_code: | - ``` - words {is} squawk, Hedy - {print} 'Train your parrot!' - new_word {is} {ask} 'Which word do you want to teach them?' - {add} new_word {to_list} words - said_word {is} words {at} {random} - {print} '🧒 Say ' new_word ', Hedy!' - {print} '🦜 ' said_word - {if} said_word {is} new_word {print} '🧒 Great job, Hedy! 🍪' - {else} {print} '🧒 No, Hedy! Say ' new_word - ``` - piggybank: - levels: - 12: - story_text: | - In this adventure you learn how to make a digital piggy bank, to calculate how much money you have and how long you need to save up to buy what you want! - example_code: | - ``` - {print} 'The digital piggy bank' - wish = {ask} 'What would you like to buy?' - price = {ask} 'How much does that cost?' - saved = {ask} 'How much money have you saved already?' - allowance = {ask} 'How much pocket money do you get per week?' - to_save = price - saved - weeks = to_save / allowance - {print} 'You can buy a ' wish ' in ' weeks ' weeks.' - 14: - example_code: | - ``` - _ calculate_budget with wish, money, allowance - to_save = wish - money - weeks = to_save / allowance - {if} wish _ money - {print} 'You need to save up some more!' - {print} 'Youll need ' weeks ' more weeks.' - {else} - {print} 'Great! You have enough' - {print} 'Lets go shopping!' - - money = {ask} 'How much money have you saved?' - wish = {ask} 'How much money do you need?' - allowance = {ask} 'How much pocket money do you get each week?' - - {call} calculate_budget with _, _, _ - ``` - pressit: - levels: - 9: - story_text: | - Now that you know how to combine statements, you can create a touch type tool with `{pressed}`. - - ### Exercise - Finish the code. Each time a random letter should be chosen, which you have to press. You get a point for a correct press, and and two points deduction for a wrong press. - **(extra)** Clear the screen after each letter, and show the user how many points they have scored. - print_command: - levels: - 18: - example_code_2: | - ``` - temperature = 25 - {print}('It is ', temperature, ' degrees outside') - ``` - - {print}('My name is ', name) - random_command: - levels: - 16: - story_text: |- - We are going to make lists the Python way, with square brackets around the lists! We also keep the quotation marks around each item like we have learned in previous levels. - We use square brackets to point out a place in a list. For example: `friends[1]` is the first name on the list of friends, as you can see in the first part of the example code. The second part of the example code shows you that we can also match 2 lists using the variable i. - repeat_command: - description: repeat command - levels: - 7: - story_text: | - ## Repeat! Repeat! Repeat! - Level 7 adds the `{repeat}` command. `{repeat}` can be used to execute one line of code multiple times. Like this: - - ### Exercise - Play around with the repeat command. Can you make the happy birthday song in only 3 lines of code instead of 4 now? - 9: - story_text: | - Great job! You've reached another new level! In the previous level you've learned to use multiple lines of code in an {if} or {repeat} command. But you can't yet combine the two... - Good news! In this level you will be allowed to put an {if} inside an {if}, or inside a {repeat} command. Putting a block of code inside another block of code is called nesting. ``` Putting a block of code inside another block of code is called nesting. - example_code: | - ``` - answer = {ask} 'Are you ready to learn something new?' - {if} answer {is} yes - {print} 'Great! You can learn to use the repeat command in the if command!' - {print} 'Hooray!' - {print} 'Hooray!' - {print} 'Hooray!' - {else} - {print} 'Maybe you should practice some more in the previous level' - repeat_command_2: - description: repeat command 2 - levels: - 7: - story_text_2: | - Another interesting thing you can so with the `{repeat}` command is using variables to set the amount of times something should be repeated. In the example code you can see that we first ask the person how old they are. - Then, in line 3, the question is repeated 'age' times. So we have used the variable 'age' with the `{repeat}` command. restaurant: name: Restaurace default_save_name: Restaurace @@ -1582,218 +406,6 @@ adventures: {print} Děkujeme za Vaši objednávku! {print} Je to na cestě! ``` - 2: - story_text: | - In level 2 you could expand your restaurant by using variables. In level 1 Hedy could only {echo} the order once and only remember the last thing that was ordered. - Now you can use variables and Hedy can remember both the food and the drinks! - example_code: | - ``` - {print} Welcome to Hedy's restaurant! - {print} Today we're serving pizza or lasagna. - food {is} {ask} What would you like to eat? - {print} Great choice! The food is my favorite! - topping {is} {ask} Would you like meat or veggies on that? - {print} food with topping is on its way! - drinks {is} {ask} What would you like to drink with that? - {print} Thank you for your order. - {print} Your food and drinks will be right there! - ``` - story_text_2: | - ### Exercise - Can you make this code more elaborate? For example by adding drinks to the order? Or...? - 3: - example_code: | - ``` - {print} Welcome to Hedy's Random Restaurant! - {print} The only restaurant that will randomly choose your meal and its price for you! - starters {is} salad, soup, carpaccio - mains {is} pizza, brussels sprouts, spaghetti - desserts {is} brownies, ice cream, french cheeses - drinks {is} cola, beer, water - prices {is} 1 dollar, 10 dollars, 100 dollars - {print} You will start with: starters {at} {random} - {print} Then we'll serve: mains {at} {random} - {print} And as dessert: desserts {at} {random} - {print} You will get a drinks {at} {random} to drink - {print} That will be: prices {at} {random} - {print} Thank you and enjoy your meal! - ``` - story_text_2: | - Does your costumer have any allergies or do they dislike certain dishes? Then you can use the `{remove}`command to remove it from your menu. - example_code_2: | - ``` - {print} Mystery milkshake - flavors {is} strawberry, chocolate, vanilla - allergies {is} {ask} Are you allergic to any falvors? - {remove} allergies {from} flavors - {print} You get a flavors {at} {random} milkshake - ``` - 4: - story_text: | - ### Exercise - Add the quotation marks to this code to make it work! Be careful: variables should not be in quotation marks. - Then, use the `{clear}` command to only show one line at a time in your output screen. - - ### Exercise 2 - Go back to the previous level and copy your restaurant code. Make the code work in this level by adding quotation marks in the right spots and add some `{clear}` commands. - 5: - story_text: | - In this level the {if} command allows you to {ask} your customers questions and give different responses to the answers. - In the example below, you see that you can {ask} the customer {if} they want to hear the specials and Hedy can respond accordingly. - example_code: | - ``` - {print} 'Welcome to Hedys restaurant!' - special {is} {ask} 'Would you like to hear our specials today?' - {if} special {is} yes {print} 'Todays special is chicken piri piri and rice.' {else} {print} 'No problem.' - food {is} {ask} 'What would you like to eat?' - {print} 'One ' food ', coming right up!' - drink {is} {ask} 'What would you like to drink with that?' - {if} drink {is} cola {print} 'Im sorry, we are out of cola!' {else} {print} 'Great choice!' - anything {is} {ask} 'Would you like anything {else}?' - {print} 'Let me repeat your order...' - {print} 'One ' food - {if} drink {is} cola {print} 'and...' {else} {print} 'One ' drink - {if} anything {is} no {print} 'Thats it!' {else} {print} 'One ' anything - {print} 'Thank you for your order and enjoy your meal!' - ``` - - ### Exercise - Can you think of more questions to {ask} the customers when they are ordering, and make up different responses to their answers by using the {if} command? - 6: - story_text: | - In this level you can use maths to calculate the total price of your customer's order, which can make your virtual restaurant more realistic. - example_code: | - You can make a simple restaurant code, like this: - ``` - {print} 'Welcome to Hedys restaurant' - {print} 'Here is our menu:' - {print} 'Our main courses are pizza, lasagne, or spaghetti' - main = {ask} 'Which main course would you like?' - price = 0 - {if} main {is} pizza price = 10 - {if} main {is} lasagne price = 12 - {if} main {is} spaghetti price = 8 - {print} 'You have ordered ' main - {print} 'That will be ' price ' dollars, please' - {print} 'Thank you, enjoy your meal!' - ``` - 7: - story_text: | - In this level you've learned how to use the {repeat} command to repeat a line of code a certain amount of times. - You can use that in your restaurant to {ask} multiple people what they'd like to eat. Like this: - - ``` - {print} 'Welcome to Hedys restaurant!' - people = {ask} 'How many people are joining us today?' - {repeat} people times food = {ask} 'What would you like to eat?' - {print} 'Thanks for your order! Its coming right up!' - ``` - example_code: | - ``` - {print} 'Welcome to Hedys restaurant!' - people = {ask} 'How many people are joining us today?' - {repeat} people times food = {ask} 'What would you like to eat?' - {print} 'Thanks for your order! Its coming right up!' - ``` - 9: - story_text: | - In this level you can use nesting to make your restaurant more realistic and more fun! - For example you would {ask} for sauce {if} somebody orders fries, but you wouldn't {if} someone orders pizza! - Check out the example, and try this at your own virtual restaurant! - example_code: | - ``` - {print} 'Welcome to Hedys restaurant!' - people = {ask} 'How many people will be joining us today?' - {print} 'Great!' - price = 0 - {repeat} people {times} - food = {ask} 'What would you like to order?' - {print} food - {if} food {is} fries - price = price + 3 - sauce = {ask} 'What kind of sauce would you like with your fries?' - {if} sauce {is} no - {print} 'no sauce' - {else} - price = price + 1 - {print} 'with ' sauce - {if} food {is} pizza - price = price + 4 - {print} 'That will be ' price ' dollar' - {print} 'Enjoy your meal!' - ``` - 10: - story_text: | - In this level you'll learn how to easily {ask} your guests' orders in a short code. - example_code: | - ``` - courses = appetizer, main course, dessert - {for} course {in} courses - food = {ask} 'What would you like to eat as your ' course '?' - {print} food ' will be your ' course - ``` - story_text_2: | - Of course, you could also order for multiple people! - example_code_2: | - ``` - courses = appetizer, main course, dessert - names = Timon, Onno - {for} name {in} names - {for} course {in} courses - food = {ask} name ', what would you like to eat as your ' course '?' - {print} name ' orders ' food ' as their ' course - ``` - 11: - story_text: | - We can use the `{for} i {in} {range} 1 {to} 5` to {print} the orders from multiple customers in an orderly manner. - example_code: | - ``` - {print} 'Welcome to Restaurant Hedy!' - people = {ask} 'For how many people would you like to order?' - {for} i {in} {range} 1 {to} people - {print} 'Order number ' i - food = {ask} 'What would you like to eat?' - {print} food - {if} food {is} fries - sauce = {ask} 'What kind of sauce would you like with that?' - {print} sauce - drinks = {ask} 'What would you like to drink?' - {print} drinks - price = 4 * people - {print} 'That will be ' price ' dollars, please!' - ``` - 12: - story_text: | - From this level on you can use decimal numbers to make you menu more realistic. - example_code: | - ``` - price = 0 - food = {ask} 'What would you like to order?' - drink = {ask} 'What would you like to drink?' - {if} food {is} 'hamburger' - price = price + 6.50 - {if} food {is} 'pizza' - price = price + 5.75 - {if} drink {is} 'water' - price = price + 1.20 - {if} drink {is} 'soda' - price = price + 2.35 - {print} 'That will be ' price ' dollar, please' - ``` - 13: - story_text: | - In this level we can use the new commands to upgrade our restaurant. - We use `{and}` to see {if} two things are both the case. - example_code: | - ``` - price = 10 - food = {ask} 'What would you like to eat?' - drinks = {ask} 'What would you like to drink?' - {if} food {is} 'sandwich' {and} drinks {is} 'juice' - {print} 'Thats our discount menu' - price = price - 3 - {print} 'That will be ' price ' dollars' - ``` rock: name: Kámen, nůžky, papír default_save_name: Kámen @@ -1820,331 +432,6 @@ adventures: {ask} Tvá volba from _ {echo} Tak tvá volba byla: ``` - 2: - story_text: | - In this level you can practise using the variables, so that you can make the rock, paper, scissors game in the next level! - example_code: | - ``` - choice {is} _ - {print} I choose choice - ``` - 3: - story_text_2: | - ### Exercise - Now you only have one player, so can you add a second player? - You can even use variables to name player 1 and player 2. - example_code_2: | - ``` - choices {is} rock, paper, scissors - {print} player 1 chooses... choices {at} {random} - {print} player 2 _ - ``` - 5: - story_text: | - In this level we can determine who won. - For that you need the new `{if}` code. - - Save your choice with the name of choice and the choice of computer as computer choice. - Then you can use `{if}` to see {if} they are the same or different. - Will you finish the code? - example_code: | - ``` - options {is} rock, paper, scissors - computer_choice {is} _ - choice {is} {ask} What do you choose? - {print} 'you chose ' _ - {print} 'computer chose ' _ - {if} _ {is} _ {print} 'tie!' {else} {print} 'no tie' - ``` - - Fill in the correct code on the blanks to see {if} it is a draw. - 9: - story_text: | - In this level you can program the whole rock, paper, scissors game by nesting the {if}-commands. Can you finish the code? - example_code: | - ``` - choices = rock, paper, scisscors - your_choice = {ask} 'What do you choose?' - {print} 'You choose ' your_choice - computer_choice = choices {at} {random} - {print} 'The computer chooses ' computer_choice - {if} computer_choice {is} your_choice - {print} 'Tie' - {if} computer_choice {is} 'rock' - {if} your_choice {is} 'paper' - {print} 'You win!' - {if} your_choice {is} 'scissors' - {print} 'You lose!' - ``` - 10: - story_text: | - Feeling too lazy to play the game yourself? Let Hedy play it for you! - example_code: | - ``` - choices = rock, paper, scissors - players = Marleen, Michael - {for} player {in} players - {print} player ' chooses ' choices {at} {random} - ``` - 13: - story_text: | - With the `{and}` command you can shorten your rock, paper, scissors code! Check out the example code below and try to finish it. - example_code: | - ``` - options = 'rock', 'paper', 'scissors' - your_choice = {ask} 'What do you choose?' - computer_choice = options {at} {random} - {print} 'You choose ' your_choice - {print} 'The computer chooses ' computer_choice - {if} computer_choice {is} your_choice - {print} 'Tie' - {if} computer_choice {is} 'rock' {and} your_choice {is} 'paper' - {print} 'You win!' - {if} computer_choice {is} 'rock' {and} your_choice {is} 'scissors' - {print} 'The computer wins!' - ``` - 15: - example_code: | - ``` - won = 'no' - options = 'rock', 'paper', 'scissors' - {while} won == 'no' - your_choice = {ask} 'What do you choose?' - computer_choice = options {at} {random} - {print} 'you chose ' your_choice - {print} 'the computer chose ' computer_choice - {if} computer_choice == your_choice - {print} 'Tie!' - {if} computer_choice == 'rock' {and} your_choice == 'scissors' - {print} 'You lose!' - {if} computer_choice == 'rock' {and} your_choice == 'paper' - {print} 'You win!' - won = 'yes' - rock_2: - levels: - 2: - story_text: | - Now that you have learned how to use the `{ask} command, you can make your rock, paper, scissors code interavtive too! - - ### Exercise - Make the rock, paper, scissors code interactive by adding the `{ask}` command and a question to your rock, paper, scissors code. - example_code: | - ``` - choice is _ - {print} I choose choice - ``` - secret: - default_save_name: language - levels: - 12: - story_text: | - In this adventure you can create your own super spy code. Encode a message that only the right agent can decipher. - If the enemy tries to crack the code, they will get some false info to waste their time. - example_code: | - ``` - name {is} {ask} 'What is your name?' - {if} name {is} '_' - a {is} 'Go to the airport ' - {else} - a {is} 'Go to the trainstation ' - password {is} {ask} 'What is the password?' - {if} password {is} _ - b {is} 'tomorrow at 02.00' - {else} - b {is} 'today at 10.00' - {print} _ _ _ - ``` - 13: - story_text: | - The code you made in the previous level can be made a lot easier in this one with the `{and}` command. - sleep_command: - description: introducing sleep command - levels: - 2: - story_text: | - ## The sleep command - Another new command in this level is `{sleep}`, which pauses your program for a second. If you type a number behind the {sleep} command, the program pauses for that amount of seconds. - songs: - levels: - 6: - story_text: | - Songs often contain a lot of repetition. Sometimes the repetition is also based on counting. - For example, in the well-known song 'Bottles of beer'. You can program that song with a little math. - example_code: | - ``` - verse = 99 - {print} verse ' bottles of beer on the wall' - {print} verse ' bottles of beer' - {print} 'Take one down, pass it around' - verse = verse - 1 - {print} verse ' bottles of beer on the wall' - ``` - - You can now repeat lines 2 to 9 as many times as you want by copying the lines. - example_code_2: | - ``` - number = 6 - number = number - 1 - print number ' little monkeys jumping on the bed' - print 'One fell off and bumped his head' - print 'Mama called the doctor and the doctor said' - print 'NO MORE MONKEYS JUMPING ON THE BED!' - sleep - ``` - 7: - story_text: | - Songs often contain a lot of repetition. For example... Baby Shark! If you sing it, you keep singing the same thing: - - Baby Shark tututudutudu
- Baby Shark tututudutudu
- Baby Shark tututudutudu
- Baby Shark - - You can make this song much shorter with a `{repeat}`! Can you finish the code? - example_code: | - ``` - {repeat} _ _ {print} 'Baby Shark tututudutudu' - {print} 'Baby Shark' - ``` - - After Baby Shark you can of course also program other songs. There are many songs with repetition. - 8: - story_text: | - In a previous level you've programmed the song 'Bottles of beer'. You made one verse and then had to copy the verses 99 times. In level 7 you can repeat the song 99 times, just by adding one simple line! - example_code: | - ``` - verse = 99 - {repeat} 99 {times} - {print} verse ' bottles of beer on the wall' - {print} verse ' bottles of beer' - {print} 'Take one down, pass it around' - verse = verse - 1 - {print} verse ' bottles of beer on the wall' - ``` - 10: - story_text: | - In this level you can easily make the childrens' song 'Five little monkeys'. Can you make the last chorus? - You can also make the whole baby shark song (including all the other sharks in the family) in only 6 lines! - Or you can make Old MacDonald with all the different animals. - example_code: | - ``` - monkeys = 5, 4, 3, 2 - {for} monkey {in} monkeys - {print} monkey ' little monkeys jumping on the bed' - {print} 'One fell off and bumped his head' - {print} 'Mama called the doctor and the doctor said' - {print} 'NO MORE MONKEYS JUMPING ON THE BED!' - ``` - - ``` - sharks = baby, mommy, daddy, grandma, grandpa - {for} shark {in} sharks - {print} shark 'tututututudu' - {print} shark 'tututututudu' - {print} shark 'tututututudu' - {print} shark - ``` - ``` - animals = pig, dog, cow - {for} animal {in} animals - {if} animal {is} pig - sound = oink - {if} animal {is} dog - sound = woof - {if} animal {is} cow - sound = moo - {print} 'Old MacDonald had a farm' - {print} 'E I E I O!' - {print} 'and on that farm he had a ' animal - {print} 'E I E I O!' - {print} 'with a ' sound sound ' here' - {print} 'and a ' sound sound ' there' - {print} 'here a ' sound - {print} 'there a ' sound - {print} 'everywhere a ' sound sound - ``` - story_text_2: | - ### Exercise 2 - Print the song Five little moneys jumping on the bed. Look up the text if you don't remember. - - **(extra)** Print the song Old MacDonald had a farm, and make sure all animals make a different sound, using an `{if}`. - 11: - story_text: | - In this level you can use the `{for} i {in} {range}` command to make songs that use counting. - example_code: | - ``` - {for} i {in} {range} 5 {to} 1 - {print} i ' little monkeys jumping on the bed' - {print} 'One fell off and bumped his head' - {print} 'Mama called the doctor and the doctor said' - {if} i {is} 1 - {print} 'PUT THOSE MONKEYS RIGHT TO BED!' - {else} - {print} 'NO MORE MONKEYS JUMPING ON THE BED!' - ``` - 12: - story_text: | - In this song we can make it even easier to program '{if} you're happy and you know it, clap your hands'. Because we can put all of the actions in a variable, check it out: - example_code: | - ``` - actions = 'clap your hands', 'stomp your feet', 'shout Hurray!' - {for} action {in} actions - {for} i {in} {range} 1 {to} 2 - {print} '{if} youre happy and you know it' - {print} action - {print} '{if} youre happy and you know it and you really want to show it' - {print} '{if} youre happy and you know it' - {print} action - ``` - 16: - story_text: | - In this level, you can program a song like OldMacDonald even more quickly. You can connect the right animal to the right sound by simply putting them in the same place in the list. - The Drunken Sailor is also quickly made in this level. You only need 8 lines for the entire song, check it out! - - ### Exercise - Complete the Old MacDonald song by setting the variable `animal` to `animals[i]` and `sound` to `sounds[i]`. - - ``` - animals = ['pig', 'dog', 'cow'] - sounds = ['oink', 'woof', 'moo'] - {for} i {in} {range} 1 {to} 3 - animal = _ - sound = _ - {print} 'Old MacDonald had a farm' - {print} 'E I E I O!' - {print} 'and on that farm he had a ' animal - {print} 'E I E I O!' - {print} 'with a ' sound sound ' here' - {print} 'and a ' sound sound ' there' - {print} 'here a ' sound - {print} 'there a ' sound - {print} 'everywhere a ' sound sound - ``` - - ``` - lines = ['what shall we do with the drunken sailor', 'shave his belly with a rusty razor', 'put him in a long boat till hes sober'] - {for} line {in} lines - {for} i {in} {range} 1 {to} 3 - {print} line - {print} 'early in the morning' - {for} i {in} {range} 1 {to} 3 - {print} 'way hay and up she rises' - {print} 'early in the morning' - ``` - songs_2: - levels: - 12: - example_code: | - ``` - {define} twinkle - {print} 'Twinkle' - {print} '...' - - {call} twinkle - {print} 'Up above the world so high' - {print} 'Like a diamond in the sky' - {call} _ - ``` tic_2: description: Zahrajte si hru Piškvorky! turtle: @@ -2256,99 +543,3 @@ adventures: story_text_2: | Nyní můžeme vylepšit program, který kreslí různé obrazce. Dokážete určit, kolikrát se musí želva otočit? Dokončete kód a nakreslete libovolný mnohoúhelník! - 9: - story_text: | - Now that we can use a `{repeat}` inside a `{repeat}`, we can create more complex figures. - - ### Exercise 1 - This code creates three black triangles, change that into five pink squares. - - **(extra)** Create a figure of your own choosing consisting of at least two different shapes types. - 10: - story_text: | - In this level you can make the turtle draw a figure. - The turtle will travel the distances in the list, one by one, making bigger and bigger steps. - ### Exercise 1 - Add a 90 degree turn in the loop, so that a spiral is drawn. - Add at least 5 numbers to the list, so the spiral grows larger. - **(extra)** can you change the spiral into another shape? Experiment with numbers for the turn! - ### Exercise 2 - The spiral is drawn outwards, make it go inwards? - turtle_draw_it: - levels: - 9: - example_code: | - Hint for the nested squares: - ``` - colors = red, blue, orange, yellow, pink, purple, green, brown, black - distance = 120 - repeat 5 times - _ - ``` - Hint for the flags: - ``` - country = ask 'which country would you like to see the flag of?' - if country is 'the Netherlands' - color_1 = red - color_2 = white - color_3 = blue - ``` - 10: - example_code: | - Hint Nested Hexagon: - ``` - distances = 100, 80, 60, 40, 20 - {for} distance {in} distances - _ - ``` - - Hint Traffic Lights: - ``` - colors = red, yellow, green - {for} chosen_color {in} colors - color _ - {repeat} _ - ``` - 12: - story_text: | - ### Exercise - Recreate the drawings with the turtle! - Hint: Bracelet designing program. Firstly, define a function **for each shape** you want to use on the bacelet. Then, add the shapes to the bacelet like this: - - Bracelet Designing program - example_code: | - ``` - {define} draw_a_square - _ - - {color} white - {turn} -90 - {forward} 300 - {turn} 180 - - {for} i {in} {range} 1 {to} 5 - {color} gray - {forward} 100 - shape = {ask} 'What kind of shape would you like next on the bracelet?' - chosen_color = {ask} 'In which color?' - {color} chosen_color - {if} shape = 'square' - {call} draw_a_square - ``` - while_command: - description: while - years: - description: Countdown to the new year! - levels: - 11: - story_text: | - In this level you can use the `{for} i {in} {range}` command to countdown to the New Year. - - ### Exercise - Fill in the blanks and make the code work! - example_code: | - ``` - for _ in _ 10 to 1 - {print} i - {print} 'Happy New Year!' - ``` diff --git a/content/adventures/cy.yaml b/content/adventures/cy.yaml index c87b4a6347a..635c646321f 100644 --- a/content/adventures/cy.yaml +++ b/content/adventures/cy.yaml @@ -1,1701 +1,4 @@ adventures: - story: - levels: - 1: - 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? - 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_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? - 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! - 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? - 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' - ``` - add_remove_command: - name: '{add} {to} & {remove} {from}' - 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. - 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. - and_or_command: - description: introducing and or - ask_command: - description: Introduction ask command - levels: - 1: - 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. - calculator: - levels: - 6: - 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_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`. - 11: - 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. - 14: - 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 - clear_command: - description: clear command - debugging: - levels: - 3: - 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} - ``` - 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! - 8: - 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: - 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!' - {else} - 'I'm sorry we don't sell that' - topping {is} {ask} 'What kind of topping would you like?' - sauce {is} {ask} 'What kind of sauce would you like?' - {print} One chosen_bread with topping and sauce. - price = amount * 6 - {print} 'That will be 'price dollar' please' - ``` - - price = amount * 6 - {print} 'That will be 'price dollar' please' - 10: - example_code: | - **Warning! This code needs to be debugged!** - ``` - names = Muad Hasan Samira Noura - activities = fly a kite, go swimming, go hiking, catch tan in the sun - {for} name {is} names - {print} At the beach name loves to activity at random - ``` - 11: - story_text: |- - ### Exercise - Debug this calender program. The output of this program is supposed to look like a list of dates. - For example: - - ``` - Hedy calender - Here are all the days of November - November 1 - November 2 - November 3 - ``` - And so on. - - Mind that you have to test your code extra carefully for the month February, because the amount of days in this month changes in leap years. - example_code: | - **Warning! This code needs to be debugged!** - ``` - print 'Hedy calender' - months_with_31 days = January, March, May, July, September, October, December - months_with_30_days = April, June, August, November - month = ask 'Which month would you like to see?' - if month in months_with_31_days - days = 31 - if month in months_with30_days - days = 30 - if month = February - leap_years = 2020, 2024, 2028, 2036, 2040, 2044, 2028 - year = ask 'What year is it?' - if year in leap_years - days = 29 - else - days = 28 - - print 'Here are all the days of ' moth - for i in range 1 to days - print month i - ``` - 12: - example_code: | - **Warning! This code needs to be debugged!** - ``` - define greet - greetings = 'Hello', 'Hi there', 'Goodevening' - print greetings at random - - define take_order - food = ask 'What would you like to eat?' - print 'One food' - drink = 'What would you like to drink?' - print 'One ' drink - more = ask 'Would you like anything else?' - if more is 'no' - print 'Alright' - else - print 'And ' more - print 'Thank you' - - print 'Welcome to our restaurant' - people = ask 'How many people are in your party tonight?' - for i in range 0 to people - call greet_costumer - ``` - 13: - example_code: | - **Warning! This code needs to be debugged!** - ``` - defin movie_recommendation with name - action_movies == 'Die Hard', 'Fast and Furious', 'Inglorious Bastards' - romance_movies = 'Love Actually', 'The Notebook', 'Titanic' - comedy_movies = 'Mr Bean' 'Barbie''Deadpool' - kids_movies = 'Minions', 'Paddington', 'Encanto' - if name is 'Camila' or name is 'Manuel' - recommended_movie = kids_movie at random - if name is 'Pedro' or 'Gabriella' - mood = ask 'What you in the mood for?' - if mood is 'action' - recommended_movie = comedy_movies at random - if mood is 'romance' - recommended_movie = romance_movies - if mood is 'comedy' - recommended_movie = comedy_movies at random - - print 'I would recommend ' recommended_movie ' for ' name - - name = ask 'Who is watching?' - recommendation = ask 'Would you like a recommendation?' - if recommendaion is 'yes' - print movie_recommendation with name - else - print 'No problem!' - ``` - 14: - example_code: | - **Warning! This code needs to be debugged!** - ``` - define calculate_heartbeat - print 'Press your fingertips gently against the side of your neck' - print '(just under your jawline)' - print 'Count the number of beats you feel for 15 seconds' - beats == ask 'How many beats do you feel in 15 seconds?' - heartbeat = beats*4 - print 'Your heartbeat is ' heartbeat - if heartbeat >= 60 or heartbeat <= 100 - print 'Your heartbeat seems fine' - else - if heartbeat > 60 - print 'Your heartbeat seems to be too low' - if heartbeat < 100 - print 'Your heartbeat seems to be too high' - print 'You might want to contact a medical professional' - - measure_heartbeat = ask 'Would you like to measure your heartbeat?' - if measure_heartbeat = 'yes' - call measure_heartbeat - else - 'no problem' - ``` - - print '(just under your jawline)' - print 'Count the number of beats you feel for 15 seconds' - beats == ask 'How many beats do you feel in 15 seconds?' - heartbeat = beats*4 - print 'Your heartbeat is ' heartbeat - if heartbeat >= 60 or heartbeat <= 100 - print 'Your heartbeat seems fine' - else - if heartbeat > 60 - print 'Your heartbeat seems to be too low' - if heartbeat < 100 - print 'Your heartbeat seems to be too high' - print 'You might want to contact a medical professional' - - measure_heartbeat = ask 'Would you like to measure your heartbeat?' - if measure_heartbeat = 'yes' - call measure_heartbeat - else - 'no problem' - 15: - example_code: | - **Warning! This code needs to be debugged!** - ``` - names = 'Tanya', 'Romy', 'Kayla', 'Aldrin', 'Ali' - verbs='walking', 'skipping', 'cycling', 'driving', 'running' - locations = 'on a mountaintop', 'in the supermarket', 'to the swimming pool' - hiding_spots = 'behind a tree', under a table', in a box' - sounds = 'a trumpet', 'a car crash', 'thunder' - causes_of_noise = 'a television', 'a kid with firecrackers', 'a magic elephant', 'a dream' - - chosen_ name = names at random - chosen_verb = verbs at random - chosen_location = 'locations at random' - chosen_sounds = noises at random - chosen_spot = hiding_spots random - chosen_causes = causes_of_noise at random - - print chosen_name ' was ' chosen_verb ' ' chosen_location - print 'when they suddenly heard a sound like ' sounds at random - print chosen_name ' looked around, but they couldn't discover where the noise came from' - print chosen_name ' hid ' chosen_spot' - print 'They tried to look around, but couldn't see anything from there' - hidden = 'yes' - while hidden = 'yes' - print chosen_name 'still didn't see anything' - answer = ask 'does ' chosen_name ' move from their hiding spot?' - if answer = 'yes' - hidden == 'no' - print 'chosen_name moved from' chosen_spot - print 'And then they saw it was just' chosen_cause - print chosen_name 'laughed and went on with their day' - print The End - ``` - 16: - example_code: | - **Warning! This code needs to be debugged!** - ``` - country = ['The Netherlands', 'Poland', 'Turkey', 'Zimbabwe', 'Thailand', 'Brasil', 'Peru', 'Australia', 'India', 'Romania' ] - capitals = 'Amsterdam', 'Warshaw' 'Istanbul', 'Harare', 'Bangkok', 'Brasilia', 'Lima', 'Canberra', 'New Delhi', 'Bucharest' - score = 0 - for i in range 0 to 10 - answer = ask 'What's the capital of ' countries[i] - correct = capital[i] - if answer = correct - print 'Correct!' - score = score + 1 - else - print 'Wrong,' capitals[i] 'in the capital of' countries[i] - print 'You scored ' score ' out of 10' - - ``` - 17: - example_code: | - **Warning! This code needs to be debugged!** - ``` - define food_order - toppings = ask 'pepperoni, tuna, veggie or cheese?' - size = ask 'big, medium or small?' - number_of_pizza = ask 'How many these pizzas would you like?' - - print 'YOU ORDERED' - print number_of_pizzas ' size ' topping ' pizza' - - define drinks_order - drink = ask 'water, coke, icetea, lemonade or coffee?' - number_of_drinks = ask 'How many of these drinks would you like?' - - print 'YOU ORDERED' - print number_of_drinks ' ' drink - - 'Welcome to Hedy pizza' - more_food = ask 'Would you like to order a pizza?' - while more_food = 'yes' - return food_order - more_food = ask 'Would you like to order a pizza?' - more_drinks = ask 'Would you like to order some drinks?' - while more_drinks == 'yes' - call drink_order - more_drinks == ask 'Would you like to order more drinks?' - - - print 'Thanks for ordering!' - ``` - 18: - example_code: | - **Warning! This code needs to be debugged!** - ``` - animals = ['pig', 'dog', 'cow'] - sounds = ['oink', 'woof', 'moo'] - for i in range 1 to 3 - animal = animals[i] - sound = sounds[i] - print 'Old MacDonald had a farm' - print 'E I E I O!' - print 'and on that farm he had a ' animal - print 'E I E I O!' - print 'with a ' sound sound ' here' - print 'and a ' sound sound ' there' - print 'here a ' sound - print 'there a ' sound - print 'everywhere a ' sound sound - ``` default: name: Cyflwyniad description: Esboniad lefel - levels: - 1: - story_text: "In Level 1 you can use the commands `{print}`, `{ask}` and `{echo}`.\n Type your code in the programming field. Or press the green button in the example code block, and the code will be typed for you!\nTry the code yourself with the green 'Run code' button under the programming field.\n\nYou can print text to the screen using the `{print}` command. \n" - 3: - story_text: | - In level 3 you can make a list. You can let the computer choose something random from the list. You do that with `{at} {random}`. - 4: - story_text: | - In level 4 `{ask}` and `{print}` have changed. - - You must put text that you want to print between quotation marks. - - This is useful, because now you can print all the words you want. Also the words you used to store something with `{is}`. - - Most programming languages also use quotation marks when printing, so we are also getting a step closer to real programming! - example_code: | - ``` - {print} 'You need to use quotation marks from now on!' - answer {is} {ask} 'What do we need to use from now on?' - {print} 'We need to use ' answer - ``` - 5: - story_text: | - In level 5 there is something new, the `{if}`! With the `{if}` you can choose between two different options. - This code prints nice if you enter Hedy as a name, and boo! if you enter something else. - `{ask}` and `{print}` still work like they did in level 4. - example_code: | - ``` - name {is} {ask} 'what is your name?' - {if} name {is} Hedy {print} 'nice' {else} {print} 'boo!' - ``` - 6: - story_text: | - In the previous level you have practiced with `{ask}` and `{if}`. For example you can ask guests what they would like to eat. - What you can't yet do though, is calculate the price for everyone's dinner. - - In the previous level you have practiced with `{ask}` and `{if}`. For example you can ask guests what they would like to eat. - What you can't yet do though, is calculate the price for everyone's dinner. - - This level makes it possible to use addition, subtraction and multiplication in your programs. This way you can calculate the prices in your restaurant, but you could also add a secret code to give your friends and family a discount. - Another option in this level is programming your own maths game, for your little brother or sister to practice their multiplications. - Go see for yourself! - example_code: | - ``` - {print} '5 plus 5 is ' 5 + 5 - {print} '5 minus 5 is ' 5 - 5 - {print} '5 times 5 is ' 5 * 5 - ``` - 7: - story_text: | - Level 7 adds the `{repeat}` command. `{repeat}` can be used to execute one line of code multiple times. - example_code: | - ``` - {repeat} 3 {times} {print} 'Hedy is fun!' - ``` - 8: - story_text: | - `{ask}` and `{print}` still work as you know them. But `{if}`, `{else}`, {pressed} and `{repeat}` have changed! - You can now execute groups of code together, but you will have to *indent* the code. - That means putting four spaces at the beginning of the line. You will also have to indent when you just want to create a block of one line. - example_code: | - This is how the `{repeat}` command works now: - ``` - {repeat} 5 {times} - {print} 'Hello everyone' - {print} 'This is all repeated 5 times' - ``` - This is how the `{if}` and `{else}` command work now: - - ``` - name = {ask} 'What is your name?' - {if} name {is} Hedy - {print} 'Welcome Hedy' - {print} 'You can play on your computer!' - {else} - {print} 'INTRUDER!' - {print} 'You cannot use this computer!' - ``` - 10: - story_text: |- - In this level we learn a new code called `{for}`. With `{for}` you can make a list and use all elements. - `{for}` creates a block, like `{repeat}` and `{if}` so all lines in the block need to start with spaces. - example_code: | - ``` - animals {is} dog, cat, blobfish - {for} animal {in} animals - {print} 'I love ' animal - ``` - 12: - story_text: |- - **Decimal numbers** - So far, Hedy did not allow for decimal numbers like 1.5, but now we do allow that. Note that computers use the `.` for decimal numbers. - example_code: | - ``` - {print} 'Two and a half plus two and a half is...' - {print} 2.5 + 2.5 - ``` - - {print} 2.5 + 2.5 - 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!' - ``` - 14: - story_text: | - We are going to learn more new items. You might know them already from mathematics, the `<` and `>`. - The `<` checks if the first number is smaller than the second, for example age `<` 12 checks if age is smaller than 12. - If you want to check if the first number is smaller or equal to the second, you can use `<=`, for example age `<=` 11. - The `>` checks if the first number is bigger than the second, for example points `>` 10 checks if points is larger than 10. - If you want to check if the first number is bigger or equal to the second, you can use `>=`, for example points `>=` 11. - You use these comparisons in an `{if}`, like this: - example_code: | - ``` - age = {ask} 'How old are you?' - {if} age > 12 - {print} 'You are older than I am!' - ``` - - {if} age < 13 - {print} 'You are younger than me!' - {else} - {print} 'You are older than me!' - 15: - story_text: |- - We are going to learn a new loop, the `{while}` loop! We continue the loop as long as the statement is true. - So don't forget to change the value in the loop. - - In the example code, we continue until a correct answer has been given. - If the correct answer is never given, the loop never ends! - example_code: | - ``` - answer = 0 - {while} answer != 25 - answer = {ask} 'What is 5 times 5?' - {print} 'A correct answer has been given' - ``` - 16: - story_text: |- - We are going to make lists the Python way, with square brackets around the lists! We also keep the quotation marks around each item like we have learned in previous levels. - You can use the square brackets as well to point out a place in the lists. - example_code: | - ``` - friends = ['Ahmed', 'Ben', 'Cayden'] - {print} friends[1] ' is the first friend on the list.' - {print} friends[2] ' is the second friend on the list.' - {print} friends[3] ' is the third friend on the list.' - #now we will match 2 lists using the variable i - lucky_numbers = [15, 18, 6] - {for} i {in} {range} 1 {to} 3 - {print} friends[i] 's lucky number is ' lucky_numbers[i] - ``` - 17: - story_text: |- - Now we are going to change indentation a little bit. Every time that we need an indentation, we need `:` at the line before the indentation. - - In this level you can also use a new command: `{elif}`. `{elif}` is short for `{else} {if}` and you need it when you want to make 3 (or more!) options. - Check it out! - 18: - story_text: |- - We arrived at real Python code! That means we need to use parentheses with {print} and {range} from now on. - {print}('My name is ', name) - dice: - levels: - 3: - example_code: | - ``` - choices {is} 1, 2, 3, 4, 5, earthworm - {print} You threw _ {at} {random} - ``` - 5: - example_code: | - ``` - choices {is} 1, 2, 3, 4, 5, earthworm - throw {is} choices {at} {random} - {print} 'you have thrown' choices - _ throw {is} earthworm {print} 'You can stop throwing.' - _ {print} 'You have to throw it again!' - ``` - 6: - story_text: | - You can also make an Earthworm die again in this, but now you can also calculate how many points have been rolled. - You may know that the worm counts 5 points for Earthworms. Now after a roll you can immediately calculate how many points you have thrown. - This is the code to calculate points for one die: - - ### Exercise - Can you make the code so that you get the total score for 8 dice? To do that, you have to cut and paste some lines of the code. - example_code: | - ``` - choices = 1, 2, 3, 4, 5, earthworm - points = 0 - throw = choices {at} {random} - {print} 'you threw' throw - {if} throw {is} earthworm points = points + 5 {else} points = points + throw - {print} 'those are' points ' point' - ``` - example_code_2: | - Did you manage to calculate the score for 8 dice? That required a lot of cutting and pasting, right? We are going to make that easier in level 7! - 7: - story_text: | - You can also make a dice again in level 5. With the `{repeat}` code you can easily roll a whole hand of dice. - - ### Exercise - Try to finish the sample code! **(extra)** Think of a game you know that involves a dice and program that using a `{repeat}`. - 10: - story_text: "Is everybody taking too long throwing the dice? In this level you can let Hedy throw all the dice at once!\n\n### Exercise \nChange the names into names of your friends or family, and finish the code.\n" - dishes: - description: Use the computer to see who does the dishes (Start at level 2) - levels: - 3: - story_text: | - Do you always disagree at home about who should wash the dishes or change the litter box today? - Then you can let the computer choose very fairly. You can program that in this level! - You first make a list of the members of your family. Then choose `{at} {random}` from the list. - example_code: | - ``` - people {is} mom, dad, Emma, Sophie - {print} people {at} {random} - ``` - story_text_2: | - Don't feel like doing the dishes yourself? Hack the program by removing your name from the list with the `{remove}` `{from}` command. - 4: - story_text: | - With quotation marks you can make your dishwashing planning more beautiful. - This time the sample code is not quite complete. - - Can you complete the code by filling the blanks? Every blank must be replaced with one word of symbol. - - Tip: Don't forget the quotation marks! - 5: - story_text: | - With the `{if}` you can now have more fun with choice in the program. You can have your program respond to the choice that the computer has made. - - Can you finish the code so that it prints 'too bad' when it is your turn and otherwise 'yes!'? - Don't forget the quotes! - example_code: "```\npeople {is} mom, dad, Emma, Sophie\ndishwasher {is} people {at} {random}\n{if} dishwasher {is} Sophie {print} _ too bad I have to do the dishes _ \n{else} {print} 'luckily no dishes because' _ 'is already washing up'\n```\n" - 6: - story_text_2: | - If you are extremely unlucky the previous program might choose you to to the dishes for the whole week! That's not fair! - To create a fairer system you can use the `{remove}` command to remove the chosen person from the list. This way you don't have to do the dishes again untill everybody has had a turn. - - Monday and tuesday are ready for you! Can you add the rest of the week? - And... can you come up with a solution for when your list is empty? - example_code_2: | - ``` - people = mom, dad, Emma, Sophie - dishwasher = people {at} {random} - {print} 'Monday the dishes are done by: ' dishwasher - {remove} dishwasher {from} people - dishwasher = people {at} {random} - {print} 'Tuesday the dishes are done by: ' dishwasher - {remove} dishwasher {from} people - dishwasher = people {at} {random} - ``` - 7: - story_text: | - With the `{repeat}` you can repeat pieces of code. You can use this to calculate who will be washing dishes for the entire week. - example_code: | - ``` - people = mom, dad, Emma, Sophie - {repeat} _ _ {print} 'the dishwasher is' _ - ``` - 10: - story_text: | - In this level you could make an even better dish washing shedule. - example_code: | - ``` - days = Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday - names = mom, dad, Emma, Sophie - _ day _ days - {print} names {at} {random} ' does the dishes on ' day - ``` - elif_command: - description: elif - levels: - 17: - example_code: | - ``` - prices = ['1 million dollars', 'an apple pie', 'nothing'] - your_price = prices[{random}] - {print} 'You win ' your_price - {if} your_price == '1 million dollars' : - {print} 'Yeah! You are rich!' - {elif} your_price == 'an apple pie' : - {print} 'Lovely, an apple pie!' - {else}: - {print} 'Better luck next time..' - ``` - for_command: - description: for command - levels: - 11: - story_text: |- - In this level, we add a new form of the `{for}`. In earlier levels, we used `{for}` with a list, but we can also use `{for}` with numbers. - We do that by adding a variable name, followed by `{in}` `{range}`. We then write the number to start at, `{to}` and the number to end at. - Try the example to see what happens! In this level again, you will need to use indentations in lines below the `{for}` statements. - fortune: - levels: - 1: - story_text_2: | - ### Exercise - Copy the example code into your inputscreen and fill in the blanks to make the code work. - **Extra** Change the code and let the fortune teller not only predict your name, but also your age, your favorite sports team or something else about yourself. - 5: - story_text: | - In this level you'll learn to (secretly) tip the odds in your favor, when using the fortune teller! - By using `{if}` and `{else}` you can make sure that you will always get a good fotune, while other people might not. - Check out this example to find out how. - example_code: | - ``` - {print} 'Im Hedy the fortune teller!' - {print} 'I can predict if youll win the lottery tomorrow!' - person {is} {ask} 'Who are you?' - {if} person {is} Hedy {print} 'You will definitely win!🤩' {else} {print} 'Bad luck! Someone else will win!😭' - ``` - 6: - example_code: | - ``` - {print} 'I am Hedy the fortune teller!' - {print} 'I can predict how many kids youll get when you grow up!' - age = {ask} 'How old are you?' - siblings = {ask} 'How many siblings do you have?' - length = {ask} 'How tall are you in centimetres?' - kids = length / age - kids = kids - siblings - {print} 'You will get ...' - {sleep} - {print} kids ' kids!' - ``` - - If the previous example wasn't silly enough for you, take a look at this one! - ``` - {print} 'Im Hedy the silly fortune teller!' - {print} 'I will predict how smart you are!' - football = {ask} 'On a scale 1-10 how much do you love football?' - bananas = {ask} 'How many bananas did you eat this week?' - hygiene = {ask} 'How many times did you wash your hands today?' - result = bananas + hygiene - result = result * football - {print} 'You are ' result ' percent smart.' - ``` - 7: - story_text: | - In this level you can use the `{repeat}` command to make your machine tell multiple fortunes at once. - example_code: | - ``` - {print} 'Im Hedy the fortune teller!' - {print} 'You can ask 3 questions!' - {repeat} 3 {times} question = {ask} 'What do you want to know?' - answer = yes, no, maybe - {repeat} 3 {times} {print} 'My crystal ball says... ' answer {at} {random} - ``` - 8: - story_text: | - In the previous levels you've learned how to use `{repeat}` to make the fortune teller answer 3 questions in a row, but we had a problem with printing the questions. - Now that problem is solved, because of the new way of using the `{repeat}` command. - In the next example you can have your fortune teller ask 3 questions and also print them! - - ### Exercise - Can you fill in right command on the blanks? - example_code: | - ``` - {print} 'I am Hedy the fortune teller!' - {print} 'You can ask me 3 questions.' - answers = yes, no, maybe - _ _ _ - question = {ask} 'What do you want to know?' - {print} question - {sleep} - {print} 'My crystal ball says...' answers {at} {random} - ``` - 10: - story_text: | - In this level you'll learn how to program the game MASH (mansion, apartment, shack, house). In this game you can predict for all the players at once, what their future will look like. - - ### Exercise 1 - Add two names to the list and see how the output of the program changes when you run it. - example_code: | - ``` - houses = mansion, apartment, shack, house - loves = nobody, a royal, their neighbour, their true love - pets = dog, cat, elephant - names = Jenna, Ryan, Jim - {for} name {in} names - {print} name ' lives in a ' houses {at} {random} - {print} name ' will marry ' loves {at} {random} - {print} name ' will get a ' pets {at} {random} ' as their pet.' - {sleep} - ``` - functions: - levels: - 12: - example_code: | - ``` - sides = 'left', 'right' - limbs = 'hand', 'foot' - colors = 'red', 'blue', 'green', 'yellow' - - {define} turn - chosen_side = sides {at} {random} - chosen_limb = limbs _ - chosen_color = colors _ - {print} chosen_side ' ' chosen_limb ' on ' chosen_color - - {print} 'Lets play a game of Twister!' - {for} i {in} {range} 1 to _ - {call} turn - {sleep} 2 - ``` - 13: - story_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. - - For example in this code we've programmed the first verse of the song 'My Bonnie is over the ocean'. - In this example code the argument `place` is used. Place is a variable that is only used in the function, so an argument. - To use `place` we have programmed the line `define song with place`. - When the function is called, computer will replace the argument `place`, with the piece of text after `call song with`. - - ### Exercise - The next verse of this song goes: - - Last night as I lay on my pillow - Last night as I lay on my bed - Last night as I lay on my pillow - I dreamed that my Bonnie is dead - - Can you program this verse in the same way as the example? - 14: - example_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?' - - new_price = _ calculate_new_price {with} old_price, _ - {print} 'The new price is ' new_price ' dollar' - ``` - haunted: - levels: - 2: - example_code: | - ``` - monster_1 {is} 👻 - monster_2 {is} 🤡 - monster_3 {is} 👶 - {print} You enter the haunted house. - {print} Suddenly you see a monster_1 - {print} You run into the other room, but a monster_2 is waiting there for you! - {print} Oh no! Quickly get to the kitchen. - {print} But as you enter monster_3 attacks you! - ``` - example_code_2: | - ``` - monster_1 {is} _ - monster_2 {is} _ - monster_3 {is} _ - {print} You enter the haunted house. - {print} Suddenly you see a monster_1 - {print} You run into the other room, but a monster_2 is waiting there for you! - {print} Oh no! Quickly get to the kitchen. - {print} But as you enter monster_3 attacks you! - ``` - 3: - story_text: | - In the previous levels you've made an introduction to your haunted house game, but as you might have noticed the story would always have a dreadful end. - In this level you can make your story more interactive by changing the outcome of the game; sometimes you'll get eaten, sometimes you'll escape! - Let Hedy decide randomly! - 11: - story_text: "In this level we've changed the `{for}` command so we can tell the player where they are. \n\n### Exercise 1\nFinish the program so the player knows which room they are in.\n\n### Exercise 2\nMake the program into an adventure by following these steps:\n\n1. Make a list of choices (like: fight or flight)\n2. Make sure the player can choose an option with `{ask}`\n3. Is answer correct? Then they may proceed to the next monster. Do they give a wrong answer? Let the player know with a `{print}`. \n\n **(extra)** If you make a wrong choice, a monster is still shown! How could you change that?\n" - if_command: - description: Introducing the if command - levels: - 9: - story_text: | - In this level you can also put an {if} command inside another {if} command. - in_command: - description: Introducing the in command - levels: - 5: - example_code_2: | - ``` - animals is dog, cow, sheep - answer is ask 'What is your favorite animal?' - _ answer _ animals _ 'Mine too!' - _ _ 'My favorite animals are dogs, cows and sheep' - ``` - is_command: - description: introducing is command - levels: - 2: - story_text_2: | - ### Exercise - Time to make your own variables! - In the example code we made an example of the variable `favorite_animal`. In line 1 the variable is set, and in line 2 we haved used the variable in a print command. - Firstly, finish our example by filling in your favorite animal on the blank. Then make at least 3 of these codes yourself. Pick a variable, and set the variable with the {is} command. Then use it with a {print} command, just like we did. - 14: - example_code: | - ``` - age = {ask} 'How old are you?' - {if} age > 12 - {print} 'You are older than I am!' - ``` - example_code_3: | - ``` - name = {ask} 'What is your name?' - {if} name != 'Hedy' - {print} 'You are not Hedy' - ``` - - {if} age < 13 - {print} 'You are younger than me!' - {else} - {print} 'You are older than me!' - language: - levels: - 5: - story_text: | - Make your own program to practice your vocabulary in a new language. - - ### Exercise - Can you make this program for a different language? Or can you add more words to the French one? - maths: - levels: - 6: - example_code: | - ``` - {print} '5 plus 5 is ' 5 + 5 - {print} '5 minus 5 is ' 5 - 5 - {print} '5 times 5 is ' 5 * 5 - ``` - 12: - example_code_2: | - ``` - a = 'Hello ' - b = 'world!' - {print} a + b - ``` - - {print} 2.5 + 2.5 - music: - levels: - 6: - story_text: "Instead of playing notes, you can also play numbers now. Simply type `{play} 1` for the lowest note, `{play} 70` for the highest note, or anything in between.\n\n### Exercise\n This calls for musical maths! Try out the example code a couple of times with different starting numbers. \nThen, see if you can compose a song using the numbers.\n" - parrot: - levels: - 1: - story_text_2: | - ### Exercise - Can you make the parrot ask a different question? Fill in the blanks in the example! - 2: - story_text: | - Create your own online pet parrot that will copy you! - example_code: | - ``` - {print} Im Hedy the parrot - name {is} {ask} whats your name? - {print} name - {sleep} - {print} squawk - {sleep} - {print} name - ``` - story_text_2: | - ### Exercise - You can use variables to make the parrot say more than only your name. Can you complete this code? - 3: - story_text: | - Teach your parrot a new word with `{add}`. - ### Exercise - How can you make your parrot say multiple words? - example_code: | - ``` - words {is} squawk, Hedy - {print} Train your parrot! - new_word {is} {ask} Which word do you want to teach them? - {add} new_word {to_list} words - {print} 🧒 Say new_word, Hedy! - {print} 🦜 words {at} {random} - ``` - 4: - story_text: | - In this level we have to use quotation marks with the commands `{ask}` and `{print}`. - Can you complete the code by adding quotation marks? - 5: - story_text: | - Reward your parrot if it says the correct word! - Finish the code by filling in the 4 missing commands. - piggybank: - levels: - 12: - story_text: | - In this adventure you learn how to make a digital piggy bank. - - ### Exercise - Finish the code to calculate how much money you have and how long you need to save up to buy what you want! - **(extra)** Maybe you have already saved some money? Deduct that from the amount you will have to save up. - 14: - example_code: | - ``` - _ calculate_budget with wish, money, allowance - to_save = wish - money - weeks = to_save / allowance - {if} wish _ money - {print} 'You need to save up some more!' - {print} 'Youll need ' weeks ' more weeks.' - {else} - {print} 'Great! You have enough' - {print} 'Lets go shopping!' - - money = {ask} 'How much money have you saved?' - wish = {ask} 'How much money do you need?' - allowance = {ask} 'How much pocket money do you get each week?' - - {call} calculate_budget with _, _, _ - ``` - pressit: - levels: - 9: - story_text: | - Now that you know how to combine statements, you can create a touch type tool with `{pressed}`. - - ### Exercise - Finish the code. Each time a random letter should be chosen, which you have to press. You get a point for a correct press, and and two points deduction for a wrong press. - **(extra)** Clear the screen after each letter, and show the user how many points they have scored. - print_command: - levels: - 18: - example_code_2: | - ``` - temperature = 25 - {print}('It is ', temperature, ' degrees outside') - ``` - - {print}('My name is ', name) - random_command: - levels: - 16: - story_text: |- - We are going to make lists the Python way, with square brackets around the lists! We also keep the quotation marks around each item like we have learned in previous levels. - We use square brackets to point out a place in a list. For example: `friends[1]` is the first name on the list of friends, as you can see in the first part of the example code. The second part of the example code shows you that we can also match 2 lists using the variable i. - repeat_command: - description: repeat command - levels: - 7: - story_text: | - ## Repeat! Repeat! Repeat! - Level 7 adds the `{repeat}` command. `{repeat}` can be used to execute one line of code multiple times. Like this: - - ### Exercise - Play around with the repeat command. Can you make the happy birthday song in only 3 lines of code instead of 4 now? - 9: - story_text: | - Great job! You've reached another new level! In the previous level you've learned to use multiple lines of code in an {if} or {repeat} command. But you can't yet combine the two... - Good news! In this level you will be allowed to put an {if} inside an {if}, or inside a {repeat} command. Putting a block of code inside another block of code is called nesting. ``` Putting a block of code inside another block of code is called nesting. - example_code: | - ``` - answer = {ask} 'Are you ready to learn something new?' - {if} answer {is} yes - {print} 'Great! You can learn to use the repeat command in the if command!' - {print} 'Hooray!' - {print} 'Hooray!' - {print} 'Hooray!' - {else} - {print} 'Maybe you should practice some more in the previous level' - repeat_command_2: - description: repeat command 2 - levels: - 7: - story_text_2: | - Another interesting thing you can so with the `{repeat}` command is using variables to set the amount of times something should be repeated. In the example code you can see that we first ask the person how old they are. - Then, in line 3, the question is repeated 'age' times. So we have used the variable 'age' with the `{repeat}` command. - restaurant: - levels: - 4: - story_text: | - ### Exercise - Add the quotation marks to this code to make it work! Be careful: variables should not be in quotation marks. - - ### Exercise 2 - Go back to the previous level and copy your restaurant code. Make the code work in this level by adding quotation marks in the right spots. - 5: - story_text: | - In this level the `{if}` command allows you to `{ask}` your customers questions and give different responses to the answers. - In the example below, you see that you can `{ask}` the customer `{if}` they want to hear the specials and Hedy can respond accordingly. - example_code: | - ``` - {print} 'Welcome to Restaurant Chez Hedy!' - special {is} {ask} 'Would you like to hear our specials today?' - {if} special {is} yes {print} 'Todays special is chicken piri piri and rice.' {else} {print} 'No problem.' - food {is} {ask} 'What would you like to eat?' - {print} 'One ' food ', coming right up!' - drink {is} {ask} 'What would you like to drink with that?' - {if} drink {is} cola {print} 'Im sorry, we are out of cola!' {else} {print} 'Great choice!' - anything {is} {ask} 'Would you like anything else?' - {print} 'Let me repeat your order...' - {print} 'One ' food - {if} drink {is} cola {print} 'and...' {else} {print} 'One ' drink - {if} anything {is} no {print} 'Thats it!' {else} {print} 'One ' anything - {print} 'Thank you for your order and enjoy your meal!' - ``` - 6: - story_text: | - In this level you can use maths to calculate the total price of your customer's order, which can make your virtual restaurant more realistic. - 7: - story_text: | - In this level you've learned how to use the `{repeat}` command to repeat a line of code a certain amount of times. - You can use that in your restaurant to `{ask}` multiple people what they'd like to eat. - - ### Exercise - Can you complete the code? Hedy needs to repeat this question as many times as there are people. So if there are 5 people, the question needs to be asked 5 times. - **(extra)** Expand your code with more questions, for example about drinks or sauce. - 9: - story_text: "In this level you can use nesting to make your restaurant more realistic and more fun!\n\n### Exercise\nThe indentation was removed in the example code. \nCan you figure out how much indentation each line needs in order for the code to work properly?\nIf the customer orders pizza, Hedy shouldn't ask what sauce the costumer wants.\n\n**(extra)** A restaurant does not stock all sauces. Make a list of available sauces and give a reply with each order whether you sell it.
\n**(extra)** Pizzas have toppings. Ask customers what they want.
\n**(extra)** Do customers want a drink? Ask them too!
\n" - 10: - example_code_2: | - ``` - _ courses = appetizer, main course, dessert - _ names = Timon, Onno - _ {for} name {in} names - _ {for} course {in} courses - _ food = {ask} name ', what would you like to eat as your ' course '?' - _ {print} name ' orders ' food ' as their ' course - ``` - 11: - story_text: | - We can use the `{for}` with `{range}` to print the orders from multiple customers in an orderly manner. - - ### Exercise - Finish the restaurant code, so that you can ask for the order of multiple people. Print the order number each time: 'Order 1', 'Order 2', etc. - Are you not sure how to go about this? Have a peek at your level 8 code. - - **(extra)** In level 9 the restaurant also used prices. You can add that here too! - 12: - story_text: | - From this level on you can use decimal numbers to make you menu more realistic. - - ### Exercise - Can you think of a code to give your friends and family a 15% discount? - rock: - default_save_name: Rock - levels: - 2: - story_text: | - In this level you can practise using the variables, so that you can make the rock, paper, scissors game in the next level! - example_code: | - ``` - _ {is} {ask} rock, paper, or scissors? - {print} I choose _ - ``` - 3: - example_code: | - ``` - choices {is} rock, paper, scissors - {print} choices {at} {random} - ``` - story_text_2: | - ### Exercise - Now you only have one player, so can you add a second player? - You can even use variables to name player 1 and player 2. - example_code_2: | - ``` - choices {is} rock, paper, scissors - {print} player 1 chooses... choices {at} {random} - {print} player 2 _ - ``` - 5: - story_text: | - In this level we can determine who won. - For that you need the new `{if}` code. - - Save your choice with the name of choice and the choice of computer as computer choice. - Then you can use `{if}` to see {if} they are the same or different. - Will you finish the code? - example_code: | - ``` - options {is} rock, paper, scissors - computer_choice {is} _ - choice {is} {ask} 'What do you choose?' - {print} 'you chose ' _ - {print} 'computer chose ' _ - {if} _ {is} _ {print} 'tie!' {else} {print} 'no tie' - ``` - - Fill in the correct code on the blanks to see {if} it is a draw. - 9: - story_text: | - In this level you can program the whole rock, paper, scissors game by nesting the {if}-commands. Can you finish the code? - example_code: | - ``` - choices = rock, paper, scissors - your_choice = {ask} 'What do you choose?' - {print} 'You choose ' your_choice - computer_choice = choices {at} {random} - {print} 'The computer chooses ' computer_choice - {if} computer_choice {is} your_choice - {print} 'Tie' - {if} computer_choice {is} rock - {if} your_choice {is} paper - {print} 'You win!' - {if} your_choice {is} scissors - {print} 'You lose!' - # finish this code - ``` - 10: - story_text: | - Feeling too lazy to play the game yourself? Let Hedy play it for you! - You only have to fill in the names of the players. - example_code: | - ``` - choices = rock, paper, scissors - players = _ - {for} player {in} players - {print} player ' chooses ' choices {at} {random} - ``` - 13: - story_text: | - With the `{and}` command you can shorten your rock, paper, scissors code! Check out the example code below and try to finish it. - rock_2: - levels: - 2: - story_text: | - Now that you have learned how to use the `{ask} command, you can make your rock, paper, scissors code interavtive too! - - ### Exercise - Make the rock, paper, scissors code interactive by adding the `{ask}` command and a question to your rock, paper, scissors code. - example_code: | - ``` - choice is _ - {print} I choose choice - ``` - secret: - levels: - 12: - story_text: | - In this adventure you can create your own super spy code. Encode a message that only the right agent can decipher. - If the enemy tries to crack the code, they will get some false info to waste their time. - - ### Exercise - Make your own secret code for your superspy. Can you make it consist of even more variables? - example_code: | - ``` - name = {ask} 'What is your name?' - {if} name {is} '_' - a = 'Go to the airport ' - {else} - a = 'Go to the trainstation ' - password = {ask} 'What is the password?' - {if} password {is} _ - b = 'tomorrow at 02.00' - {else} - b = 'today at 10.00' - {print} _ _ _ - ``` - 13: - story_text: | - Can you fill in the right command on the blank? Mind: The superspy has to answer BOTH questions correctly, before they get the confidential information! - sleep_command: - description: introducing sleep command - levels: - 2: - story_text: | - ## The sleep command - Another new command in this level is `{sleep}`, which pauses your program for a second. If you type a number behind the {sleep} command, the program pauses for that amount of seconds. - songs: - levels: - 6: - example_code_2: | - ``` - number = 6 - number = number - 1 - print number ' little monkeys jumping on the bed' - print 'One fell off and bumped his head' - print 'Mama called the doctor and the doctor said' - print 'NO MORE MONKEYS JUMPING ON THE BED!' - sleep - ``` - 7: - story_text: | - Songs often contain a lot of repetition. For example... Baby Shark! If you sing it, you keep singing the same thing: - - Baby Shark tututudutudu
- Baby Shark tututudutudu
- Baby Shark tututudutudu
- Baby Shark - - You can make this song much shorter with a `{repeat}`! Can you finish the code? - example_code: | - ``` - {repeat} _ _ {print} 'Baby Shark tututudutudu' - {print} 'Baby Shark' - ``` - - After Baby Shark you can of course also program other songs. There are many songs with repetition. - 8: - story_text: | - In a previous level you've programmed the song 'Bottles of beer'. You made one verse and then had to copy the verses 99 times. In this level you can repeat the song 99 times, just by adding one simple line! - Do you know which line of code to add on the blanks? - example_code: | - ``` - verse = 99 - _ _ _ - {print} verse ' bottles of beer on the wall' - {print} verse ' bottles of beer' - {print} 'Take one down, pass it around' - verse = verse - 1 - {print} verse ' bottles of beer on the wall' - ``` - 10: - story_text: | - In this level you can easily make the childrens' song 'Five little monkeys'. Can you make the last chorus? - You can also make the whole baby shark song (including all the other sharks in the family) in only 6 lines, using `{for}`! - Or you can make Old MacDonald with all the different animals. - - - - ### Exercises - Can you add the last verse of the monkeys on the bed, when there is only one monkey left? - - Can you make the baby shark code even shorter by using a `{repeat}` command? - - Can you add new animals to Old MacDonald's farm? - example_code: | - ``` - monkeys = 5, 4, 3, 2 - {for} monkey {in} monkeys - {print} monkey ' little monkeys jumping on the bed' - {print} 'One fell off and bumped his head' - {print} 'Mama called the doctor and the doctor said' - {print} 'NO MORE MONKEYS JUMPING ON THE BED!' - ``` - - ``` - sharks = baby, mommy, daddy, grandma, grandpa - {for} shark {in} sharks - {print} shark ' shark tututututudu' - {print} shark ' shark tututututudu' - {print} shark ' shark tututututudu' - {print} shark ' shark' - ``` - ``` - animals = pig, dog, cow - {for} animal {in} animals - {if} animal {is} pig - sound = oink - {if} animal {is} dog - sound = woof - {if} animal {is} cow - sound = moo - {print} 'Old MacDonald had a farm' - {print} 'E I E I O!' - {print} 'and on that farm he had a ' animal - {print} 'E I E I O!' - {print} 'with a ' sound sound ' here' - {print} 'and a ' sound sound ' there' - {print} 'here a ' sound - {print} 'there a ' sound - {print} 'everywhere a ' sound sound - ``` - story_text_2: | - ### Exercise 2 - Print the song Five little moneys jumping on the bed. Look up the text if you don't remember. - - **(extra)** Print the song Old MacDonald had a farm, and make sure all animals make a different sound, using an `{if}`. - 11: - story_text: | - In this level you can use the `{for} i {in} {range}` command to make songs that use counting, like the 5 little monkeys. - - ### Exercise - Fill in the blanks and make the code work! - example_code: | - ``` - _ _ _ _ 5 _ 1 - {print} i ' little monkeys jumping on the bed' - {print} 'One fell off and bumped his head' - {print} 'Mama called the doctor and the doctor said' - {if} i {is} 1 - {print} 'PUT THOSE MONKEYS RIGHT TO BED!' - {else} - {print} 'NO MORE MONKEYS JUMPING ON THE BED!' - ``` - songs_2: - levels: - 12: - example_code: | - ``` - {define} twinkle - {print} 'Twinkle' - {print} '...' - - {call} twinkle - {print} 'Up above the world so high' - {print} 'Like a diamond in the sky' - {call} _ - ``` - turtle: - levels: - 2: - story_text: | - In this level you can use variables to make the turtle interactive. For example you can ask the player how many steps the turtle must make. - example_code: | - ``` - answer {is} {ask} How many steps should the turtle make? - {forward} answer - ``` - story_text_2: | - Also, in level 1 the turtle could only turn left or right. That is a bit boring! - In level 2 he can point his nose in all directions. - - Use 90 to turn a quarter. We call this degrees. A full turn is 360 degrees. - - ### Exercise - Can you make a figure with this code? Maybe a triangle or a circle? - example_code_2: | - ``` - {print} Drawing figures - angle {is} 90 - {turn} angle - {forward} 25 - {turn} angle - {forward} 25 - ``` - 3: - story_text: | - In this level you can use use `{at} {random}` with the drawing turtle. A random choice makes the turtle walk a different path each time. - Use `{at} {random}` to choose a value from a list. - ### Exercise - Can you copy and paste lines 2 and 3 to create a longer random path? - 5: - example_code_2: | - ``` - direction {is} {ask} 'Do you want to go left, right, or straight ahead?' - if direction is left turn _ - if direction is right turn _ - forward 100 - ``` - 8: - story_text: | - Now that we can repeat several lines, we can make figures more easily. - We only have to set the angle once and then use that variable in the `{repeat}`. - example_code: | - ``` - angle = 90 - {repeat} 10 {times} - {turn} angle - {forward} 50 - ``` - story_text_2: | - Also, we can now improve the program that draws different figures. - Can you figure out how far the turtle has to turn here? Finish the code and you can draw any polygon you'd like! - 9: - story_text: | - Now that we can use a `{repeat}` inside a `{repeat}`, we can create more complex figures. - - ### Exercise 1 - This code creates three black triangles, change that into five pink squares. - - **(extra)** Create a figure of your own choosing consisting of at least two different shapes types. - 10: - story_text: | - In this level you can make the turtle draw a figure. - The turtle will travel the distances in the list, one by one, making bigger and bigger steps. - ### Exercise 1 - Add a 90 degree turn in the loop, so that a spiral is drawn. - Add at least 5 numbers to the list, so the spiral grows larger. - **(extra)** can you change the spiral into another shape? Experiment with numbers for the turn! - ### Exercise 2 - The spiral is drawn outwards, make it go inwards? - turtle_draw_it: - levels: - 9: - example_code: | - Hint for the nested squares: - ``` - colors = red, blue, orange, yellow, pink, purple, green, brown, black - distance = 120 - repeat 5 times - _ - ``` - Hint for the flags: - ``` - country = ask 'which country would you like to see the flag of?' - if country is 'the Netherlands' - color_1 = red - color_2 = white - color_3 = blue - ``` - 10: - example_code: | - Hint Nested Hexagon: - ``` - distances = 100, 80, 60, 40, 20 - {for} distance {in} distances - _ - ``` - - Hint Traffic Lights: - ``` - colors = red, yellow, green - {for} chosen_color {in} colors - color _ - {repeat} _ - ``` - 12: - story_text: | - ### Exercise - Recreate the drawings with the turtle! - Hint: Bracelet designing program. Firstly, define a function **for each shape** you want to use on the bacelet. Then, add the shapes to the bacelet like this: - - Bracelet Designing program - example_code: | - ``` - {define} draw_a_square - _ - - {color} white - {turn} -90 - {forward} 300 - {turn} 180 - - {for} i {in} {range} 1 {to} 5 - {color} gray - {forward} 100 - shape = {ask} 'What kind of shape would you like next on the bracelet?' - chosen_color = {ask} 'In which color?' - {color} chosen_color - {if} shape = 'square' - {call} draw_a_square - ``` - while_command: - description: while - years: - levels: - 11: - example_code: | - ``` - {for} number {in} {range} _ {to} _ - {print} number - {print} 'Happy New Year!' - ``` diff --git a/content/adventures/da.yaml b/content/adventures/da.yaml index d81bafbf2dc..347ff69ebf4 100644 --- a/content/adventures/da.yaml +++ b/content/adventures/da.yaml @@ -113,99 +113,6 @@ adventures: ### Opgave Tilføj en gentagelse til din egen historie. Gå tilbage til dine gemte programmer, vælg dit historieprogram fra niveau 6 og find en linje der indeholder {print} og gentag det! - 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: - 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: - 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: - example_code: | - ``` - name = 'The Queen of England' - {print} name ' was eating a piece of cake, when suddenly...' - ``` - 13: - 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' - ``` - add_remove_command: - name: '{add} {to} & {remove} {from}' - description: introducing add to and remove from - levels: - 3: - 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. - and_or_command: - description: introducing and or ask_command: description: Introduction ask command levels: @@ -225,324 +132,10 @@ adventures: description: Blackjack del 3 blackjack_4: description: Blackjack del 4 - calculator: - levels: - 6: - 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_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} _ - 11: - example_code: | - ``` - number = 10 - {for} i {in} {range} 1 to 10 - {print} i * number - ``` - 12: - story_text: | - Now you can make a calculator that works for decimal numbers. Fill in the blanks to get it to work properly! - example_code: | - ``` - number1 = {ask} 'What is the first number?' - number2 = {ask} 'What is the second number?' - answer = _ - {print} number1 ' plus ' number2 ' is ' answer - ``` calculator_2: name: Lommeregner 2 default_save_name: Lommeregner 2 description: Lommeregner 2 - clear_command: - description: clear command - debugging: - levels: - 3: - 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} - ``` - 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! - 9: - 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!' - {else} - 'I'm sorry we don't sell that' - topping {is} {ask} 'What kind of topping would you like?' - sauce {is} {ask} 'What kind of sauce would you like?' - {print} One chosen_bread with topping and sauce. - price = amount * 6 - {print} 'That will be 'price dollar' please' - ``` - - price = amount * 6 - {print} 'That will be 'price dollar' please' - 10: - example_code: | - **Warning! This code needs to be debugged!** - ``` - names = Muad Hasan Samira Noura - activities = fly a kite, go swimming, go hiking, catch tan in the sun - {for} name {is} names - {print} At the beach name loves to activity at random - ``` - 11: - story_text: |- - ### Exercise - Debug this calender program. The output of this program is supposed to look like a list of dates. - For example: - - ``` - Hedy calender - Here are all the days of November - November 1 - November 2 - November 3 - ``` - And so on. - - Mind that you have to test your code extra carefully for the month February, because the amount of days in this month changes in leap years. - example_code: | - **Warning! This code needs to be debugged!** - ``` - print 'Hedy calender' - months_with_31 days = January, March, May, July, September, October, December - months_with_30_days = April, June, August, November - month = ask 'Which month would you like to see?' - if month in months_with_31_days - days = 31 - if month in months_with30_days - days = 30 - if month = February - leap_years = 2020, 2024, 2028, 2036, 2040, 2044, 2028 - year = ask 'What year is it?' - if year in leap_years - days = 29 - else - days = 28 - - print 'Here are all the days of ' moth - for i in range 1 to days - print month i - ``` - 12: - example_code: | - **Warning! This code needs to be debugged!** - ``` - define greet - greetings = 'Hello', 'Hi there', 'Goodevening' - print greetings at random - - define take_order - food = ask 'What would you like to eat?' - print 'One food' - drink = 'What would you like to drink?' - print 'One ' drink - more = ask 'Would you like anything else?' - if more is 'no' - print 'Alright' - else - print 'And ' more - print 'Thank you' - - print 'Welcome to our restaurant' - people = ask 'How many people are in your party tonight?' - for i in range 0 to people - call greet_costumer - ``` - 13: - example_code: | - **Warning! This code needs to be debugged!** - ``` - defin movie_recommendation with name - action_movies == 'Die Hard', 'Fast and Furious', 'Inglorious Bastards' - romance_movies = 'Love Actually', 'The Notebook', 'Titanic' - comedy_movies = 'Mr Bean' 'Barbie''Deadpool' - kids_movies = 'Minions', 'Paddington', 'Encanto' - if name is 'Camila' or name is 'Manuel' - recommended_movie = kids_movie at random - if name is 'Pedro' or 'Gabriella' - mood = ask 'What you in the mood for?' - if mood is 'action' - recommended_movie = comedy_movies at random - if mood is 'romance' - recommended_movie = romance_movies - if mood is 'comedy' - recommended_movie = comedy_movies at random - - print 'I would recommend ' recommended_movie ' for ' name - - name = ask 'Who is watching?' - recommendation = ask 'Would you like a recommendation?' - if recommendaion is 'yes' - print movie_recommendation with name - else - print 'No problem!' - ``` - 14: - example_code: | - **Warning! This code needs to be debugged!** - ``` - define calculate_heartbeat - print 'Press your fingertips gently against the side of your neck' - print '(just under your jawline)' - print 'Count the number of beats you feel for 15 seconds' - beats == ask 'How many beats do you feel in 15 seconds?' - heartbeat = beats*4 - print 'Your heartbeat is ' heartbeat - if heartbeat >= 60 or heartbeat <= 100 - print 'Your heartbeat seems fine' - else - if heartbeat > 60 - print 'Your heartbeat seems to be too low' - if heartbeat < 100 - print 'Your heartbeat seems to be too high' - print 'You might want to contact a medical professional' - - measure_heartbeat = ask 'Would you like to measure your heartbeat?' - if measure_heartbeat = 'yes' - call measure_heartbeat - else - 'no problem' - ``` - - print '(just under your jawline)' - print 'Count the number of beats you feel for 15 seconds' - beats == ask 'How many beats do you feel in 15 seconds?' - heartbeat = beats*4 - print 'Your heartbeat is ' heartbeat - if heartbeat >= 60 or heartbeat <= 100 - print 'Your heartbeat seems fine' - else - if heartbeat > 60 - print 'Your heartbeat seems to be too low' - if heartbeat < 100 - print 'Your heartbeat seems to be too high' - print 'You might want to contact a medical professional' - - measure_heartbeat = ask 'Would you like to measure your heartbeat?' - if measure_heartbeat = 'yes' - call measure_heartbeat - else - 'no problem' - 15: - example_code: | - **Warning! This code needs to be debugged!** - ``` - names = 'Tanya', 'Romy', 'Kayla', 'Aldrin', 'Ali' - verbs='walking', 'skipping', 'cycling', 'driving', 'running' - locations = 'on a mountaintop', 'in the supermarket', 'to the swimming pool' - hiding_spots = 'behind a tree', under a table', in a box' - sounds = 'a trumpet', 'a car crash', 'thunder' - causes_of_noise = 'a television', 'a kid with firecrackers', 'a magic elephant', 'a dream' - - chosen_ name = names at random - chosen_verb = verbs at random - chosen_location = 'locations at random' - chosen_sounds = noises at random - chosen_spot = hiding_spots random - chosen_causes = causes_of_noise at random - - print chosen_name ' was ' chosen_verb ' ' chosen_location - print 'when they suddenly heard a sound like ' sounds at random - print chosen_name ' looked around, but they couldn't discover where the noise came from' - print chosen_name ' hid ' chosen_spot' - print 'They tried to look around, but couldn't see anything from there' - hidden = 'yes' - while hidden = 'yes' - print chosen_name 'still didn't see anything' - answer = ask 'does ' chosen_name ' move from their hiding spot?' - if answer = 'yes' - hidden == 'no' - print 'chosen_name moved from' chosen_spot - print 'And then they saw it was just' chosen_cause - print chosen_name 'laughed and went on with their day' - print The End - ``` - 16: - example_code: | - **Warning! This code needs to be debugged!** - ``` - country = ['The Netherlands', 'Poland', 'Turkey', 'Zimbabwe', 'Thailand', 'Brasil', 'Peru', 'Australia', 'India', 'Romania' ] - capitals = 'Amsterdam', 'Warshaw' 'Istanbul', 'Harare', 'Bangkok', 'Brasilia', 'Lima', 'Canberra', 'New Delhi', 'Bucharest' - score = 0 - for i in range 0 to 10 - answer = ask 'What's the capital of ' countries[i] - correct = capital[i] - if answer = correct - print 'Correct!' - score = score + 1 - else - print 'Wrong,' capitals[i] 'in the capital of' countries[i] - print 'You scored ' score ' out of 10' - - ``` - 17: - example_code: | - **Warning! This code needs to be debugged!** - ``` - define food_order - toppings = ask 'pepperoni, tuna, veggie or cheese?' - size = ask 'big, medium or small?' - number_of_pizza = ask 'How many these pizzas would you like?' - - print 'YOU ORDERED' - print number_of_pizzas ' size ' topping ' pizza' - - define drinks_order - drink = ask 'water, coke, icetea, lemonade or coffee?' - number_of_drinks = ask 'How many of these drinks would you like?' - - print 'YOU ORDERED' - print number_of_drinks ' ' drink - - 'Welcome to Hedy pizza' - more_food = ask 'Would you like to order a pizza?' - while more_food = 'yes' - return food_order - more_food = ask 'Would you like to order a pizza?' - more_drinks = ask 'Would you like to order some drinks?' - while more_drinks == 'yes' - call drink_order - more_drinks == ask 'Would you like to order more drinks?' - - - print 'Thanks for ordering!' - ``` default: name: Introduktion description: Niveau forklaring @@ -763,43 +356,6 @@ adventures: {print} 'you have' _ 'thrown' {if} _ {is} earthworm {print} 'You can stop throwing.' _ {print} 'You have to hear it again!' ``` - 6: - story_text: | - You can also make an Earthworm die again in this, but now you can also calculate how many points have been rolled. - You may know that the worm counts 5 points for Earthworms. Now after a roll you can immediately calculate how many points you have thrown. - This is the code to calculate points for one die: - - ### Exercise - Can you make the code so that you get the total score for 8 dice? To do that, you have to cut and paste some lines of the code. - example_code: | - ``` - choices = 1, 2, 3, 4, 5, earthworm - points = 0 - throw = choices {at} {random} - {print} 'you threw' throw - {if} throw {is} earthworm points = points + 5 {else} points = points + throw - {print} 'those are' points ' point' - ``` - example_code_2: | - Did you manage to calculate the score for 8 dice? That required a lot of cutting and pasting, right? We are going to make that easier in level 7! - 7: - story_text: | - You can also make a dice again in level 5. With the `{repeat}` code you can easily roll a whole hand of dice. - - ### Exercise - Try to finish the sample code! **(extra)** Think of a game you know that involves a dice and program that using a `{repeat}.` - 10: - story_text: | - Is everybody taking too long throwing the dice? In this level you can let Hedy throw all the dice at once! - Can you fill in the correct line of code on the blanks? - example_code: | - ``` - players = Ann, John, Jesse - choices = 1, 2, 3, 4, 5, 6 - _ - {print} player ' throws ' choices {at} {random} - {sleep} - ``` dishes: name: Opvask? default_save_name: Opvask @@ -892,256 +448,10 @@ adventures: _ dag _ dage {print} navne {at} {random} ' tager opvasken på ' day ``` - elif_command: - description: elif - levels: - 17: - example_code: | - ``` - prices = ['1 million dollars', 'an apple pie', 'nothing'] - your_price = prices[{random}] - {print} 'You win ' your_price - {if} your_price == '1 million dollars' : - {print} 'Yeah! You are rich!' - {elif} your_price == 'an apple pie' : - {print} 'Lovely, an apple pie!' - {else}: - {print} 'Better luck next time..' - ``` - for_command: - description: for command - fortune: - levels: - 1: - example_code: | - ``` - {print} Hello, I'm Hedy the fortune teller! - {ask} Who are you? - {print} Let me take a look in my crystal ball - {print} I see... I see... - {echo} Your name is - ``` - story_text_2: | - ### Exercise - Hedy now only tells you your name. Can you expand the code so that Hedy can predict more things about you? - Obviously, Hedy isn't a very good fortune teller yet, as she can only repeat the answers that were given by the players! - Take a look in level 2 to improve your fortune teller. - 5: - story_text: | - In this level you'll learn to (secretly) tip the odds in your favor, when using the fortune teller! - By using `{if}` and `{else}` you can make sure that you will always get a good fotune, while other people might not. - Check out this example to find out how. - example_code: | - ``` - {print} 'Im Hedy the fortune teller!' - {print} 'I can predict if youll win the lottery tomorrow!' - person {is} {ask} 'Who are you?' - {if} person {is} Hedy {print} 'You will definitely win!🤩' {else} {print} 'Bad luck! Someone else will win!😭' - ``` - 6: - example_code: | - ``` - {print} 'I am Hedy the fortune teller!' - {print} 'I can predict how many kids youll get when you grow up!' - age = {ask} 'How old are you?' - siblings = {ask} 'How many siblings do you have?' - length = {ask} 'How tall are you in centimetres?' - kids = length / age - kids = kids - siblings - {print} 'You will get ...' - {sleep} - {print} kids ' kids!' - ``` - - If the previous example wasn't silly enough for you, take a look at this one! - ``` - {print} 'Im Hedy the silly fortune teller!' - {print} 'I will predict how smart you are!' - football = {ask} 'On a scale 1-10 how much do you love football?' - bananas = {ask} 'How many bananas did you eat this week?' - hygiene = {ask} 'How many times did you wash your hands today?' - result = bananas + hygiene - result = result * football - {print} 'You are ' result ' percent smart.' - ``` - 7: - story_text: | - In this level you can use the `{repeat}` command to make your machine tell multiple fortunes at once. - example_code: | - ``` - {print} 'Im Hedy the fortune teller!' - {print} 'You can ask 3 questions!' - {repeat} 3 {times} question = {ask} 'What do you want to know?' - answer = yes, no, maybe - {repeat} 3 {times} {print} 'My crystal ball says... ' answer {at} {random} - ``` - 8: - story_text: | - In the previous levels you've learned how to use `{repeat}` to make the fortune teller answer 3 questions in a row, but we had a problem with printing the questions. - Now that problem is solved, because of the new way of using the `{repeat}` command. - In the next example you can have your fortune teller ask 3 questions and also print them! - - ### Exercise - Can you fill in the `{repeat}` command correctly on the blanks? - example_code: | - ``` - {print} 'I am Hedy the fortune teller!' - {print} 'You can ask me 3 questions.' - answers = yes, no, maybe - _ _ _ - question = {ask} 'What do you want to know?' - {print} question - {sleep} - {print} 'My crystal ball says...' answers {at} {random} - ``` - 10: - story_text: | - In this level you'll learn how to program the game MASH (mansion, apartement, shack, house). In this game you can predict for all the players at once, what their future will look like. - example_code: | - ``` - houses = mansion, apartment, shack, house - loves = nobody, a royal, their neighbour, their true love - pets = dog, cat, elephant - names = Jenna, Ryan, Jim - {for} name {in} names - {print} name ' lives in a ' houses {at} {random} - {print} name ' will marry ' loves {at} {random} - {print} name ' will get a ' pets {at} {random} ' as their pet.' - {sleep} - ``` - 12: - example_code: | - ``` - fortunes = 'you will slip on a banana peel', _ - {print} 'I will take a look in my crystall ball for your future.' - {print} 'I see... I see...' - {sleep} - {print} fortunes {at} {random} - ``` functions: name: funktioner default_save_name: funktioner description: funktioner - levels: - 12: - example_code: | - ``` - sides = 'left', 'right' - limbs = 'hand', 'foot' - colors = 'red', 'blue', 'green', 'yellow' - - {define} turn - chosen_side = sides {at} {random} - chosen_limb = limbs _ - chosen_color = colors _ - {print} chosen_side ' ' chosen_limb ' on ' chosen_color - - {print} 'Lets play a game of Twister!' - {for} i {in} {range} 1 to _ - {call} turn - {sleep} 2 - ``` - 14: - example_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?' - - new_price = _ calculate_new_price {with} old_price, _ - {print} 'The new price is ' new_price ' dollar' - ``` - haunted: - levels: - 2: - example_code: | - ``` - monster_1 {is} 👻 - monster_2 {is} 🤡 - monster_3 {is} 👶 - {print} You enter the haunted house. - {print} Suddenly you see a monster_1 - {print} You run into the other room, but a monster_2 is waiting there for you! - {print} Oh no! Quickly get to the kitchen. - {print} But as you enter monster_3 attacks you! - ``` - example_code_2: | - ``` - monster_1 {is} _ - monster_2 {is} _ - monster_3 {is} _ - {print} You enter the haunted house. - {print} Suddenly you see a monster_1 - {print} You run into the other room, but a monster_2 is waiting there for you! - {print} Oh no! Quickly get to the kitchen. - {print} But as you enter monster_3 attacks you! - ``` - 3: - story_text: | - In the previous levels you've made an introduction to your haunted house game, but as you might have noticed the story would always have a dreadful end. - In this level you can make your story more interactive by changing the outcome of the game; sometimes you'll get eaten, sometimes you'll escape! - Let Hedy decide randomly! - 4: - example_code: | - ``` - {print} _ Escape from the haunted house! _ - {print} _ There are 3 doors in front of you... _ - choice {is} {ask} _ Which door do you choose? _ - {print} _ You picked door ... _ choice - monsters {is} a zombie, a vampire, NOTHING YOUVE ESCAPED - {print} _ You see... _ - {sleep} - {print} monsters {at} {random} - ``` - 11: - story_text: | - In this level we've changed the repeat command and we've added a line to our haunted house that tells the player in which room they are. - - ### Exercise - Finish the program with the correct line of code. Mind: There are 3 rooms that the player needs to survive before they win! - example_code: | - ``` - {print} 'Escape from the Haunted House!' - player {is} alive - doors = 1, 2, 3 - monsters = zombie, vampire, giant spider - _ - {if} player {is} alive - correct_door = doors {at} {random} - {print} 'Room ' i - {print} 'There are 3 doors in front of you...' - chosendoor = {ask} 'Which door do you choose?' - {if} chosendoor {is} correct_door - {print} 'No monsters here!' - {else} - {print} 'You are eaten by a ' monsters {at} {random} - player = dead - {else} - {print} 'GAME OVER' - {if} player {is} alive - {print} 'Great! You survived!' - ``` - if_command: - description: Introducing the if command - levels: - 9: - story_text: | - In this level you can also put an {if} command inside another {if} command. - in_command: - description: Introducing the in command - levels: - 5: - example_code_2: | - ``` - animals is dog, cow, sheep - answer is ask 'What is your favorite animal?' - _ answer _ animals _ 'Mine too!' - _ _ 'My favorite animals are dogs, cows and sheep' - ``` is_command: description: introducing is command levels: @@ -1157,434 +467,12 @@ adventures: navn = Hedy svar = 20 + 4 ``` - 14: - example_code: | - ``` - age = {ask} 'How old are you?' - {if} age > 12 - {print} 'You are older than I am!' - ``` - example_code_3: | - ``` - name = {ask} 'What is your name?' - {if} name != 'Hedy' - {print} 'You are not Hedy' - ``` - - {if} age < 13 - {print} 'You are younger than me!' - {else} - {print} 'You are older than me!' - maths: - levels: - 6: - example_code: | - ``` - {print} '5 plus 5 is ' 5 + 5 - {print} '5 minus 5 is ' 5 - 5 - {print} '5 times 5 is ' 5 * 5 - ``` - 12: - example_code_2: | - ``` - a = 'Hello ' - b = 'world!' - {print} a + b - ``` - - {print} 2.5 + 2.5 - parrot: - levels: - 2: - story_text: | - Create your own online pet parrot that will copy you! - example_code: | - ``` - {print} Im Hedy the parrot - name {is} {ask} whats your name? - {print} name - {sleep} - {print} squawk - {sleep} - {print} name - ``` - story_text_2: | - ### Exercise - You can use variables to make the parrot say more than only your name. Can you complete this code? - 3: - story_text: | - Teach your parrot a new word with `{add}`. - ### Exercise - How can you make your parrot say multiple words? - example_code: | - ``` - words {is} squawk, Hedy - {print} Train your parrot! - new_word {is} {ask} Which word do you want to teach them? - {add} new_word {to_list} words - {print} 🧒 Say new_word, Hedy! - {print} 🦜 words {at} {random} - ``` - piggybank: - levels: - 12: - story_text: | - In this adventure you learn how to make a digital piggy bank. - Finish the code to calculate how much money you have and how long you need to save up to buy what you want! - pressit: - levels: - 9: - story_text: | - Now that you know how to combine statements, you can create a touch type tool with `{pressed}`. - - ### Exercise - Finish the code. Each time a random letter should be chosen, which you have to press. You get a point for a correct press, and and two points deduction for a wrong press. - **(extra)** Clear the screen after each letter, and show the user how many points they have scored. print_command: default_save_name: skriv - levels: - 18: - example_code_2: | - ``` - temperature = 25 - {print}('It is ', temperature, ' degrees outside') - ``` - - {print}('My name is ', name) - repeat_command: - description: repeat command - levels: - 7: - story_text: | - ## Repeat! Repeat! Repeat! - Level 7 adds the `{repeat}` command. `{repeat}` can be used to execute one line of code multiple times. Like this: - - ### Exercise - Play around with the repeat command. Can you make the happy birthday song in only 3 lines of code instead of 4 now? - 9: - story_text: | - Great job! You've reached another new level! In the previous level you've learned to use multiple lines of code in an {if} or {repeat} command. But you can't yet combine the two... - Good news! In this level you will be allowed to put an {if} inside an {if}, or inside a {repeat} command. Putting a block of code inside another block of code is called nesting. ``` Putting a block of code inside another block of code is called nesting. - example_code: | - ``` - answer = {ask} 'Are you ready to learn something new?' - {if} answer {is} yes - {print} 'Great! You can learn to use the repeat command in the if command!' - {print} 'Hooray!' - {print} 'Hooray!' - {print} 'Hooray!' - {else} - {print} 'Maybe you should practice some more in the previous level' - repeat_command_2: - description: repeat command 2 - levels: - 7: - story_text_2: | - Another interesting thing you can so with the `{repeat}` command is using variables to set the amount of times something should be repeated. In the example code you can see that we first ask the person how old they are. - Then, in line 3, the question is repeated 'age' times. So we have used the variable 'age' with the `{repeat}` command. - restaurant: - levels: - 3: - example_code: | - ``` - {print} Welcome to Hedy's Random Restaurant! - {print} The only restaurant that will randomly choose your meal and its price for you! - starters {is} salad, soup, carpaccio - mains {is} pizza, brussels sprouts, spaghetti - desserts {is} brownies, ice cream, french cheeses - drinks {is} cola, beer, water - prices {is} 1 dollar, 10 dollars, 100 dollars - {print} You will start with: starters {at} {random} - {print} Then we'll serve: mains {at} {random} - {print} And as dessert: desserts {at} {random} - {print} You will get a drinks {at} {random} to drink - {print} That will be: prices {at} {random} - {print} Thank you and enjoy your meal! - ``` - example_code_2: | - ``` - {print} Mystery milkshake - flavors {is} strawberry, chocolate, vanilla - allergies {is} {ask} Are you allergic to any falvors? - _ - {print} You get a flavors {at} {random} milkshake - ``` - 4: - story_text: | - ### Exercise - Add the quotation marks to this code to make it work! Be careful: variables should not be in quotation marks. - 5: - story_text: | - In this level the `{if}` command allows you to `{ask}` your customers questions and give different responses to the answers. - In the example below, you see that you can `{ask}` the customer `{if}` they want to hear the specials and Hedy can respond accordingly. - example_code: | - ``` - {print} 'Welcome to Hedys restaurant!' - special {is} {ask} 'Would you like to hear our specials today?' - {if} special {is} yes {print} 'Todays special is chicken piri piri and rice.' {else} {print} 'No problem.' - food {is} {ask} 'What would you like to eat?' - {print} 'One ' food ', coming right up!' - drink {is} {ask} 'What would you like to drink with that?' - {if} drink {is} cola {print} 'Im sorry, we are out of cola!' {else} {print} 'Great choice!' - anything {is} {ask} 'Would you like anything {else}?' - {print} 'Let me repeat your order...' - {print} 'One ' food - {if} drink {is} cola {print} 'and...' {else} {print} 'One ' drink - {if} anything {is} no {print} 'Thats it!' {else} {print} 'One ' anything - {print} 'Thank you for your order and enjoy your meal!' - ``` - 6: - story_text: | - In this level you can use maths to calculate the total price of your customer's order, which can make your virtual restaurant more realistic. - 7: - story_text: | - In this level you've learned how to use the `{repeat}` command to repeat a line of code a certain amount of times. - You can use that in your restaurant to `{ask}` multiple people what they'd like to eat. - - ### Exercise - Can you complete the code? Hedy needs to repeat this question as many times as there are people. So if there are 5 people, the question needs to be asked 5 times. - **(extra)** Expand your code with more questions, for example about drinks or sauce. - example_code: | - ``` - {print} 'Welcome to Hedys restaurant!' - people = {ask} 'How many people are joining us today?' - ``` - 9: - story_text: | - In this level you can use nesting to make your restaurant more realistic and more fun! - For example you would ask for sauce if somebody orders fries, but you wouldn't if someone orders pizza! - - ### Exercise - This is a challenge for the real brainiacs! Each line that needs indentation has been given a blank. - Can you figure out how much indentation each line needs in order for the code to work propperly? - Good luck! - TIP: If the customer orders pizza, Hedy shouldn't ask what sauce the costumer wants. - example_code: | - ``` - {print} 'Welcome to Hedys restaurant!' - people = {ask} 'How many people will be joining us today?' - {print} 'Great!' - price = 0 - {repeat} people {times} - _ food = {ask} 'What would you like to order?' - _ {print} food - _ {if} food {is} fries - _ price = price + 3 - _ sauce = {ask} 'What kind of sauce would you like with your fries?' - _ {if} sauce {is} no - _ {print} 'no sauce' - _ {else} - _ price = price + 1 - _ {print} 'with ' sauce - _ {if} food {is} pizza - _ price = price + 4 - {print} 'That will be ' price ' dollar' - {print} 'Enjoy your meal!' - ``` - 10: - example_code: | - ``` - courses = appetizer, main course, dessert - {for} course {in} courses - food = {ask} 'What would you like to eat as your ' course '?' - {print} food ' will be your ' course - ``` - example_code_2: | - ``` - _ courses = appetizer, main course, dessert - _ names = Timon, Onno - _ {for} name {in} names - _ {for} course {in} courses - _ food = {ask} name ', what would you like to eat as your ' course '?' - _ {print} name ' orders ' food ' as their ' course - ``` - 11: - story_text: | - We can use the `{for} i {in} {range} 1 {to} 5` to `{print}` the orders from multiple customers in an orderly manner. - - ### Exercise - Can you handle another indentation challenge? Get the code to work properly by adding the right amount of indentation before each line! - example_code: | - ``` - {print} 'Welcome to Restaurant Hedy!' - people = {ask} 'For how many people would you like to order?' - {for} i {in} {range} 1 {to} people - _ {print} 'Order number ' i - _ food = {ask} 'What would you like to eat?' - _ {print} food - _ {if} food {is} fries - _ sauce = {ask} 'What kind of sauce would you like with that?' - _ {print} sauce - _ drinks = {ask} 'What would you like to drink?' - _ {print} drinks - price = 4 * people - {print} 'That will be ' price ' dollars, please!' - ``` - 12: - story_text: | - From this level on you can use decimal numbers to make you menu more realistic. - - ### Exercise - Can you think of a code to give your friends and family a 15% discount? - example_code: | - ``` - price = 0 - food = {ask} 'What would you like to order?' - drink = {ask} 'What would you like to drink?' - {if} food {is} 'hamburger' - price = price + 6.50 - {if} food {is} 'pizza' - price = price + 5.75 - {if} drink {is} 'water' - price = price + 1.20 - {if} drink {is} 'soda' - price = price + 2.35 - {print} 'That will be ' price ' dollar, please' - ``` - 13: - example_code: | - ``` - price = 10 - food = {ask} 'What would you like to eat?' - drinks = {ask} 'What would you like to drink?' - {if} food {is} 'sandwich' {and} drinks {is} 'juice' - {print} 'Thats our discount menu' - price = price - 3 - {print} 'That will be ' price ' dollars' - ``` - rock: - default_save_name: Rock - levels: - 2: - example_code: | - ``` - _ {is} {ask} rock, paper, or scissors? - {print} I choose _ - ``` - 3: - example_code: | - ``` - choices {is} rock, paper, scissors - {print} choices {at} {random} - ``` - story_text_2: | - ### Exercise - Now you only have one player, so can you add a second player? - You can even use variables to name player 1 and player 2. - example_code_2: | - ``` - choices {is} rock, paper, scissors - {print} player 1 chooses... choices {at} {random} - {print} player 2 _ - ``` - 5: - story_text: | - In this level we can determine who won. - For that you need the new `{if}` code. - - Save your choice with the name of choice and the choice of computer as computer choice. - Then you can use `{if}` to see if they are the same or different. - Will you finish the code? - example_code: | - ``` - options {is} rock, paper, scissors - computer_choice {is} _ - choice {is} {ask} 'What do you choose?' - {print} 'you chose ' _ - {print} 'computer chose ' _ - {if} _ {is} _ {print} 'tie!' {else} {print} 'no tie' - ``` - - Fill in the correct code on the blanks to see {if} it is a draw. - 9: - story_text: | - In this level you can program the whole rock, paper, scissors game by nesting the `{if}` commands. Can you finish the code? - 10: - story_text: | - Feeling too lazy to play the game yourself? Let Hedy play it for you! - You only have to fill in the names of the players. - example_code: | - ``` - choices = rock, paper, scissors - players = _ - {for} player {in} players - {print} player ' chooses ' choices {at} {random} - ``` - rock_2: - levels: - 2: - story_text: | - Now that you have learned how to use the `{ask} command, you can make your rock, paper, scissors code interavtive too! - - ### Exercise - Make the rock, paper, scissors code interactive by adding the `{ask}` command and a question to your rock, paper, scissors code. - example_code: | - ``` - choice is _ - {print} I choose choice - ``` - secret: - levels: - 12: - example_code: | - ``` - name = {ask} 'What is your name?' - {if} name {is} '_' - a = 'Go to the airport ' - {else} - a = 'Go to the trainstation ' - password = {ask} 'What is the password?' - {if} password {is} _ - b = 'tomorrow at 02.00' - {else} - b = 'today at 10.00' - {print} _ _ _ - ``` - 13: - story_text: | - Can you fill in the right command on the blank? Mind: The superspy has to answer BOTH questions correctly, before they get the confidential information! - sleep_command: - description: introducing sleep command - levels: - 2: - story_text: | - ## The sleep command - Another new command in this level is `{sleep}`, which pauses your program for a second. If you type a number behind the {sleep} command, the program pauses for that amount of seconds. songs: levels: - 8: - example_code: | - ``` - verse = 99 - _ _ _ - {print} verse ' bottles of beer on the wall' - {print} verse ' bottles of beer' - {print} 'Take one down, pass it around' - verse = verse - 1 - {print} verse ' bottles of beer on the wall' - ``` - 10: - story_text_2: | - ### Exercise 2 - Print the song Five little moneys jumping on the bed. Look up the text if you don't remember. - - **(extra)** Print the song Old MacDonald had a farm, and make sure all animals make a different sound, using an `{if}`. 16: example_code: "```\nalle_dyr = ['gris', 'hund', 'ko']\nlyde = ['øh', 'vuf', 'muh']\n{for} i {in} {range} 1 {to} 3\n dyr = alle_dyr[i]\n lyd = lyde[i]\n {print} 'Jens Hansen havde en bondegård'\n {print} 'ih ah ih ah oh!'\n {print} 'og på den gård der var en ' dyr\n {print} 'ih ah ih ah oh!'\n {print} 'Der var ' lyd lyd' her'\n {print} 'og ' lyd lyd' der'\n {print} lyde ' her'\n {print} lyde ' der'\n {print} 'alle steder ' lyde lyde\n```\n\n```\nlinjer = ['Hvad skal vi gøre med den fulde sømand', 'Smid ham i brummen til han vågner', 'Han skal klynges op i masten']\n{for} linje {in} linjer\n {for} i {in} {range} 1 {to} 3\n {print} linje \n {print} 'Tidligt om morgnen.'\n {for} i {in} {range} 1 {to} 3\n {print} 'Hu hej, se hun sejler'\n {print} 'Tidligt om morgnen.'\n```\n" - songs_2: - levels: - 12: - example_code: | - ``` - {define} twinkle - {print} 'Twinkle' - {print} '...' - - {call} twinkle - {print} 'Up above the world so high' - {print} 'Like a diamond in the sky' - {call} _ - ``` tic: name: Kryds og Bolle tic_2: @@ -1678,13 +566,6 @@ adventures: {turn} vinkel {forward} 25 ``` - example_code_2: | - ``` - direction {is} {ask} 'Do you want to go left, right, or straight ahead?' - if direction is left turn _ - if direction is right turn _ - forward 100 - ``` 6: story_text: | På dette niveau kan du bruge beregninger til at tegne forskellige figurer. @@ -1736,59 +617,3 @@ adventures: Denne kode skaber tre sorte trekanter og fem lyserøde firkanter. **(ekstra)** Lav en figur du selv vælger bestående af mindst to forskellige former. - turtle_draw_it: - levels: - 10: - example_code: | - Hint Nested Hexagon: - ``` - distances = 100, 80, 60, 40, 20 - {for} distance {in} distances - _ - ``` - - Hint Traffic Lights: - ``` - colors = red, yellow, green - {for} chosen_color {in} colors - color _ - {repeat} _ - ``` - 12: - story_text: | - ### Exercise - Recreate the drawings with the turtle! - Hint: Bracelet designing program. Firstly, define a function **for each shape** you want to use on the bacelet. Then, add the shapes to the bacelet like this: - - Bracelet Designing program - example_code: | - ``` - {define} draw_a_square - _ - - {color} white - {turn} -90 - {forward} 300 - {turn} 180 - - {for} i {in} {range} 1 {to} 5 - {color} gray - {forward} 100 - shape = {ask} 'What kind of shape would you like next on the bracelet?' - chosen_color = {ask} 'In which color?' - {color} chosen_color - {if} shape = 'square' - {call} draw_a_square - ``` - while_command: - description: while - years: - description: Countdown to the new year! - levels: - 11: - example_code: | - ``` - {for} _ {in} _ 10 {to} 1 - {print} i - {print} 'Happy New Year!' - ``` diff --git a/content/adventures/de.yaml b/content/adventures/de.yaml index cfd8f056ca9..411f028e017 100644 --- a/content/adventures/de.yaml +++ b/content/adventures/de.yaml @@ -1185,7 +1185,7 @@ adventures: ``` 17: story_text: |- - ### Exercise + ### Übung Debugge diesen Code. Viel Glück! example_code: | **Warnung! Dieser Code muss debugged werden!** diff --git a/content/adventures/el.yaml b/content/adventures/el.yaml index fce12456e36..b137ba25807 100644 --- a/content/adventures/el.yaml +++ b/content/adventures/el.yaml @@ -23,23 +23,6 @@ adventures: Θα πρέπει να γράψεις λίγο παραπάνω κώδικα γι'αυτό. Τώρα θα πρέπει πρώτα να ονοματίσεις το βασικό σου χαρακτήρα πρώτα. Έπειτα μπορείς να τοποθετήσεις αυτό το όνομα οπουδήποτε στην πρόταση. - 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 He hears crazy noises everywhere - 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: | Μπορείς επίσης να προσθέσεις κάτι τυχαίο στην ιστορία σου. Οποιοδήποτε τέρας, ζώο ή άλλο εμπόδιο. @@ -50,18 +33,6 @@ adventures: animals is κουκουβάγια, σκαντζόχοιρος, αρμαντίλο print Τώρα ακούει τον ήχο ένος animals at random ``` - story_text_2: | - The command `{add}` can also come in handy in your story. For example - example_code_2: | - ``` - {print} He hears a sound - animals {is} 🐿, 🦔, 🦇, 🦉 - animal {is} {ask} What do you think it is? - {add} animal {to_list} animals - {print} it was a animals {at} {random} - ``` - story_text_3: | - This is an example of the `{remove}` command in your story 5: story_text: | Στο επίπεδο 4 μπορείς να κάνεις την ιστορία σου ακόμα πιο διασκεδαστική. Στο επίπεδο 4 μπορείς να προγραμματίσεις διαφορετικά φινάλε. @@ -91,61 +62,6 @@ adventures: repeat 5 times print 'Βοήθεια!' print 'Γιατί δε με βοηθάει κανείς;' ``` - 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! - 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'. - 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. - add_remove_command: - name: '{add} {to} & {remove} {from}' - 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. - 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. - and_or_command: - description: introducing and or - ask_command: - description: Introduction ask command - levels: - 1: - 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. calculator: name: Αριθμομηχανή default_save_name: Αριθμομηχανή @@ -176,372 +92,6 @@ adventures: if answer is correct_answer print 'οκ' else print 'λάθος! ήταν ' correct_answer ``` - 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`. - 11: - example_code: | - ``` - number = 10 - {for} i {in} {range} 1 to 10 - {print} i * number - ``` - 12: - story_text: | - Now you can make a calculator that works for decimal numbers. - 14: - 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 - clear_command: - description: clear command - debugging: - levels: - 3: - 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} - ``` - 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! - 8: - 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: - 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!' - {else} - 'I'm sorry we don't sell that' - topping {is} {ask} 'What kind of topping would you like?' - sauce {is} {ask} 'What kind of sauce would you like?' - {print} One chosen_bread with topping and sauce. - price = amount * 6 - {print} 'That will be 'price dollar' please' - ``` - - price = amount * 6 - {print} 'That will be 'price dollar' please' - 10: - example_code: | - **Warning! This code needs to be debugged!** - ``` - names = Muad Hasan Samira Noura - activities = fly a kite, go swimming, go hiking, catch tan in the sun - {for} name {is} names - {print} At the beach name loves to activity at random - ``` - 11: - story_text: |- - ### Exercise - Debug this calender program. The output of this program is supposed to look like a list of dates. - For example: - - ``` - Hedy calender - Here are all the days of November - November 1 - November 2 - November 3 - ``` - And so on. - - Mind that you have to test your code extra carefully for the month February, because the amount of days in this month changes in leap years. - example_code: | - **Warning! This code needs to be debugged!** - ``` - print 'Hedy calender' - months_with_31 days = January, March, May, July, September, October, December - months_with_30_days = April, June, August, November - month = ask 'Which month would you like to see?' - if month in months_with_31_days - days = 31 - if month in months_with30_days - days = 30 - if month = February - leap_years = 2020, 2024, 2028, 2036, 2040, 2044, 2028 - year = ask 'What year is it?' - if year in leap_years - days = 29 - else - days = 28 - - print 'Here are all the days of ' moth - for i in range 1 to days - print month i - ``` - 12: - example_code: | - **Warning! This code needs to be debugged!** - ``` - define greet - greetings = 'Hello', 'Hi there', 'Goodevening' - print greetings at random - - define take_order - food = ask 'What would you like to eat?' - print 'One food' - drink = 'What would you like to drink?' - print 'One ' drink - more = ask 'Would you like anything else?' - if more is 'no' - print 'Alright' - else - print 'And ' more - print 'Thank you' - - print 'Welcome to our restaurant' - people = ask 'How many people are in your party tonight?' - for i in range 0 to people - call greet_costumer - ``` - 13: - example_code: | - **Warning! This code needs to be debugged!** - ``` - defin movie_recommendation with name - action_movies == 'Die Hard', 'Fast and Furious', 'Inglorious Bastards' - romance_movies = 'Love Actually', 'The Notebook', 'Titanic' - comedy_movies = 'Mr Bean' 'Barbie''Deadpool' - kids_movies = 'Minions', 'Paddington', 'Encanto' - if name is 'Camila' or name is 'Manuel' - recommended_movie = kids_movie at random - if name is 'Pedro' or 'Gabriella' - mood = ask 'What you in the mood for?' - if mood is 'action' - recommended_movie = comedy_movies at random - if mood is 'romance' - recommended_movie = romance_movies - if mood is 'comedy' - recommended_movie = comedy_movies at random - - print 'I would recommend ' recommended_movie ' for ' name - - name = ask 'Who is watching?' - recommendation = ask 'Would you like a recommendation?' - if recommendaion is 'yes' - print movie_recommendation with name - else - print 'No problem!' - ``` - 14: - example_code: | - **Warning! This code needs to be debugged!** - ``` - define calculate_heartbeat - print 'Press your fingertips gently against the side of your neck' - print '(just under your jawline)' - print 'Count the number of beats you feel for 15 seconds' - beats == ask 'How many beats do you feel in 15 seconds?' - heartbeat = beats*4 - print 'Your heartbeat is ' heartbeat - if heartbeat >= 60 or heartbeat <= 100 - print 'Your heartbeat seems fine' - else - if heartbeat > 60 - print 'Your heartbeat seems to be too low' - if heartbeat < 100 - print 'Your heartbeat seems to be too high' - print 'You might want to contact a medical professional' - - measure_heartbeat = ask 'Would you like to measure your heartbeat?' - if measure_heartbeat = 'yes' - call measure_heartbeat - else - 'no problem' - ``` - - print '(just under your jawline)' - print 'Count the number of beats you feel for 15 seconds' - beats == ask 'How many beats do you feel in 15 seconds?' - heartbeat = beats*4 - print 'Your heartbeat is ' heartbeat - if heartbeat >= 60 or heartbeat <= 100 - print 'Your heartbeat seems fine' - else - if heartbeat > 60 - print 'Your heartbeat seems to be too low' - if heartbeat < 100 - print 'Your heartbeat seems to be too high' - print 'You might want to contact a medical professional' - - measure_heartbeat = ask 'Would you like to measure your heartbeat?' - if measure_heartbeat = 'yes' - call measure_heartbeat - else - 'no problem' - 15: - example_code: | - **Warning! This code needs to be debugged!** - ``` - names = 'Tanya', 'Romy', 'Kayla', 'Aldrin', 'Ali' - verbs='walking', 'skipping', 'cycling', 'driving', 'running' - locations = 'on a mountaintop', 'in the supermarket', 'to the swimming pool' - hiding_spots = 'behind a tree', under a table', in a box' - sounds = 'a trumpet', 'a car crash', 'thunder' - causes_of_noise = 'a television', 'a kid with firecrackers', 'a magic elephant', 'a dream' - - chosen_ name = names at random - chosen_verb = verbs at random - chosen_location = 'locations at random' - chosen_sounds = noises at random - chosen_spot = hiding_spots random - chosen_causes = causes_of_noise at random - - print chosen_name ' was ' chosen_verb ' ' chosen_location - print 'when they suddenly heard a sound like ' sounds at random - print chosen_name ' looked around, but they couldn't discover where the noise came from' - print chosen_name ' hid ' chosen_spot' - print 'They tried to look around, but couldn't see anything from there' - hidden = 'yes' - while hidden = 'yes' - print chosen_name 'still didn't see anything' - answer = ask 'does ' chosen_name ' move from their hiding spot?' - if answer = 'yes' - hidden == 'no' - print 'chosen_name moved from' chosen_spot - print 'And then they saw it was just' chosen_cause - print chosen_name 'laughed and went on with their day' - print The End - ``` - 16: - example_code: | - **Warning! This code needs to be debugged!** - ``` - country = ['The Netherlands', 'Poland', 'Turkey', 'Zimbabwe', 'Thailand', 'Brasil', 'Peru', 'Australia', 'India', 'Romania' ] - capitals = 'Amsterdam', 'Warshaw' 'Istanbul', 'Harare', 'Bangkok', 'Brasilia', 'Lima', 'Canberra', 'New Delhi', 'Bucharest' - score = 0 - for i in range 0 to 10 - answer = ask 'What's the capital of ' countries[i] - correct = capital[i] - if answer = correct - print 'Correct!' - score = score + 1 - else - print 'Wrong,' capitals[i] 'in the capital of' countries[i] - print 'You scored ' score ' out of 10' - - ``` - 17: - example_code: | - **Warning! This code needs to be debugged!** - ``` - define food_order - toppings = ask 'pepperoni, tuna, veggie or cheese?' - size = ask 'big, medium or small?' - number_of_pizza = ask 'How many these pizzas would you like?' - - print 'YOU ORDERED' - print number_of_pizzas ' size ' topping ' pizza' - - define drinks_order - drink = ask 'water, coke, icetea, lemonade or coffee?' - number_of_drinks = ask 'How many of these drinks would you like?' - - print 'YOU ORDERED' - print number_of_drinks ' ' drink - - 'Welcome to Hedy pizza' - more_food = ask 'Would you like to order a pizza?' - while more_food = 'yes' - return food_order - more_food = ask 'Would you like to order a pizza?' - more_drinks = ask 'Would you like to order some drinks?' - while more_drinks == 'yes' - call drink_order - more_drinks == ask 'Would you like to order more drinks?' - - - print 'Thanks for ordering!' - ``` - 18: - example_code: | - **Warning! This code needs to be debugged!** - ``` - animals = ['pig', 'dog', 'cow'] - sounds = ['oink', 'woof', 'moo'] - for i in range 1 to 3 - animal = animals[i] - sound = sounds[i] - print 'Old MacDonald had a farm' - print 'E I E I O!' - print 'and on that farm he had a ' animal - print 'E I E I O!' - print 'with a ' sound sound ' here' - print 'and a ' sound sound ' there' - print 'here a ' sound - print 'there a ' sound - print 'everywhere a ' sound sound - ``` default: levels: 1: @@ -551,12 +101,6 @@ adventures: Στο επίπεδο 3 μπορείς να δημιουργήσεις μια λίστα. Μπορείς να αφήσεις τον υπολογιστή να επιλέξει κάτι τυχαία από τη λίστα. Αυτό γίνεται με τη χρήση της `at random`. 4: story_text: "Στο επίπεδο 4 οι εντολές `{ask}` and `{print}` αλλάζουν.\n\n Πρέπει να περικλείσεις το κείμενο που θέλεις να εμφανίσεις σε εισαγωγικά.\n \nΑυτό είναι χρήσιμο, επειδή τώρα μπορείς να εμφανίσεις όσες λέξεις θέλεις. Επίσης, τις λέξεις που αποθήκευες με την `{is}`.\n\nΟι περισσότερες γλώσσες προγραμματισμού χρησιμοποιούν εισαγωγικά όταν εμφανίζουν στην οθόνη, οπότε βρισκόμαστε ένα βήμα πιο κοντά στον πραγματικό προγραμματισμό!\n\nΘα βρεις τις εντολές στα αριστερά και πάλι, και τις ασκήσεις στις ακόλουθες καρτέλες. Οι ασκήσεις πλέον γίνονται όλο και πιο δύσκολες στις διαδοχικές καρτέλες. \nΈτσι, είναι καλύτερα να ξεκινήσεις από τα αριστερά με την ιστορία, και να δουλεύεις στα δεξιά, έτσι ώστε να προσπαθείς όλο και περισσότερο.\n" - example_code: | - ``` - print 'You need to use quotation marks from now on!' - answer is ask 'What do we need to use from now on?' - print 'We need to use ' answer - ``` 5: story_text: | Οι `ask` και `print` λειτουργούν ακριβώς όπως στο επίπεδο 4. @@ -622,22 +166,6 @@ adventures: else print 'η πίτσα είναι καλύτερη!' ``` - - food = ask 'Τι θέλεις;' - if food is 'πίτσα' - print 'ωραία!' - else - print 'η πίτσα είναι καλύτερη!' - 10: - story_text: | - In this level we learn a new code called `for`. With `for` you can make a list and use all elements. - `for` creates a block, like `repeat` and `if` so all lines in the block need to start with spaces. - example_code: |- - ``` - animals is dog, cat, blobfish - for animal in animals - print 'I love ' animal - ``` 12: story_text: "Μέχρι τώρα η Hedy δενεπέτρεπε δεκαδικούς αριθμούς όπως 1.5, αλλά δεν θα το επιτρέψουμε πλέον. Σημείωσε ότι οι υπολογιστές χρησιμοποιούν το `.` για τους δεκαδικούς αριθμούς.\n\nΑπό αυτό το επίπεδο και μετά πρέπει να χρησιμοποιείς τα εισαγωγικά όταν αποθηκεύεις κείμενο με `=`:\n\nΟι λίστες είναι κείμενα, άρα θέλουν επίσης εισαγωγικά. Πρόσεξε ότι κάθε στοιχείο στη λίστα έχει εισαγωγικά. \nΑυτό σου επιτρέπει να αποθηκέυσεις δυο λέξεις ως ένα στοιχείο, πχ 'Black Widow'.\n\n\nΓια τους αριθμούς, δεν χρησιμοποιούνται εισαγωγικά στο `=`/\n" example_code: |- @@ -649,31 +177,14 @@ adventures: print 2.5 + 2.5 13: story_text: Τώρα θα μάθουμε τα `and` και `or`! Αν θέλεις να ελέγξεις δύο δηλώσεις, δεν χρειάζεται να χρησιμοποίησεις δύο if αλλά μπορείς να χρησιμοποιήσεις τα `and` και `or`. Αν χρησιμοποιήσεις τo `and`, και οι δύο προτάσεις, αριστερά και δεξιά από το `and` θα πρέπει να είναι αληθείς. Μπορούμε επίσης να χρησιμοποιήσουμε το `or`. Τότε, μόνο μια πρόταση χρειάζεται να είναι αληθής. - 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!' - ``` 14: story_text: "Θα μάθουμε μερικά ακόμα νέα πράγματα! Ίσως να τα γνωρίζεις ήδη από τα μαθηματικά, τα `<` και `>`. \nΤο `<` ελέγχει αν ο πρώτος αριθμός είναι μικρότερος από τον δεύτερο, πχ `age < 12` ελέγχει αν το `age` είναι μικρότερο από 12.\nΑν θέλεις να ελέγξεις αν ο πρώτος αριθμός είναι μικρότερος ή ίσος από τον δεύτερο, μπορείς να χρησιμοποιήσεις `<=`, πχ`age <= 11`.\n Το `>` ελέγχει αν ο πρώτος αριθμός είναι μεγαλύτερος από τον δεύτερο, πχ `points > 10` ελέγχει αν `points` είναι μεγαλύτερο από 10.\nΑν θέλεις να ελέγξεις αν ο πρώτος αριθμός είναι μεγαλύτερος ή ίσος από τον δεύτερο, μπορείς να χρησιμοποιήσεις`>=`, πχ `points >= 11`.\nΧρησιμοποιείς αυτές τις συγκρίσεις μέσα σε ένα `{if}`, ως εξής." - example_code: | - ``` - age = {ask} 'How old are you?' - {if} age > 12 - {print} 'You are older than I am!' - ``` 15: story_text: "Θα μάθουμε ένα νέο βρόχο, το βρόχο `while`! Συνεχίζουμε το βρόχο για όσο η πρόταση είναι αληθής/ορθή! \nΜην ξεχάσεις να αλλάξεις την τιμή στον βρόχο.\n\nΈτσι στο παράδειγμα του κώδικα, συνεχίζουμε ώσπου να δοθεί μια σωστή απάντηση. \nΑν δε δοθεί ποτέ η σωστή απάντηση, ο βρόχος δε θα σταματήσει ποτέ!\n" example_code: | ``` answer = 0 while answer != 25 - answer = ask 'What is 5 times 5?' - print 'A correct answer has been given' - ``` - answer = ask 'Πόσο κάνει 5 φορές το 5;' print 'Δόθηκε η σωστή απάντηση' 16: @@ -681,10 +192,6 @@ adventures: example_code: \n```\nfriends = ['Μαρία', 'Κώστας', 'Αλκμήνη']\nlucky_numbers = [15, 18, 6]\n{for} i {in} {range} 1 {to} 3\n {print} 'ο τυχερός αριθμός του/της' friends[i]\n {print} 'είναι' lucky_numbers[i]\n```\n" 17: story_text: "Τώρα θα αλλάξουμε λίγο τις εσοχές. Κάθε φορά που χρειαζόμαστε μια εσοχή, χρειαζόμαστε ένα `:` στη γραμμή πριν την εσοχή.\n\nΣ' αυτό το επίπεδο μπορείς επίσηςνα χρησιμοποιήσει ςμια νέα εντολή: `{elif}`. 'Η`{elif}` είναι σύντμηση των `{else} {if}` και θα το χρειαστείς όταν θέλεις να έχεις 2 (ή περισσότερες!) επιλογές. \nΔοκίμασέ το!." - 18: - story_text: |- - We arrived at real Python code! That means we need to use parentheses with {print} and {range} from now on. - {print}('My name is ', naam) dice: name: Φτιάξε τα δικά σου ζάρια default_save_name: ζάρια @@ -737,8 +244,6 @@ adventures: Κατάφερες να υπολογίσεις το σκορ για 8 ζάρια; Χρειάστηκε αρκετή αποκοπή και επικόλληση, έτσι; Θα το κάνουμε πιο εύκολο στο επίπεδο 7! - example_code_2: | - Did you manage to calculate the score for 8 dice? That required a lot of cutting and pasting, right? We are going to make that easier in level 7! 7: story_text: | Μπορείς να φτιάξεις ένα ζάρι και πάλι στο επίπεδο 6. Με την εντολή `repeat` μπορείς έυκολα να ρίξεις μια ολόκληρη χούφτα από ζάρια. @@ -750,9 +255,6 @@ adventures: choices is 1, 2, 3, 4, 5, σκουληκάκι repeat _ _ print _ _ _ ``` - 10: - story_text: | - Is everybody taking too long throwing the dice? In this level you can let Hedy throw all the dice at once! dishes: name: Ποιός πρέπει να πλύνει τα πιάτα default_save_name: πιάτα @@ -766,8 +268,6 @@ adventures: Πρώτα φτιάξε μια λίστα με τα μέλη της οικογένειάς σου. Ύστερα επίλεξε 'τυχαία' από τη λίστα. example_code: "```\npeople is μαμά, μπαμπάς, Ελένη, Σοφία\nprint people at random\n```\n\nΔοκίμασες να κάνεις μια πρόταση χρησιμοποιώντας τη λέξη people; \n\nΔηλαδή, `print Επέλεξα από αυτούς τους people`. Αν δεν το έχεις κάνει ήδη, πήγαινε να το δοκιμάσεις! \n\nΘα δεις ότι δε δουλεύει σωστά. H Hedy θα εμφανίσει: Επέλεξα από αυτούς τους [μαμά, μπαμπάς, Ελένη, Σοφία]. Αυτό μπορείς να το λύσεις στο επίπεδο 3.\n" - story_text_2: | - Don't feel like doing the dishes yourself? Hack the program to remove your name from the list. 4: story_text: | Με εισαγωγικά μπορείς να κάνεις τον προγραμματισμό του πλυσίματος πιάτων πιο όμορφο. @@ -804,12 +304,6 @@ adventures: Τώρα θα πρέπει να κάνεις πολλή αντιγραφή και επικόλληση, έτσι; Αυτό θα το διορθώσουμε στο επίπεδο 7. Αυτό το επίπεδο είναι το τέλος της περιπέτειας του πλυσίματος! Όμως υπάρχουν πολλές ακόμα περιπέτειες να ακολουθήσεις σε άλλα επίπεδα, όπως το κομπιουτεράκι, μια διαδραστική ιστορία και ένα πιο περίπλοκο παιχνίδι. - story_text_2: | - If you are extremely unlucky the previous program might choose you to to the dishes for the whole week! That's not fair! - To create a fairer system you can use the `{remove}` command to remove the chosen person from the list. This way you don't have to do the dishes again untill everybody has had a turn. - - Monday and tuesday are ready for you! Can you add the rest of the week? - And... can you come up with a solution for when your list is empty? example_code_2: |- ``` people is μαμά, μπαμπάς, Ελένη, Σοφία @@ -827,417 +321,6 @@ adventures: people is μαμά, μπαμπάς, Ελένη, Σοφία repeat _ _ print 'αυτό που θα πλύνει τα πιάτα είναι' _ ``` - 10: - story_text: | - In this level you could make an even better dish washing shedule. - elif_command: - description: elif - levels: - 17: - example_code: | - ``` - prices = ['1 million dollars', 'an apple pie', 'nothing'] - your_price = prices[{random}] - {print} 'You win ' your_price - {if} your_price == '1 million dollars' : - {print} 'Yeah! You are rich!' - {elif} your_price == 'an apple pie' : - {print} 'Lovely, an apple pie!' - {else}: - {print} 'Better luck next time..' - ``` - for_command: - description: for command - levels: - 11: - story_text: |- - In this level, we add a new form of the `{for}`. In earlier levels, we used `{for}` with a list, but we can also use `{for}` with numbers. - We do that by adding a variable name, followed by `{in}` `{range}`. We then write the number to start at, `{to}` and the number to end at. - Try the example to see what happens! In this level again, you will need to use indentations in lines below the `{for}` statements. - fortune: - levels: - 1: - story_text: | - Have you ever been to a carnival and had your future predicted by a fortune teller? Or have you ever played with a magic eight ball? - Then you probably know that they can't really predict your future, but it's still fun to play! - - In the upcoming levels you can learn how to create your own fortune telling machine! - In level 1 you can start off easy by letting Hedy introduce herself as a fortune teller and let her {echo} the players' answers. - Like this: - story_text_2: | - ### Exercise - Hedy now only tells you your name. Can you expand the code so that Hedy can predict more things about you? - Obviously, Hedy isn't a very good fortune teller yet, as she can only repeat the answers that were given by the players! - Take a look in level 2 to improve your fortune teller. - 3: - story_text: | - In the previous levels you've created your first fortune telling machine, but Hedy couldn't really predict anything, only {echo}. - In this level you can use a variable and the `{at} {random}` command to really let Hedy choose an answer for you. Check out this code for instance: - story_text_2: | - ### Exercises - Now, Hedy can only answer yes, no or maybe. Can you give Hedy more answer options, like 'definitely' or '{ask} again'. - 5: - story_text: | - In this level you'll learn to (secretly) tip the odds in your favor, when using the fortune teller! - By using `{if}` and `{else}` you can make sure that you will always get a good fotune, while other people might not. - Check out this example to find out how. - 6: - story_text: | - In this level you can use math in your predictions as a fortune teller. This allows you to make up (silly) formulas to calculate the future. - For example you could calculate how rich you'll get or how many kids you will have when you grow up. - 7: - story_text: | - In this level you can use the `{repeat}` command to make your machine tell multiple fortunes at once. - 8: - story_text: | - In the previous levels you've learned how to use repeat to make the fortune teller answer 3 questions in a row, but we had a problem with printing the questions. - Now that problem is solved, because of the new way of using the repeat command. - In the next example you can have your fortune teller {ask} 3 questions and also print them! - example_code: | - ``` - {print} 'I am Hedy the fortune teller!' - {print} 'You can ask me 3 questions.' - answers = yes, no, maybe - _ _ _ - question = {ask} 'What do you want to know?' - {print} question - {sleep} - {print} 'My crystal ball says...' answers {at} {random} - ``` - 10: - story_text: | - In this level you'll learn how to program the game MASH (mansion, apartement, shack, house). In this game you can predict for all the players at once, what their future will look like. - 12: - story_text: | - In this level you can make your fortunes multiple words. Like in this example below: - functions: - levels: - 12: - example_code: | - ``` - sides = 'left', 'right' - limbs = 'hand', 'foot' - colors = 'red', 'blue', 'green', 'yellow' - - {define} turn - chosen_side = sides {at} {random} - chosen_limb = limbs _ - chosen_color = colors _ - {print} chosen_side ' ' chosen_limb ' on ' chosen_color - - {print} 'Lets play a game of Twister!' - {for} i {in} {range} 1 to _ - {call} turn - {sleep} 2 - ``` - 13: - story_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. - - For example in this code we've programmed the first verse of the song 'My Bonnie is over the ocean'. - In this example code the argument `place` is used. Place is a variable that is only used in the function, so an argument. - To use `place` we have programmed the line `define song with place`. - When the function is called, computer will replace the argument `place`, with the piece of text after `call song with`. - - ### Exercise - The next verse of this song goes: - - Last night as I lay on my pillow - Last night as I lay on my bed - Last night as I lay on my pillow - I dreamed that my Bonnie is dead - - Can you program this verse in the same way as the example? - 14: - example_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?' - - new_price = _ calculate_new_price {with} old_price, _ - {print} 'The new price is ' new_price ' dollar' - ``` - haunted: - levels: - 1: - story_text: | - In this adventure you are working towards making a game in which you have to escape from a haunted house by picking the correct door. - If you pick the right door you'll survive, but {if} not a terrible monster might... - - In level 1 we start our haunted house game by making up a scary story and {ask} the player what monster they'll see in the haunted house. - story_text_2: | - Can you finish the scary story? Or make up your own haunted house story? - 2: - example_code: | - ``` - monster_1 {is} 👻 - monster_2 {is} 🤡 - monster_3 {is} 👶 - {print} You enter the haunted house. - {print} Suddenly you see a monster_1 - {print} You run into the other room, but a monster_2 is waiting there for you! - {print} Oh no! Quickly get to the kitchen. - {print} But as you enter monster_3 attacks you! - ``` - example_code_2: | - ``` - monster_1 {is} _ - monster_2 {is} _ - monster_3 {is} _ - {print} You enter the haunted house. - {print} Suddenly you see a monster_1 - {print} You run into the other room, but a monster_2 is waiting there for you! - {print} Oh no! Quickly get to the kitchen. - {print} But as you enter monster_3 attacks you! - ``` - 3: - story_text: | - In the previous levels you've made an introduction to your haunted house game, but as you might have noticed the story would always have a dreadful end. - In this level you can make your story more interactive by changing the outcome of the game; sometimes you'll get eaten, sometimes you'll escape! - Let Hedy decide randomly! - 4: - story_text: | - In this level you learn how to use quotation marks in your games. - Can you make your Haunted House level 4 proof? - example_code: | - ``` - {print} _Escape from the haunted house!_ - {print} _There are 3 doors in front of you..._ - choice {is} {ask} _Which door do you choose?_ - {print} _You picked door ..._ choice - monsters {is} a zombie, a vampire, NOTHING YOUVE ESCAPED - {print} _You see..._ - {sleep} - {print} monsters {at} {random} - ``` - 5: - story_text: | - Up until this level the haunted house game always asked the player to choose a door, but as you might have noticed, they didn't really have to answer correctly. - If the player filled in a completely random answer, the game would still work and the player might even win (despite not picking a door). - In this level you can only win the game by picking the same door Hedy picked randomly. - example_code: | - ``` - {print} 'Escape from the haunted house!' - {print} 'There are 3 doors in front of you...' - doors {is} 1, 2, 3 - monsters {is} werewolf, mummy, vampire, zombie - chosen_door {is} {ask} 'Which door do you choose?' - {print} 'You chose door...' chosen_door - {sleep} - correct_door {is} doors {at} {random} - {if} chosen_door {is} correct_door {print} 'Great! Youve escaped!' - {else} {print} 'Oh no! You are being eaten by a...' monsters {at} {random} - ``` - 9: - story_text: | - In this level you can use nesting, which allows you to make the haunted house even more interactive! - - Now it's very hard to win this game, can you make it easier to win? - For example by only having 1 wrong door and 2 correct doors instead of 1 correct door and 2 wrong ones? - 11: - story_text: | - In this level we've changed the repeat command and we've added a line to our haunted house that tells the player in which room they are. - example_code: | - ``` - {print} 'Escape from the Haunted House!' - player {is} alive - doors = 1, 2, 3 - monsters = zombie, vampire, giant spider - {for} i {in} {range} 1 {to} 3 - {if} player {is} alive - correct_door = doors {at} {random} - {print} 'Room ' i - {print} 'There are 3 doors in front of you...' - chosendoor = {ask} 'Which door do you choose?' - {if} chosendoor {is} correct_door - {print} 'No monsters here!' - {else} - {print} 'You are eaten by a ' monsters {at} {random} - player = dead - {else} - {print} 'GAME OVER' - {if} player {is} alive - {print} 'Great! You survived!' - ``` - if_command: - description: Introducing the if command - levels: - 9: - story_text: | - In this level you can also put an {if} command inside another {if} command. - in_command: - description: Introducing the in command - levels: - 5: - example_code_2: | - ``` - animals is dog, cow, sheep - answer is ask 'What is your favorite animal?' - _ answer _ animals _ 'Mine too!' - _ _ 'My favorite animals are dogs, cows and sheep' - ``` - is_command: - description: introducing is command - levels: - 2: - story_text_2: | - ### Exercise - Time to make your own variables! - In the example code we made an example of the variable `favorite_animal`. In line 1 the variable is set, and in line 2 we haved used the variable in a print command. - Firstly, finish our example by filling in your favorite animal on the blank. Then make at least 3 of these codes yourself. Pick a variable, and set the variable with the {is} command. Then use it with a {print} command, just like we did. - 14: - example_code: | - ``` - age = {ask} 'How old are you?' - {if} age > 12 - {print} 'You are older than I am!' - ``` - example_code_3: | - ``` - name = {ask} 'What is your name?' - {if} name != 'Hedy' - {print} 'You are not Hedy' - ``` - - {if} age < 13 - {print} 'You are younger than me!' - {else} - {print} 'You are older than me!' - language: - levels: - 5: - story_text: | - Make your own program to practice your vocabulary in a new language. - maths: - levels: - 6: - example_code: | - ``` - {print} '5 plus 5 is ' 5 + 5 - {print} '5 minus 5 is ' 5 - 5 - {print} '5 times 5 is ' 5 * 5 - ``` - 12: - example_code_2: | - ``` - a = 'Hello ' - b = 'world!' - {print} a + b - ``` - - {print} 2.5 + 2.5 - music: - levels: - 6: - story_text: "Instead of playing notes, you can also play numbers now. Simply type `{play} 1` for the lowest note, `{play} 70` for the highest note, or anything in between.\n\n### Exercise\n This calls for musical maths! Try out the example code a couple of times with different starting numbers. \nThen, see if you can compose a song using the numbers.\n" - parrot: - levels: - 1: - story_text_2: | - ### Exercise - Can you make the parrot ask a different question? Fill in the blanks in the example! - 2: - story_text: | - Create your own online pet parrot that will copy you! - story_text_2: | - ### Exercise - You can use variables to make the parrot say more than only your name. Can you complete this code? - 3: - story_text: | - Teach your parrot a new word with `{add}`. - 4: - story_text: | - In this level we have to use quotation marks with the commands `{ask}` and `{print}`. - Can you complete the code by adding quotation marks? - 5: - story_text: | - Reward your parrot {if} it says the correct word! - piggybank: - levels: - 12: - story_text: | - In this adventure you learn how to make a digital piggy bank, to calculate how much money you have and how long you need to save up to buy what you want! - 14: - example_code: | - ``` - _ calculate_budget with wish, money, allowance - to_save = wish - money - weeks = to_save / allowance - {if} wish _ money - {print} 'You need to save up some more!' - {print} 'Youll need ' weeks ' more weeks.' - {else} - {print} 'Great! You have enough' - {print} 'Lets go shopping!' - - money = {ask} 'How much money have you saved?' - wish = {ask} 'How much money do you need?' - allowance = {ask} 'How much pocket money do you get each week?' - - {call} calculate_budget with _, _, _ - ``` - pressit: - levels: - 9: - story_text: | - Now that you know how to combine statements, you can create a touch type tool with `{pressed}`. - - ### Exercise - Finish the code. Each time a random letter should be chosen, which you have to press. You get a point for a correct press, and and two points deduction for a wrong press. - **(extra)** Clear the screen after each letter, and show the user how many points they have scored. - print_command: - levels: - 18: - example_code_2: | - ``` - temperature = 25 - {print}('It is ', temperature, ' degrees outside') - ``` - - {print}('My name is ', name) - random_command: - levels: - 16: - story_text: |- - We are going to make lists the Python way, with square brackets around the lists! We also keep the quotation marks around each item like we have learned in previous levels. - We use square brackets to point out a place in a list. For example: `friends[1]` is the first name on the list of friends, as you can see in the first part of the example code. The second part of the example code shows you that we can also match 2 lists using the variable i. - repeat_command: - description: repeat command - levels: - 7: - story_text: | - ## Repeat! Repeat! Repeat! - Level 7 adds the `{repeat}` command. `{repeat}` can be used to execute one line of code multiple times. Like this: - - ### Exercise - Play around with the repeat command. Can you make the happy birthday song in only 3 lines of code instead of 4 now? - 9: - story_text: | - Great job! You've reached another new level! In the previous level you've learned to use multiple lines of code in an {if} or {repeat} command. But you can't yet combine the two... - Good news! In this level you will be allowed to put an {if} inside an {if}, or inside a {repeat} command. Putting a block of code inside another block of code is called nesting. ``` Putting a block of code inside another block of code is called nesting. - example_code: | - ``` - answer = {ask} 'Are you ready to learn something new?' - {if} answer {is} yes - {print} 'Great! You can learn to use the repeat command in the if command!' - {print} 'Hooray!' - {print} 'Hooray!' - {print} 'Hooray!' - {else} - {print} 'Maybe you should practice some more in the previous level' - repeat_command_2: - description: repeat command 2 - levels: - 7: - story_text_2: | - Another interesting thing you can so with the `{repeat}` command is using variables to set the amount of times something should be repeated. In the example code you can see that we first ask the person how old they are. - Then, in line 3, the question is repeated 'age' times. So we have used the variable 'age' with the `{repeat}` command. restaurant: name: Εστιατόριο default_save_name: Εστιατόριο @@ -1265,9 +348,6 @@ adventures: print Σας ευχαριστώ για την παραγγελία. print Το φαγητό και τα ποτά σας θα είναι έτοιμα αμέσως! ``` - story_text_2: | - ### Exercise - Can you make this code more elaborate? For example by adding drinks to the order? Or...? 3: story_text: | Δυσκολεύεσαι να αποφασίσεις τί θέλεις να φάς για δείπνο. Μπορείς να αφήσεις τη Hedy να επιλέξει για σένα! @@ -1289,94 +369,6 @@ adventures: print Το κόστος θα είναι: prices at random print Ευχαριστούμε και καλή όρεξη! ``` - story_text_2: | - Does your costumer have any allergies or do they dislike certain dishes? Then you can use the `{remove}`command to remove it from your menu. - example_code_2: | - ``` - {print} Mystery milkshake - flavors {is} strawberry, chocolate, vanilla - allergies {is} {ask} Are you allergic to any falvors? - {remove} allergies {from} flavors - {print} You get a flavors {at} {random} milkshake - ``` - 4: - story_text: | - ### Exercise - Add the quotation marks to this code to make it work! Be careful: variables should not be in quotation marks. - Then, use the `{clear}` command to only show one line at a time in your output screen. - - ### Exercise 2 - Go back to the previous level and copy your restaurant code. Make the code work in this level by adding quotation marks in the right spots and add some `{clear}` commands. - 5: - story_text: | - In this level the {if} command allows you to {ask} your customers questions and give different responses to the answers. - In the example below, you see that you can {ask} the customer {if} they want to hear the specials and Hedy can respond accordingly. - 6: - story_text: | - In this level you can use maths to calculate the total price of your customer's order, which can make your virtual restaurant more realistic. - example_code: | - You can make a simple restaurant code, like this: - ``` - {print} 'Welcome to Hedys restaurant' - {print} 'Here is our menu:' - {print} 'Our main courses are pizza, lasagne, or spaghetti' - main = {ask} 'Which main course would you like?' - price = 0 - {if} main {is} pizza price = 10 - {if} main {is} lasagne price = 12 - {if} main {is} spaghetti price = 8 - {print} 'You have ordered ' main - {print} 'That will be ' price ' dollars, please' - {print} 'Thank you, enjoy your meal!' - ``` - 7: - story_text: |- - In this level you've learned how to use the {repeat} command to repeat a line of code a certain amount of times. - You can use that in your restaurant to {ask} multiple people what they'd like to eat. - example_code: | - ``` - {print} 'Welcome to Hedys restaurant!' - people = {ask} 'How many people are joining us today?' - {repeat} people times food = {ask} 'What would you like to eat?' - {print} 'Thanks for your order! Its coming right up!' - ``` - 9: - story_text: | - In this level you can use nesting to make your restaurant more realistic and more fun! - For example you would {ask} for sauce {if} somebody orders fries, but you wouldn't {if} someone orders pizza! - Check out the example, and try this at your own virtual restaurant! - 10: - story_text: | - In this level you'll learn how to easily {ask} your guests' orders in a short code. - example_code_2: | - ``` - courses = appetizer, main course, dessert - names = Timon, Onno - {for} name {in} names - {for} course {in} courses - food = {ask} name ', what would you like to eat as your ' course '?' - {print} name ' orders ' food ' as their ' course - ``` - 11: - story_text: | - We can use the `{for} i {in} {range} 1 {to} 5` to {print} the orders from multiple customers in an orderly manner. - 12: - story_text: | - From this level on you can use decimal numbers to make you menu more realistic. - 13: - story_text: | - In this level we can use the new commands to upgrade our restaurant. - We use `{and}` to see {if} two things are both the case. - example_code: | - ``` - price = 10 - food = {ask} 'What would you like to eat?' - drinks = {ask} 'What would you like to drink?' - {if} food {is} 'sandwich' {and} drinks {is} 'juice' - {print} 'Thats our discount menu' - price = price - 3 - {print} 'That will be ' price ' dollars' - ``` rock: name: Πέτρα, ψαλίδι, χαρτί default_save_name: Πέτρα @@ -1401,16 +393,6 @@ adventures: Μπορείς να χρησιμοποιήσεις την `ask` και πάλι στο επίπεδο 2. Μπορείς να εμφανίσεις την επιλογή σου και την επιλογή από τον υπολογιστή; Προσοχή όμως, η `ask` τώρα λειτουργεί διαφορετικά απ'ότι στο επίπεδο 1. Θα πρέπει να υπάρχει ένα όνομα πριν από αυτή. - story_text_2: | - ### Exercise - Now you only have one player, so can you add a second player? - You can even use variables to name player 1 and player 2. - example_code_2: | - ``` - choices {is} rock, paper, scissors - {print} player 1 chooses... choices {at} {random} - {print} player 2 _ - ``` 5: story_text: | Στο επίπεδο 4 μπορούμε να αποφασίσουμε ποιός θα κερδίσει. Για αυτό θα χρειαστούμε τον νέο κώδικα `if`. @@ -1429,75 +411,6 @@ adventures: ``` Πρώτα, συμπλήρωσε το σωστό κώδικα στις τελίτσες για να δεις αν είναι ισοπαλία. - 9: - story_text: | - In this level you can program the whole rock, paper, scissors game by nesting the {if}-commands. Can you finish the code? - example_code: | - ``` - choices = rock, paper, scissors - your_choice = {ask} 'What do you choose?' - {print} 'You choose ' your_choice - computer_choice = choices {at} {random} - {print} 'The computer chooses ' computer_choice - {if} computer_choice {is} your_choice - {print} 'Tie' - {if} computer_choice {is} rock - {if} your_choice {is} paper - {print} 'You win!' - {if} your_choice {is} scissors - {print} 'You lose!' - # finish this code - ``` - 10: - story_text: | - Feeling too lazy to play the game yourself? Let Hedy play it for you! - 13: - story_text: | - With the `{and}` command you can shorten your rock, paper, scissors code! Check out the example code below and try to finish it. - rock_2: - levels: - 2: - story_text: | - Now that you have learned how to use the `{ask} command, you can make your rock, paper, scissors code interavtive too! - - ### Exercise - Make the rock, paper, scissors code interactive by adding the `{ask}` command and a question to your rock, paper, scissors code. - example_code: | - ``` - choice is _ - {print} I choose choice - ``` - secret: - default_save_name: language - levels: - 12: - story_text: | - In this adventure you can create your own super spy code. Encode a message that only the right agent can decipher. - If the enemy tries to crack the code, they will get some false info to waste their time. - example_code: | - ``` - name {is} {ask} 'What is your name?' - {if} name {is} '_' - a {is} 'Go to the airport ' - {else} - a {is} 'Go to the trainstation ' - password {is} {ask} 'What is the password?' - {if} password {is} _ - b {is} 'tomorrow at 02.00' - {else} - b {is} 'today at 10.00' - {print} _ _ _ - ``` - 13: - story_text: | - The code you made in the previous level can be made a lot easier in this one with the `{and}` command. - sleep_command: - description: introducing sleep command - levels: - 2: - story_text: | - ## The sleep command - Another new command in this level is `{sleep}`, which pauses your program for a second. If you type a number behind the {sleep} command, the program pauses for that amount of seconds. songs: name: Τραγούδα ένα τραγούδι! default_save_name: τραγούδι @@ -1525,16 +438,7 @@ adventures: * repeat 3 times print 'Μωρό Καρχαρίας Τουτουρουτουτου' Όμως όπως θα δείτε σε αυτό το μάθημα, κάποιες φορές θέλεις να επαναλάβεις αρκετές γραμμές μαζί. Αυτό μπορεί να γίνει με αποκοπή και επικόλληση, όμως αυτό απαιτεί αρκετή δουλειά. Στο επίπεδο 7 θα μάθες πώς να το κάνεις αυτό εύκολα. - example_code_2: | - ``` - number = 6 - number = number - 1 - print number ' little monkeys jumping on the bed' - print 'One fell off and bumped his head' - print 'Mama called the doctor and the doctor said' - print 'NO MORE MONKEYS JUMPING ON THE BED!' - sleep - ``` + 7: story_text: | Τα τραγούδια συχνά περιλαμβάνουν αρκετή επανάληψη. Για παράδειγμα... το Μωρό Καρχαρίας! Αν το τραγουδήσεις, τραγουδάς διαρκώς το ίδιο πράγμα: @@ -1552,229 +456,3 @@ adventures: repeat _ _ print 'Μωρό Καρχαρίας τουτουρουτουτου' print 'Μωρό Καρχαρίας' ``` - 8: - story_text: | - In a previous level you've programmed the song 'Bottles of beer'. You made one verse and then had to copy the verses 99 times. In level 7 you can repeat the song 99 times, just by adding one simple line! - 10: - story_text: | - In this level you can easily make the childrens' song 'Five little monkeys'. Can you make the last chorus? - You can also make the whole baby shark song (including all the other sharks in the family) in only 6 lines! - Or you can make Old MacDonald with all the different animals. - example_code: | - ``` - monkeys = 5, 4, 3, 2 - {for} monkey {in} monkeys - {print} monkey ' little monkeys jumping on the bed' - {print} 'One fell off and bumped his head' - {print} 'Mama called the doctor and the doctor said' - {print} 'NO MORE MONKEYS JUMPING ON THE BED!' - ``` - - ``` - sharks = baby, mommy, daddy, grandma, grandpa - {for} shark {in} sharks - {print} shark 'tututututudu' - {print} shark 'tututututudu' - {print} shark 'tututututudu' - {print} shark - ``` - ``` - animals = pig, dog, cow - {for} animal {in} animals - {if} animal {is} pig - sound = oink - {if} animal {is} dog - sound = woof - {if} animal {is} cow - sound = moo - {print} 'Old MacDonald had a farm' - {print} 'E I E I O!' - {print} 'and on that farm he had a ' animal - {print} 'E I E I O!' - {print} 'with a ' sound sound ' here' - {print} 'and a ' sound sound ' there' - {print} 'here a ' sound - {print} 'there a ' sound - {print} 'everywhere a ' sound sound - ``` - story_text_2: | - ### Exercise 2 - Print the song Five little moneys jumping on the bed. Look up the text if you don't remember. - - **(extra)** Print the song Old MacDonald had a farm, and make sure all animals make a different sound, using an `{if}`. - 11: - story_text: | - In this level you can use the `{for} i {in} {range}` command to make songs that use counting. - example_code: | - ``` - {for} i {in} {range} 5 {to} 1 - {print} i ' little monkeys jumping on the bed' - {print} 'One fell off and bumped his head' - {print} 'Mama called the doctor and the doctor said' - {if} i {is} 1 - {print} 'PUT THOSE MONKEYS RIGHT TO BED!' - {else} - {print} 'NO MORE MONKEYS JUMPING ON THE BED!' - ``` - 12: - story_text: | - In this song we can make it even easier to program '{if} you're happy and you know it, clap your hands'. Because we can put all of the actions in a variable, check it out: - songs_2: - levels: - 12: - example_code: | - ``` - {define} twinkle - {print} 'Twinkle' - {print} '...' - - {call} twinkle - {print} 'Up above the world so high' - {print} 'Like a diamond in the sky' - {call} _ - ``` - turtle: - default_save_name: turtle - levels: - 2: - story_text: | - In level 1 the turtle could only turn left or right. That is a bit boring! - In level 2 he can point his nose in all directions. - - Use 90 to turn a quarter. We call this degrees. A full turn is 360 degrees. - Can you make a figure with this code? Maybe a triangle or a circle? - example_code: | - ``` - answer {is} {ask} How many steps should the turtle make? - {forward} answer - ``` - story_text_2: | - Also, in level 1 the turtle could only turn left or right. That is a bit boring! - In level 2 he can point his nose in all directions. - - Use 90 to turn a quarter. We call this degrees. A full turn is 360 degrees. - Can you make a figure with this code? Maybe a triangle or a circle? - example_code_2: | - ``` - {print} Drawing figures - angle {is} 90 - {turn} angle - {forward} 25 - {turn} angle - {forward} 25 - ``` - 3: - story_text: | - In this level you can use use `{random}` with the drawing turtle. A random choice makes the turtle walk a different path each time. - Use `{at} {random}` to choose a value from a list. You can copy and paste lines 2 and 3 to create a longer random path. - 5: - example_code_2: | - ``` - direction {is} {ask} 'Do you want to go left, right, or straight ahead?' - if direction is left turn _ - if direction is right turn _ - forward 100 - ``` - 8: - story_text: | - Now that we can repeat several lines, we can make figures more easily. - We only have to set the angle once and then use that variable in the `{repeat}`. - story_text_2: | - Also, we can now improve the program that draws different figures. - Can you figure out how far the turtle has to turn here? Finish the code and you can draw any polygon you'd like! - 9: - story_text: | - Now that we can use a `{repeat}` inside a `{repeat}`, we can create more complex figures. - - ### Exercise 1 - This code creates three black triangles, change that into five pink squares. - - **(extra)** Create a figure of your own choosing consisting of at least two different shapes types. - 10: - story_text: | - In this level you can make the turtle draw a figure. - The turtle will travel the distances in the list, one by one, making bigger and bigger steps. - ### Exercise 1 - Add a 90 degree turn in the loop, so that a spiral is drawn. - Add at least 5 numbers to the list, so the spiral grows larger. - **(extra)** can you change the spiral into another shape? Experiment with numbers for the turn! - ### Exercise 2 - The spiral is drawn outwards, make it go inwards? - turtle_draw_it: - levels: - 9: - example_code: | - Hint for the nested squares: - ``` - colors = red, blue, orange, yellow, pink, purple, green, brown, black - distance = 120 - repeat 5 times - _ - ``` - Hint for the flags: - ``` - country = ask 'which country would you like to see the flag of?' - if country is 'the Netherlands' - color_1 = red - color_2 = white - color_3 = blue - ``` - 10: - example_code: | - Hint Nested Hexagon: - ``` - distances = 100, 80, 60, 40, 20 - {for} distance {in} distances - _ - ``` - - Hint Traffic Lights: - ``` - colors = red, yellow, green - {for} chosen_color {in} colors - color _ - {repeat} _ - ``` - 12: - story_text: | - ### Exercise - Recreate the drawings with the turtle! - Hint: Bracelet designing program. Firstly, define a function **for each shape** you want to use on the bacelet. Then, add the shapes to the bacelet like this: - - Bracelet Designing program - example_code: | - ``` - {define} draw_a_square - _ - - {color} white - {turn} -90 - {forward} 300 - {turn} 180 - - {for} i {in} {range} 1 {to} 5 - {color} gray - {forward} 100 - shape = {ask} 'What kind of shape would you like next on the bracelet?' - chosen_color = {ask} 'In which color?' - {color} chosen_color - {if} shape = 'square' - {call} draw_a_square - ``` - while_command: - description: while - years: - description: Countdown to the new year! - levels: - 11: - story_text: | - In this level you can use the `{for} i {in} {range}` command to countdown to the New Year. - - ### Exercise - Fill in the blanks and make the code work! - example_code: | - ``` - for _ in _ 10 to 1 - {print} i - {print} 'Happy New Year!' - ``` diff --git a/content/adventures/eo.yaml b/content/adventures/eo.yaml index 0babd08e1fc..b8e051e6d1a 100644 --- a/content/adventures/eo.yaml +++ b/content/adventures/eo.yaml @@ -43,15 +43,6 @@ adventures: {sleep} {print} nomo timas, ke ĉi tie estas hantata arbaro ``` - 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: | En Nivelo 3, oni povas igi sian rakonton pli amuza. Oni povas uzi hazardecon por iu ajn monstro, besto aŭ alia obstaklo, jene: @@ -221,26 +212,6 @@ adventures: {print} 'Ne, ĝi ne estas ĉe la ' loko {print} 'Nun vi povas eniri la domon!' ``` - add_remove_command: - name: '{add} {to} & {remove} {from}' - 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. - 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. - and_or_command: - description: introducing and or - ask_command: - description: Introduction ask command - levels: - 1: - 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. blackjack: name: Nigra fanto default_save_name: Nigra fanto @@ -297,8 +268,6 @@ adventures: {if} respondo {is} ĝusta_respondo {print} 'Bone!' {else} {print} 'Malĝuste! La ĝusta respondo estas ' ĝusta_respondo ``` - 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 = _ @@ -325,13 +294,6 @@ adventures: poentaro = poentaro + 1 {print} 'Bonege! Jen via poentaro: ' poentaro '/10!' ``` - 11: - example_code: | - ``` - number = 10 - {for} i {in} {range} 1 to 10 - {print} i * number - ``` 12: story_text: | Nun oni povas verki kalkulilon, kiu funkcias por decimalaj frakcioj. @@ -342,343 +304,6 @@ adventures: respondo = nombro1 + nombro2 {print} nombro1 ' plus ' nombro2 ' estas ' respondo ``` - 14: - 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 - clear_command: - description: clear command - debugging: - levels: - 3: - 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} - ``` - 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! - 8: - 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: - 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!' - {else} - 'I'm sorry we don't sell that' - topping {is} {ask} 'What kind of topping would you like?' - sauce {is} {ask} 'What kind of sauce would you like?' - {print} One chosen_bread with topping and sauce. - price = amount * 6 - {print} 'That will be 'price dollar' please' - ``` - - price = amount * 6 - {print} 'That will be 'price dollar' please' - 10: - example_code: | - **Warning! This code needs to be debugged!** - ``` - names = Muad Hasan Samira Noura - activities = fly a kite, go swimming, go hiking, catch tan in the sun - {for} name {is} names - {print} At the beach name loves to activity at random - ``` - 11: - story_text: |- - ### Exercise - Debug this calender program. The output of this program is supposed to look like a list of dates. - For example: - - ``` - Hedy calender - Here are all the days of November - November 1 - November 2 - November 3 - ``` - And so on. - - Mind that you have to test your code extra carefully for the month February, because the amount of days in this month changes in leap years. - example_code: | - **Warning! This code needs to be debugged!** - ``` - print 'Hedy calender' - months_with_31 days = January, March, May, July, September, October, December - months_with_30_days = April, June, August, November - month = ask 'Which month would you like to see?' - if month in months_with_31_days - days = 31 - if month in months_with30_days - days = 30 - if month = February - leap_years = 2020, 2024, 2028, 2036, 2040, 2044, 2028 - year = ask 'What year is it?' - if year in leap_years - days = 29 - else - days = 28 - - print 'Here are all the days of ' moth - for i in range 1 to days - print month i - ``` - 12: - example_code: | - **Warning! This code needs to be debugged!** - ``` - define greet - greetings = 'Hello', 'Hi there', 'Goodevening' - print greetings at random - - define take_order - food = ask 'What would you like to eat?' - print 'One food' - drink = 'What would you like to drink?' - print 'One ' drink - more = ask 'Would you like anything else?' - if more is 'no' - print 'Alright' - else - print 'And ' more - print 'Thank you' - - print 'Welcome to our restaurant' - people = ask 'How many people are in your party tonight?' - for i in range 0 to people - call greet_costumer - ``` - 13: - example_code: | - **Warning! This code needs to be debugged!** - ``` - defin movie_recommendation with name - action_movies == 'Die Hard', 'Fast and Furious', 'Inglorious Bastards' - romance_movies = 'Love Actually', 'The Notebook', 'Titanic' - comedy_movies = 'Mr Bean' 'Barbie''Deadpool' - kids_movies = 'Minions', 'Paddington', 'Encanto' - if name is 'Camila' or name is 'Manuel' - recommended_movie = kids_movie at random - if name is 'Pedro' or 'Gabriella' - mood = ask 'What you in the mood for?' - if mood is 'action' - recommended_movie = comedy_movies at random - if mood is 'romance' - recommended_movie = romance_movies - if mood is 'comedy' - recommended_movie = comedy_movies at random - - print 'I would recommend ' recommended_movie ' for ' name - - name = ask 'Who is watching?' - recommendation = ask 'Would you like a recommendation?' - if recommendaion is 'yes' - print movie_recommendation with name - else - print 'No problem!' - ``` - 14: - example_code: | - **Warning! This code needs to be debugged!** - ``` - define calculate_heartbeat - print 'Press your fingertips gently against the side of your neck' - print '(just under your jawline)' - print 'Count the number of beats you feel for 15 seconds' - beats == ask 'How many beats do you feel in 15 seconds?' - heartbeat = beats*4 - print 'Your heartbeat is ' heartbeat - if heartbeat >= 60 or heartbeat <= 100 - print 'Your heartbeat seems fine' - else - if heartbeat > 60 - print 'Your heartbeat seems to be too low' - if heartbeat < 100 - print 'Your heartbeat seems to be too high' - print 'You might want to contact a medical professional' - - measure_heartbeat = ask 'Would you like to measure your heartbeat?' - if measure_heartbeat = 'yes' - call measure_heartbeat - else - 'no problem' - ``` - - print '(just under your jawline)' - print 'Count the number of beats you feel for 15 seconds' - beats == ask 'How many beats do you feel in 15 seconds?' - heartbeat = beats*4 - print 'Your heartbeat is ' heartbeat - if heartbeat >= 60 or heartbeat <= 100 - print 'Your heartbeat seems fine' - else - if heartbeat > 60 - print 'Your heartbeat seems to be too low' - if heartbeat < 100 - print 'Your heartbeat seems to be too high' - print 'You might want to contact a medical professional' - - measure_heartbeat = ask 'Would you like to measure your heartbeat?' - if measure_heartbeat = 'yes' - call measure_heartbeat - else - 'no problem' - 15: - example_code: | - **Warning! This code needs to be debugged!** - ``` - names = 'Tanya', 'Romy', 'Kayla', 'Aldrin', 'Ali' - verbs='walking', 'skipping', 'cycling', 'driving', 'running' - locations = 'on a mountaintop', 'in the supermarket', 'to the swimming pool' - hiding_spots = 'behind a tree', under a table', in a box' - sounds = 'a trumpet', 'a car crash', 'thunder' - causes_of_noise = 'a television', 'a kid with firecrackers', 'a magic elephant', 'a dream' - - chosen_ name = names at random - chosen_verb = verbs at random - chosen_location = 'locations at random' - chosen_sounds = noises at random - chosen_spot = hiding_spots random - chosen_causes = causes_of_noise at random - - print chosen_name ' was ' chosen_verb ' ' chosen_location - print 'when they suddenly heard a sound like ' sounds at random - print chosen_name ' looked around, but they couldn't discover where the noise came from' - print chosen_name ' hid ' chosen_spot' - print 'They tried to look around, but couldn't see anything from there' - hidden = 'yes' - while hidden = 'yes' - print chosen_name 'still didn't see anything' - answer = ask 'does ' chosen_name ' move from their hiding spot?' - if answer = 'yes' - hidden == 'no' - print 'chosen_name moved from' chosen_spot - print 'And then they saw it was just' chosen_cause - print chosen_name 'laughed and went on with their day' - print The End - ``` - 16: - example_code: | - **Warning! This code needs to be debugged!** - ``` - country = ['The Netherlands', 'Poland', 'Turkey', 'Zimbabwe', 'Thailand', 'Brasil', 'Peru', 'Australia', 'India', 'Romania' ] - capitals = 'Amsterdam', 'Warshaw' 'Istanbul', 'Harare', 'Bangkok', 'Brasilia', 'Lima', 'Canberra', 'New Delhi', 'Bucharest' - score = 0 - for i in range 0 to 10 - answer = ask 'What's the capital of ' countries[i] - correct = capital[i] - if answer = correct - print 'Correct!' - score = score + 1 - else - print 'Wrong,' capitals[i] 'in the capital of' countries[i] - print 'You scored ' score ' out of 10' - - ``` - 17: - example_code: | - **Warning! This code needs to be debugged!** - ``` - define food_order - toppings = ask 'pepperoni, tuna, veggie or cheese?' - size = ask 'big, medium or small?' - number_of_pizza = ask 'How many these pizzas would you like?' - - print 'YOU ORDERED' - print number_of_pizzas ' size ' topping ' pizza' - - define drinks_order - drink = ask 'water, coke, icetea, lemonade or coffee?' - number_of_drinks = ask 'How many of these drinks would you like?' - - print 'YOU ORDERED' - print number_of_drinks ' ' drink - - 'Welcome to Hedy pizza' - more_food = ask 'Would you like to order a pizza?' - while more_food = 'yes' - return food_order - more_food = ask 'Would you like to order a pizza?' - more_drinks = ask 'Would you like to order some drinks?' - while more_drinks == 'yes' - call drink_order - more_drinks == ask 'Would you like to order more drinks?' - - - print 'Thanks for ordering!' - ``` - 18: - example_code: | - **Warning! This code needs to be debugged!** - ``` - animals = ['pig', 'dog', 'cow'] - sounds = ['oink', 'woof', 'moo'] - for i in range 1 to 3 - animal = animals[i] - sound = sounds[i] - print 'Old MacDonald had a farm' - print 'E I E I O!' - print 'and on that farm he had a ' animal - print 'E I E I O!' - print 'with a ' sound sound ' here' - print 'and a ' sound sound ' there' - print 'here a ' sound - print 'there a ' sound - print 'everywhere a ' sound sound - ``` default: name: Enkonduko default_save_name: enkonduko @@ -1028,30 +653,6 @@ adventures: {for} tago {in} tagoj {print} nomoj {at} {random} ' lavas telerojn je ' tago ``` - elif_command: - description: elif - levels: - 17: - example_code: | - ``` - prices = ['1 million dollars', 'an apple pie', 'nothing'] - your_price = prices[{random}] - {print} 'You win ' your_price - {if} your_price == '1 million dollars' : - {print} 'Yeah! You are rich!' - {elif} your_price == 'an apple pie' : - {print} 'Lovely, an apple pie!' - {else}: - {print} 'Better luck next time..' - ``` - for_command: - description: for command - levels: - 11: - story_text: |- - In this level, we add a new form of the `{for}`. In earlier levels, we used `{for}` with a list, but we can also use `{for}` with numbers. - We do that by adding a variable name, followed by `{in}` `{range}`. We then write the number to start at, `{to}` and the number to end at. - Try the example to see what happens! In this level again, you will need to use indentations in lines below the `{for}` statements. fortune: name: Aŭguristo default_save_name: Aŭguristo @@ -1182,67 +783,6 @@ adventures: 12: story_text: | En ĉi tiu nivelo, vi povas montri plurvortajn aŭguraĵojn jene: - example_code: | - ``` - fortunes = 'you will be rich', 'you will fall in love', 'you will slip on a banana peel' - {print} 'I will take a look in my crystall ball for your future.' - {print} 'I see... I see...' - {sleep} - {print} fortunes {at} {random} - ``` - functions: - levels: - 12: - example_code: | - ``` - sides = 'left', 'right' - limbs = 'hand', 'foot' - colors = 'red', 'blue', 'green', 'yellow' - - {define} turn - chosen_side = sides {at} {random} - chosen_limb = limbs _ - chosen_color = colors _ - {print} chosen_side ' ' chosen_limb ' on ' chosen_color - - {print} 'Lets play a game of Twister!' - {for} i {in} {range} 1 to _ - {call} turn - {sleep} 2 - ``` - 13: - story_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. - - For example in this code we've programmed the first verse of the song 'My Bonnie is over the ocean'. - In this example code the argument `place` is used. Place is a variable that is only used in the function, so an argument. - To use `place` we have programmed the line `define song with place`. - When the function is called, computer will replace the argument `place`, with the piece of text after `call song with`. - - ### Exercise - The next verse of this song goes: - - Last night as I lay on my pillow - Last night as I lay on my bed - Last night as I lay on my pillow - I dreamed that my Bonnie is dead - - Can you program this verse in the same way as the example? - 14: - example_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?' - - new_price = _ calculate_new_price {with} old_price, _ - {print} 'The new price is ' new_price ' dollar' - ``` haunted: name: Hantata domo default_save_name: Hantata domo @@ -1285,86 +825,12 @@ adventures: {print} Ho ne! Rapidu al la kuirejo. {print} Sed dum vi eniras monstro_3 atakas vin! ``` - example_code_2: | - ``` - monster_1 {is} _ - monster_2 {is} _ - monster_3 {is} _ - {print} You enter the haunted house. - {print} Suddenly you see a monster_1 - {print} You run into the other room, but a monster_2 is waiting there for you! - {print} Oh no! Quickly get to the kitchen. - {print} But as you enter monster_3 attacks you! - ``` - 3: - story_text: | - In the previous levels you've made an introduction to your haunted house game, but as you might have noticed the story would always have a dreadful end. - In this level you can make your story more interactive by changing the outcome of the game; sometimes you'll get eaten, sometimes you'll escape! - Let Hedy decide randomly! 4: story_text: | En ĉi tiu nivelo vi lernas kiel uzi citilojn en viaj ludoj. Ĉu vi povas igi vian Hantatan Domon rulebla en Nivelo 4? - example_code: | - ``` - {print} _Escape from the haunted house!_ - {print} _There are 3 doors in front of you..._ - choice {is} {ask} _Which door do you choose?_ - {print} _You picked door ..._ choice - monsters {is} a zombie, a vampire, NOTHING YOUVE ESCAPED - {print} _You see..._ - {sleep} - {print} monsters {at} {random} - ``` - 5: - story_text: | - Up until this level the haunted house game always asked the player to choose a door, but as you might have noticed, they didn't really have to answer correctly. - If the player filled in a completely random answer, the game would still work and the player might even win (despite not picking a door). - In this level you can only win the game by picking the same door Hedy picked randomly. - example_code: | - ``` - {print} 'Escape from the haunted house!' - {print} 'There are 3 doors in front of you...' - doors {is} 1, 2, 3 - monsters {is} werewolf, mummy, vampire, zombie - chosen_door {is} {ask} 'Which door do you choose?' - {print} 'You chose door...' chosen_door - {sleep} - correct_door {is} doors {at} {random} - {if} chosen_door {is} correct_door {print} 'Great! Youve escaped!' - {else} {print} 'Oh no! You are being eaten by a...' monsters {at} {random} - ``` - 9: - story_text: | - In this level you can use nesting, which allows you to make the haunted house even more interactive! - ### Exercise - Now it's very hard to win this game, can you make it easier to win? - For example by only having 1 wrong door and 2 correct doors instead of 1 correct door and 2 wrong ones? - example_code: | - ``` - {print} 'Escape from the Haunted House!' - ludanto = vivanta - pordoj = 1, 2, 3 - monstroj = kadavromonstro, vampiro, araneego - {repeat} 3 {times} - {if} ludanto {is} vivanta - ĝusta_pordo {is} pordoj {at} {random} - {print} 'Jen tri pordoj antaŭ vi…' - elektita_pordo = {ask} 'Kiun pordon elekti?' - {if} elektita_pordo {is} ĝusta_pordo - {print} 'Neniu monstro ĉi tie!' - {else} - {print} 'Vin manĝas ' monstroj {at} {random} - ludanto = mortinta - {else} - {print} 'FINO' - {if} ludanto {is} vivanta - {print} 'Bonege! Vi pretervivis!' - ``` 11: - story_text: | - In this level we've changed the repeat command and we've added a line to our haunted house that tells the player in which room they are. example_code: | ``` {print} 'Eskapu el la Hantata Domo!' @@ -1387,50 +853,6 @@ adventures: {if} ludanto {is} vivanta {print} 'Bonege! Vi pretervivis!' ``` - if_command: - description: Introducing the if command - levels: - 9: - story_text: | - In this level you can also put an {if} command inside another {if} command. - in_command: - description: Introducing the in command - levels: - 5: - example_code_2: | - ``` - animals is dog, cow, sheep - answer is ask 'What is your favorite animal?' - _ answer _ animals _ 'Mine too!' - _ _ 'My favorite animals are dogs, cows and sheep' - ``` - is_command: - description: introducing is command - levels: - 2: - story_text_2: | - ### Exercise - Time to make your own variables! - In the example code we made an example of the variable `favorite_animal`. In line 1 the variable is set, and in line 2 we haved used the variable in a print command. - Firstly, finish our example by filling in your favorite animal on the blank. Then make at least 3 of these codes yourself. Pick a variable, and set the variable with the {is} command. Then use it with a {print} command, just like we did. - 14: - example_code: | - ``` - age = {ask} 'How old are you?' - {if} age > 12 - {print} 'You are older than I am!' - ``` - example_code_3: | - ``` - name = {ask} 'What is your name?' - {if} name != 'Hedy' - {print} 'You are not Hedy' - ``` - - {if} age < 13 - {print} 'You are younger than me!' - {else} - {print} 'You are older than me!' language: name: Lingvo default_save_name: Lingvo @@ -1465,28 +887,6 @@ adventures: {print} 'Malĝuste, ' francaj_vortoj[i] ' signifas la jenon: ' traduko[i] {print} 'Vi respondis ' poentaro ' fojojn ĝuste.' ``` - maths: - levels: - 6: - example_code: | - ``` - {print} '5 plus 5 is ' 5 + 5 - {print} '5 minus 5 is ' 5 - 5 - {print} '5 times 5 is ' 5 * 5 - ``` - 12: - example_code_2: | - ``` - a = 'Hello ' - b = 'world!' - {print} a + b - ``` - - {print} 2.5 + 2.5 - music: - levels: - 6: - story_text: "Instead of playing notes, you can also play numbers now. Simply type `{play} 1` for the lowest note, `{play} 70` for the highest note, or anything in between.\n\n### Exercise\n This calls for musical maths! Try out the example code a couple of times with different starting numbers. \nThen, see if you can compose a song using the numbers.\n" parrot: name: Papago default_save_name: Papago @@ -1502,9 +902,6 @@ adventures: {echo} {echo} ``` - story_text_2: | - ### Exercise - Can you make the parrot ask a different question? Fill in the blanks in the example! 2: story_text: | Kreu vian propran Interretan dorlotpapagon, kiu kopios vin! @@ -1518,9 +915,6 @@ adventures: {sleep} {print} nomo ``` - story_text_2: | - ### Exercise - You can use variables to make the parrot say more than only your name. Can you complete this code? 3: story_text: | Instruu al via papago novan vorton per `{add}`. @@ -1533,10 +927,6 @@ adventures: {print} 🧒 Diru nova_vorto , Hedy! {print} 🦜 vortoj {at} {random} ``` - 4: - story_text: | - In this level we have to use quotation marks with the commands `{ask}` and `{print}`. - Can you complete the code by adding quotation marks? 5: story_text: | Rekompencu vian papagon, se ĝi diras la ĝustan vorton! @@ -1556,59 +946,6 @@ adventures: name: Ŝparujo default_save_name: Ŝparujo description: Kalkulu vian poŝmonon! - levels: - 12: - story_text: | - In this adventure you learn how to make a digital piggy bank, to calculate how much money you have and how long you need to save up to buy what you want! - example_code: | - ``` - {print} 'The digital piggy bank' - wish = {ask} 'What would you like to buy?' - price = {ask} 'How much does that cost?' - saved = {ask} 'How much money have you saved already?' - allowance = {ask} 'How much pocket money do you get per week?' - to_save = price - saved - weeks = to_save / allowance - {print} 'You can buy a ' wish ' in ' weeks ' weeks.' - ``` - 14: - example_code: | - ``` - _ calculate_budget with wish, money, allowance - to_save = wish - money - weeks = to_save / allowance - {if} wish _ money - {print} 'You need to save up some more!' - {print} 'Youll need ' weeks ' more weeks.' - {else} - {print} 'Great! You have enough' - {print} 'Lets go shopping!' - - money = {ask} 'How much money have you saved?' - wish = {ask} 'How much money do you need?' - allowance = {ask} 'How much pocket money do you get each week?' - - {call} calculate_budget with _, _, _ - ``` - pressit: - levels: - 9: - story_text: | - Now that you know how to combine statements, you can create a touch type tool with `{pressed}`. - - ### Exercise - Finish the code. Each time a random letter should be chosen, which you have to press. You get a point for a correct press, and and two points deduction for a wrong press. - **(extra)** Clear the screen after each letter, and show the user how many points they have scored. - print_command: - levels: - 18: - example_code_2: | - ``` - temperature = 25 - {print}('It is ', temperature, ' degrees outside') - ``` - - {print}('My name is ', name) quizmaster: name: Kvizmajstro default_save_name: Kvizmajstro @@ -1638,43 +975,6 @@ adventures: {if} poentoj_b > poentoj_a {print} 'Vi apartenas al la B-klubo' ``` - random_command: - levels: - 16: - story_text: |- - We are going to make lists the Python way, with square brackets around the lists! We also keep the quotation marks around each item like we have learned in previous levels. - We use square brackets to point out a place in a list. For example: `friends[1]` is the first name on the list of friends, as you can see in the first part of the example code. The second part of the example code shows you that we can also match 2 lists using the variable i. - repeat_command: - description: repeat command - levels: - 7: - story_text: | - ## Repeat! Repeat! Repeat! - Level 7 adds the `{repeat}` command. `{repeat}` can be used to execute one line of code multiple times. Like this: - - ### Exercise - Play around with the repeat command. Can you make the happy birthday song in only 3 lines of code instead of 4 now? - 9: - story_text: | - Great job! You've reached another new level! In the previous level you've learned to use multiple lines of code in an {if} or {repeat} command. But you can't yet combine the two... - Good news! In this level you will be allowed to put an {if} inside an {if}, or inside a {repeat} command. Putting a block of code inside another block of code is called nesting. ``` Putting a block of code inside another block of code is called nesting. - example_code: | - ``` - answer = {ask} 'Are you ready to learn something new?' - {if} answer {is} yes - {print} 'Great! You can learn to use the repeat command in the if command!' - {print} 'Hooray!' - {print} 'Hooray!' - {print} 'Hooray!' - {else} - {print} 'Maybe you should practice some more in the previous level' - repeat_command_2: - description: repeat command 2 - levels: - 7: - story_text_2: | - Another interesting thing you can so with the `{repeat}` command is using variables to set the amount of times something should be repeated. In the example code you can see that we first ask the person how old they are. - Then, in line 3, the question is repeated 'age' times. So we have used the variable 'age' with the `{repeat}` command. restaurant: name: Restoracio default_save_name: Restoracio @@ -1683,9 +983,6 @@ adventures: 1: story_text: | En Nivelo 1, vi povas krei vian propran virtualan restoracion kaj preni la mendojn de viaj gastoj. - story_text_2: | - ### Exercise - Can you think of more lines to add to your restaurant code? For example, can you {ask} the guests what they'd like to drink, tell them the price, or wish them a pleasant meal? example_code_2: | ``` {print} Bonvenon al Restoracio Hedy 🍟 @@ -1695,9 +992,6 @@ adventures: {print} Ĝi estas kuirata! ``` 2: - story_text: | - In level 2 you could expand your restaurant by using variables. In level 1 Hedy could only {echo} the order once and only remember the last thing that was ordered. - Now you can use variables and Hedy can remember both the food and the drinks! example_code: | ``` {print} Bonvenon al Restoracio Hedy! @@ -1710,9 +1004,6 @@ adventures: {print} Dankon pro via mendo. {print} Viaj manĝaĵoj kaj trinkaĵoj estos ĝuste tie! ``` - story_text_2: | - ### Exercise - Can you make this code more elaborate? For example by adding drinks to the order? Or...? 3: story_text: | Ĉu vi havas problemon decidante, kion vi volas manĝi por vespermanĝo? Vi povas lasi Hedy elekti por vi! @@ -1734,8 +1025,6 @@ adventures: {print} Jen la totalo: prezoj {at} {random} {print} Dankon kaj ĝuu vian manĝon! ``` - story_text_2: | - Does your costumer have any allergies or do they dislike certain dishes? Then you can use the `{remove}`command to remove it from your menu. example_code_2: | ``` {print} Mistera laktotrinkaĵo @@ -1745,13 +1034,6 @@ adventures: {print} Vi ricevas laktotrinkaĵon kun ingrediencoj {at} {random} ``` 4: - story_text: | - ### Exercise - Add the quotation marks to this code to make it work! Be careful: variables should not be in quotation marks. - Then, use the `{clear}` command to only show one line at a time in your output screen. - - ### Exercise 2 - Go back to the previous level and copy your restaurant code. Make the code work in this level by adding quotation marks in the right spots and add some `{clear}` commands. example_code: | ``` _ Add the quotation marks to this code _ @@ -1766,9 +1048,6 @@ adventures: {print} Your manĝaĵo and trinkaĵo will be right there! ``` 5: - story_text: | - In this level the {if} command allows you to {ask} your customers questions and give different responses to the answers. - In the example below, you see that you can {ask} the customer {if} they want to hear the specials and Hedy can respond accordingly. example_code: | ``` {print} 'Bonvenon al Restoracio Hedy!' @@ -1786,8 +1065,6 @@ adventures: {print} 'Dankon pro via mendo. Ĝuu vian manĝon!' ``` 6: - story_text: | - In this level you can use maths to calculate the total price of your customer's order, which can make your virtual restaurant more realistic. example_code: | Vi povas verki simplan kodon por restoracio, jene: ``` @@ -1815,10 +1092,6 @@ adventures: {print} 'Dankon pro via mendo! La manĝaĵo baldaŭ venos!' ``` 9: - story_text: | - In this level you can use nesting to make your restaurant more realistic and more fun! - For example you would {ask} for sauce {if} somebody orders fries, but you wouldn't {if} someone orders pizza! - Check out the example, and try this at your own virtual restaurant! example_code: | ``` {print} 'Bonvenon al Restoracio Hedy!' @@ -1900,9 +1173,6 @@ adventures: {print} 'Bonvolu pagi ' prezo ' spesmilojn' ``` 13: - story_text: | - In this level we can use the new commands to upgrade our restaurant. - We use `{and}` to see {if} two things are both the case. example_code: | ``` prezo = 10 @@ -1914,11 +1184,6 @@ adventures: {print} 'La totalo estas ' prezo ' spesmiloj' ``` 15: - story_text: | - Per la `{while}` vi povas certigi, ke viaj klientoj povas mendadi ĝis ili finiĝos. - - ### Exercise - Correctly add the `{while}` command to this code. example_code: | ``` {print} 'Bonvenon al McHedy' @@ -1964,16 +1229,6 @@ adventures: elektoj {is} roko, papero, tondilo {print} elektoj {at} {random} ``` - story_text_2: | - ### Exercise - Now you only have one player, so can you add a second player? - You can even use variables to name player 1 and player 2. - example_code_2: | - ``` - choices {is} rock, paper, scissors - {print} player 1 chooses... choices {at} {random} - {print} player 2 _ - ``` 5: story_text: | En ĉi tiu nivelo ni povas determini kiu venkis. @@ -2060,19 +1315,6 @@ adventures: {print} 'Vi gajnas la partion!' gajnis = 'jes' ``` - rock_2: - levels: - 2: - story_text: | - Now that you have learned how to use the `{ask} command, you can make your rock, paper, scissors code interavtive too! - - ### Exercise - Make the rock, paper, scissors code interactive by adding the `{ask}` command and a question to your rock, paper, scissors code. - example_code: | - ``` - choice is _ - {print} I choose choice - ``` secret: name: Superspiono default_save_name: Superspiono @@ -2108,13 +1350,6 @@ adventures: {else} {print} 'Iru al la stacidomo je la 10a horo' ``` - sleep_command: - description: introducing sleep command - levels: - 2: - story_text: | - ## The sleep command - Another new command in this level is `{sleep}`, which pauses your program for a second. If you type a number behind the {sleep} command, the program pauses for that amount of seconds. songs: name: Kantu! default_save_name: Kanto @@ -2135,16 +1370,6 @@ adventures: ``` Vi nun povas ripeti liniojn 2 ĝis 6 tiom da fojoj, kiom vi volas, kopiante la liniojn. - example_code_2: | - ``` - number = 6 - number = number - 1 - print number ' little monkeys jumping on the bed' - print 'One fell off and bumped his head' - print 'Mama called the doctor and the doctor said' - print 'NO MORE MONKEYS JUMPING ON THE BED!' - sleep - ``` 7: story_text: | Kantoj ofte enhavas multe da ripetaĵojn. Ekzemple… Ŝarkido! Se vi kantas ĝin, vi ripete kantas la samajn vortojn: @@ -2217,11 +1442,6 @@ adventures: {print} 'aliloke ' sono {print} 'ĉie ' sono sono ``` - story_text_2: | - ### Exercise 2 - Print the song Five little moneys jumping on the bed. Look up the text if you don't remember. - - **(extra)** Print the song Old MacDonald had a farm, and make sure all animals make a different sound, using an `{if}`. 11: story_text: | En ĉi tiu nivelo, oni povas uzi la komandon `{for} i {in} {range}` por fari kantojn, kiuj uzas kalkuladon. @@ -2418,99 +1638,3 @@ adventures: Ankaŭ ni nun povas plibonigi la programon, kiu desegnas malsamajn figurojn. Ĉu vi povas eltrovi kiom malproksimen la testudo devas turni ĉi tien? Finu la kodon kaj vi povas desegni ajnan plurangulon, kiun vi ŝatus! example_code_2: "```\nanguloj = {ask} 'Kiom da anguloj mi desegnu?'\nangulo = 360 / anguloj \n{repeat} anguloj {times}\n {turn} _\n {forward} _\n```\n" - 9: - story_text: | - Now that we can use a `{repeat}` inside a `{repeat}`, we can create more complex figures. - - ### Exercise 1 - This code creates three black triangles, change that into five pink squares. - - **(extra)** Create a figure of your own choosing consisting of at least two different shapes types. - 10: - story_text: | - In this level you can make the turtle draw a figure. - The turtle will travel the distances in the list, one by one, making bigger and bigger steps. - ### Exercise 1 - Add a 90 degree turn in the loop, so that a spiral is drawn. - Add at least 5 numbers to the list, so the spiral grows larger. - **(extra)** can you change the spiral into another shape? Experiment with numbers for the turn! - ### Exercise 2 - The spiral is drawn outwards, make it go inwards? - turtle_draw_it: - levels: - 9: - example_code: | - Hint for the nested squares: - ``` - colors = red, blue, orange, yellow, pink, purple, green, brown, black - distance = 120 - repeat 5 times - _ - ``` - Hint for the flags: - ``` - country = ask 'which country would you like to see the flag of?' - if country is 'the Netherlands' - color_1 = red - color_2 = white - color_3 = blue - ``` - 10: - example_code: | - Hint Nested Hexagon: - ``` - distances = 100, 80, 60, 40, 20 - {for} distance {in} distances - _ - ``` - - Hint Traffic Lights: - ``` - colors = red, yellow, green - {for} chosen_color {in} colors - color _ - {repeat} _ - ``` - 12: - story_text: | - ### Exercise - Recreate the drawings with the turtle! - Hint: Bracelet designing program. Firstly, define a function **for each shape** you want to use on the bacelet. Then, add the shapes to the bacelet like this: - - Bracelet Designing program - example_code: | - ``` - {define} draw_a_square - _ - - {color} white - {turn} -90 - {forward} 300 - {turn} 180 - - {for} i {in} {range} 1 {to} 5 - {color} gray - {forward} 100 - shape = {ask} 'What kind of shape would you like next on the bracelet?' - chosen_color = {ask} 'In which color?' - {color} chosen_color - {if} shape = 'square' - {call} draw_a_square - ``` - while_command: - description: while - years: - description: Countdown to the new year! - levels: - 11: - story_text: | - In this level you can use the `{for} i {in} {range}` command to countdown to the New Year. - - ### Exercise - Fill in the blanks and make the code work! - example_code: | - ``` - for _ in _ 10 to 1 - {print} i - {print} 'Happy New Year!' - ``` diff --git a/content/adventures/es.yaml b/content/adventures/es.yaml index 3d7894c8787..5fddc8ef0cf 100644 --- a/content/adventures/es.yaml +++ b/content/adventures/es.yaml @@ -3115,10 +3115,6 @@ adventures: _ ``` 4: - story_text: | - En este nivel podemos programar el juego de piedra, papel, tijera. Pero si quieres añadir texto, aquí también tienes que usar comillas. - ### Exercise - Fill in quotation marks on the blanks. Mind that the variable `choices` should be outside the quotes. example_code: "```\nopciones {is} piedra, papel, tijeras\n{print} _El ordenador elige..._ opciones {at} {random}\n```\n" 5: story_text: | diff --git a/content/adventures/et.yaml b/content/adventures/et.yaml index f19892de0dd..9c53cd08fb9 100644 --- a/content/adventures/et.yaml +++ b/content/adventures/et.yaml @@ -2,17 +2,6 @@ adventures: story: levels: 1: - story_text: | - In level 1 you can make a story with a different main character that you enter yourself. - - As the first line, use this code: - - ``` - {ask} who is the star in your story? - ``` - - 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} Selle loo peategelane on @@ -21,561 +10,6 @@ adventures: {print} Ta kuuleb hirmsaid hääli igal pool {print} Ta kardab, et selles metsas kummitab ``` - story_text_2: | - ### Exercise - Can you make your own story in Hedy now by using `{print}` , `{ask}` and `{echo}`? - 2: - 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: - example_code_2: | - ``` - {print} He hears a sound - animals {is} 🐿, 🦔, 🦇, 🦉 - animal {is} {ask} What do you think it is? - {add} animal {to_list} animals - {print} it was a animals {at} {random} - ``` - story_text_3: | - This is an example of the `{remove}` command in your story - 5: - story_text: | - In this level you can program different endings, which will make your story even more fun. - - 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 'encounter 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}`. - 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! - 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. - 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' - ``` - add_remove_command: - name: '{add} {to} & {remove} {from}' - 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. - 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. - and_or_command: - description: introducing and or - ask_command: - description: Introduction ask command - levels: - 1: - 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. - calculator: - levels: - 6: - story_text: | - Now that you can calculate, you can also create a program to practice maths calculations. You can make up the calculations yourself, for example: - example_code: | - ``` - correct_answer = 11 * 27 - answer = {ask} 'How much is 11 times 27?' - {if} answer {is} correct_answer {print} 'good job!' - {else} {print} 'Wrong! It was ' correct_answer - ``` - story_text_2: | - You can also let the computer do random calculations on its own using {random}. - example_code_2: | - ``` - tables = 4, 5, 6, 8 - numbers = 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 - table = tables {at} {random} - number = numbers {at} {random} - correct_answer = table * number - answer = {ask} 'how much is ' table ' times ' number '?' - {if} answer {is} correct_answer {print} 'okay' - {else} {print} 'mistake! it was ' correct_answer - ``` - 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`. - 11: - example_code: | - ``` - number = 10 - {for} i {in} {range} 1 to 10 - {print} i * number - ``` - 12: - story_text: | - Now you can make a calculator that works for decimal numbers. - example_code: | - ``` - number1 = {ask} 'What is the first number?' - number2 = {ask} 'What is the second number?' - answer = number1 + number2 - {print} number1 ' plus ' number2 ' is ' answer - ``` - 14: - 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 - clear_command: - description: clear command - debugging: - levels: - 3: - 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} - ``` - 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! - 8: - 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: - 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!' - {else} - 'I'm sorry we don't sell that' - topping {is} {ask} 'What kind of topping would you like?' - sauce {is} {ask} 'What kind of sauce would you like?' - {print} One chosen_bread with topping and sauce. - price = amount * 6 - {print} 'That will be 'price dollar' please' - ``` - - price = amount * 6 - {print} 'That will be 'price dollar' please' - 10: - example_code: | - **Warning! This code needs to be debugged!** - ``` - names = Muad Hasan Samira Noura - activities = fly a kite, go swimming, go hiking, catch tan in the sun - {for} name {is} names - {print} At the beach name loves to activity at random - ``` - 11: - story_text: |- - ### Exercise - Debug this calender program. The output of this program is supposed to look like a list of dates. - For example: - - ``` - Hedy calender - Here are all the days of November - November 1 - November 2 - November 3 - ``` - And so on. - - Mind that you have to test your code extra carefully for the month February, because the amount of days in this month changes in leap years. - example_code: | - **Warning! This code needs to be debugged!** - ``` - print 'Hedy calender' - months_with_31 days = January, March, May, July, September, October, December - months_with_30_days = April, June, August, November - month = ask 'Which month would you like to see?' - if month in months_with_31_days - days = 31 - if month in months_with30_days - days = 30 - if month = February - leap_years = 2020, 2024, 2028, 2036, 2040, 2044, 2028 - year = ask 'What year is it?' - if year in leap_years - days = 29 - else - days = 28 - - print 'Here are all the days of ' moth - for i in range 1 to days - print month i - ``` - 12: - example_code: | - **Warning! This code needs to be debugged!** - ``` - define greet - greetings = 'Hello', 'Hi there', 'Goodevening' - print greetings at random - - define take_order - food = ask 'What would you like to eat?' - print 'One food' - drink = 'What would you like to drink?' - print 'One ' drink - more = ask 'Would you like anything else?' - if more is 'no' - print 'Alright' - else - print 'And ' more - print 'Thank you' - - print 'Welcome to our restaurant' - people = ask 'How many people are in your party tonight?' - for i in range 0 to people - call greet_costumer - ``` - 13: - example_code: | - **Warning! This code needs to be debugged!** - ``` - defin movie_recommendation with name - action_movies == 'Die Hard', 'Fast and Furious', 'Inglorious Bastards' - romance_movies = 'Love Actually', 'The Notebook', 'Titanic' - comedy_movies = 'Mr Bean' 'Barbie''Deadpool' - kids_movies = 'Minions', 'Paddington', 'Encanto' - if name is 'Camila' or name is 'Manuel' - recommended_movie = kids_movie at random - if name is 'Pedro' or 'Gabriella' - mood = ask 'What you in the mood for?' - if mood is 'action' - recommended_movie = comedy_movies at random - if mood is 'romance' - recommended_movie = romance_movies - if mood is 'comedy' - recommended_movie = comedy_movies at random - - print 'I would recommend ' recommended_movie ' for ' name - - name = ask 'Who is watching?' - recommendation = ask 'Would you like a recommendation?' - if recommendaion is 'yes' - print movie_recommendation with name - else - print 'No problem!' - ``` - 14: - example_code: | - **Warning! This code needs to be debugged!** - ``` - define calculate_heartbeat - print 'Press your fingertips gently against the side of your neck' - print '(just under your jawline)' - print 'Count the number of beats you feel for 15 seconds' - beats == ask 'How many beats do you feel in 15 seconds?' - heartbeat = beats*4 - print 'Your heartbeat is ' heartbeat - if heartbeat >= 60 or heartbeat <= 100 - print 'Your heartbeat seems fine' - else - if heartbeat > 60 - print 'Your heartbeat seems to be too low' - if heartbeat < 100 - print 'Your heartbeat seems to be too high' - print 'You might want to contact a medical professional' - - measure_heartbeat = ask 'Would you like to measure your heartbeat?' - if measure_heartbeat = 'yes' - call measure_heartbeat - else - 'no problem' - ``` - - print '(just under your jawline)' - print 'Count the number of beats you feel for 15 seconds' - beats == ask 'How many beats do you feel in 15 seconds?' - heartbeat = beats*4 - print 'Your heartbeat is ' heartbeat - if heartbeat >= 60 or heartbeat <= 100 - print 'Your heartbeat seems fine' - else - if heartbeat > 60 - print 'Your heartbeat seems to be too low' - if heartbeat < 100 - print 'Your heartbeat seems to be too high' - print 'You might want to contact a medical professional' - - measure_heartbeat = ask 'Would you like to measure your heartbeat?' - if measure_heartbeat = 'yes' - call measure_heartbeat - else - 'no problem' - 15: - example_code: | - **Warning! This code needs to be debugged!** - ``` - names = 'Tanya', 'Romy', 'Kayla', 'Aldrin', 'Ali' - verbs='walking', 'skipping', 'cycling', 'driving', 'running' - locations = 'on a mountaintop', 'in the supermarket', 'to the swimming pool' - hiding_spots = 'behind a tree', under a table', in a box' - sounds = 'a trumpet', 'a car crash', 'thunder' - causes_of_noise = 'a television', 'a kid with firecrackers', 'a magic elephant', 'a dream' - - chosen_ name = names at random - chosen_verb = verbs at random - chosen_location = 'locations at random' - chosen_sounds = noises at random - chosen_spot = hiding_spots random - chosen_causes = causes_of_noise at random - - print chosen_name ' was ' chosen_verb ' ' chosen_location - print 'when they suddenly heard a sound like ' sounds at random - print chosen_name ' looked around, but they couldn't discover where the noise came from' - print chosen_name ' hid ' chosen_spot' - print 'They tried to look around, but couldn't see anything from there' - hidden = 'yes' - while hidden = 'yes' - print chosen_name 'still didn't see anything' - answer = ask 'does ' chosen_name ' move from their hiding spot?' - if answer = 'yes' - hidden == 'no' - print 'chosen_name moved from' chosen_spot - print 'And then they saw it was just' chosen_cause - print chosen_name 'laughed and went on with their day' - print The End - ``` - 16: - example_code: | - **Warning! This code needs to be debugged!** - ``` - country = ['The Netherlands', 'Poland', 'Turkey', 'Zimbabwe', 'Thailand', 'Brasil', 'Peru', 'Australia', 'India', 'Romania' ] - capitals = 'Amsterdam', 'Warshaw' 'Istanbul', 'Harare', 'Bangkok', 'Brasilia', 'Lima', 'Canberra', 'New Delhi', 'Bucharest' - score = 0 - for i in range 0 to 10 - answer = ask 'What's the capital of ' countries[i] - correct = capital[i] - if answer = correct - print 'Correct!' - score = score + 1 - else - print 'Wrong,' capitals[i] 'in the capital of' countries[i] - print 'You scored ' score ' out of 10' - - ``` - 17: - example_code: | - **Warning! This code needs to be debugged!** - ``` - define food_order - toppings = ask 'pepperoni, tuna, veggie or cheese?' - size = ask 'big, medium or small?' - number_of_pizza = ask 'How many these pizzas would you like?' - - print 'YOU ORDERED' - print number_of_pizzas ' size ' topping ' pizza' - - define drinks_order - drink = ask 'water, coke, icetea, lemonade or coffee?' - number_of_drinks = ask 'How many of these drinks would you like?' - - print 'YOU ORDERED' - print number_of_drinks ' ' drink - - 'Welcome to Hedy pizza' - more_food = ask 'Would you like to order a pizza?' - while more_food = 'yes' - return food_order - more_food = ask 'Would you like to order a pizza?' - more_drinks = ask 'Would you like to order some drinks?' - while more_drinks == 'yes' - call drink_order - more_drinks == ask 'Would you like to order more drinks?' - - - print 'Thanks for ordering!' - ``` - 18: - example_code: | - **Warning! This code needs to be debugged!** - ``` - animals = ['pig', 'dog', 'cow'] - sounds = ['oink', 'woof', 'moo'] - for i in range 1 to 3 - animal = animals[i] - sound = sounds[i] - print 'Old MacDonald had a farm' - print 'E I E I O!' - print 'and on that farm he had a ' animal - print 'E I E I O!' - print 'with a ' sound sound ' here' - print 'and a ' sound sound ' there' - print 'here a ' sound - print 'there a ' sound - print 'everywhere a ' sound sound - ``` default: name: Sissejuhatus default_save_name: sissejuhatus @@ -600,12 +34,6 @@ adventures: See on kasulik, kuna nüüd sa saad igasugust teksti ekraanile kirjutada. Näiteks nagu sõnu, mida sa kasutad muutujanimena `{is}` käsus. Enamik programmeerimiskeeli kasutab kas ülakomasid või jutumärke teksti edasiandmiseks, nii et me oleme juba samm lähemal päris programmeerimise juurde! - example_code: | - ``` - {print} 'You need to use quotation marks from now on!' - answer {is} {ask} 'What do we need to use from now on?' - {print} 'We need to use ' answer - ``` 5: story_text: | 5. tasemel leiame midagi uut: `{if}`! `{if}` abil saad valida kahe vóimaluse vahel. @@ -616,35 +44,7 @@ adventures: nimi {is} {ask} 'Mis su nimi on?' {if} nimi {is} Hedy {print} 'lahe' {else} {print} 'buu!' ``` - 6: - story_text: | - In the previous level you have practiced with `{ask}` and `{if}`. For example you can ask guests what they would like to eat. - What you can't yet do though, is calculate the price for everyone's dinner. - - In the previous level you have practiced with `{ask}` and `{if}`. For example you can ask guests what they would like to eat. - What you can't yet do though, is calculate the price for everyone's dinner. - - This level makes it possible to use addition, subtraction and multiplication in your programs. This way you can calculate the prices in your restaurant, but you could also add a secret code to give your friends and family a discount. - Another option in this level is programming your own maths game, for your little brother or sister to practice their multiplications. - Go see for yourself! - example_code: | - ``` - {print} '5 plus 5 is ' 5 + 5 - {print} '5 minus 5 is ' 5 - 5 - {print} '5 times 5 is ' 5 * 5 - ``` - 7: - story_text: | - Level 7 adds the `{repeat}` command. `{repeat}` can be used to execute one line of code multiple times. - example_code: | - ``` - {repeat} 3 {times} {print} 'Hedy is fun!' - ``` 8: - story_text: | - `{ask}` and `{print}` still work as you know them. But `{if}` and `{repeat}` have changed! - You can now execute groups of code together, but you will have to *indent* the code. - That means putting four spaces at the beginning of the line. You will also have to indent when you just want to create a block of one line. example_code: | Niimoodi töötab `{repeat}` käsk nüüd: ``` @@ -663,1387 +63,3 @@ adventures: {print} 'SISSETUNGIJA!' {print} 'Sa ei saa seda arvutit kasutada!' ``` - 10: - story_text: |- - In this level we learn a new code called `{for}`. With `{for}` you can make a list and use all elements. - `{for}` creates a block, like `{repeat}` and `{if}` so all lines in the block need to start with spaces. - example_code: | - ``` - animals {is} dog, cat, blobfish - {for} animal {in} animals - {print} 'I love ' animal - ``` - 12: - story_text: |- - **Decimal numbers** - So far, Hedy did not allow for decimal numbers like 1.5, but now we do allow that. Note that computers use the `.` for decimal numbers. - example_code: | - ``` - {print} 'Two and a half plus two and a half is...' - {print} 2.5 + 2.5 - ``` - - {print} 2.5 + 2.5 - 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!' - ``` - 14: - story_text: | - We are going to learn more new items. You might know them already from mathematics, the `<` and `>`. - The `<` checks if the first number is smaller than the second, for example `age < 12` checks if `age` {is} smaller than 12. - If you want to check if the first number is smaller or equal to the second, you can use `<=`, for example `age <= 11`. - The `>` checks if the first number is bigger than the second, for example `points > 10` checks if `points` is larger than 10. - If you want to check if the first number is bigger or equal to the second, you can use `>=`, for example `points >= 11`. - You use these comparisons in an `{if}`, like this: - example_code: | - ``` - age = {ask} 'How old are you?' - {if} age > 12 - {print} 'You are older than I am!' - ``` - - {if} age < 13 - {print} 'You are younger than me!' - {else} - {print} 'You are older than me!' - 15: - story_text: |- - We are going to learn a new loop, the `{while}` loop! We continue the loop as long as the statement is true. - So don't forget to change the value in the loop. - - In the example code, we continue until a correct answer has been given. - If the correct answer is never given, the loop never ends! - example_code: | - ``` - answer = 0 - {while} answer != 25 - answer = {ask} 'What is 5 times 5?' - {print} 'A correct answer has been given' - ``` - 16: - story_text: |- - We are going to make lists the Python way, with square brackets around the lists! We also keep the quotation marks around each item like we have learned in previous levels. - You can use the square brackets as well to point out a place in the lists. - example_code: | - ``` - friends = ['Ahmed', 'Ben', 'Cayden'] - {print} friends[1] ' is the first friend on the list.' - {print} friends[2] ' is the second friend on the list.' - {print} friends[3] ' is the third friend on the list.' - #now we will match 2 lists using the variable i - lucky_numbers = [15, 18, 6] - {for} i {in} {range} 1 {to} 3 - {print} friends[i] 's lucky number is ' lucky_numbers[i] - ``` - 17: - story_text: |- - Now we are going to change a little bit with indentation. Every time that we need an indentation, we need `:` at the line before the indentation. - - In this level you can also use a new command: `{elif}`. `{elif}` is short for `{else} {if}` and you need it when you want to make 3 (or more!) options. - Check it out! - 18: - story_text: |- - We arrived at real Python code! That means we need to use parentheses with {print} and {range} from now on. - {print}('My name is ', naam) - dice: - levels: - 3: - example_code: | - ``` - choices {is} 1, 2, 3, 4, 5, earthworm - {print} choices {at} {random} - ``` - 4: - story_text: | - In this level we can make sentences with the die value in the sentence, with quotes of course. - This time the sample code is not quite complete. Can you finish the code? - 5: - story_text: | - You can also make a die again in this level using the `{if}`. - Complete the sample code so that the code says "You can stop throwing" once you have thrown an earthworm. - - But maybe you want to recreate a die from a completely different game. That's fine too! Then make up your own reaction. Eg 'yes' for 6 and 'pity' for something {else}. - example_code: | - ``` - choices {is} 1, 2, 3, 4, 5, earthworm - throw {is} _ - {print} 'you have' _ 'thrown' - {if} _ {is} earthworm {print} 'You can stop throwing.' _ {print} 'You have to hear it again!' - ``` - 6: - story_text: | - You can also make an Earthworm die again in this, but now you can also calculate how many points have been rolled. - You may know that the worm counts 5 points for Earthworms. Now after a roll you can immediately calculate how many points you have thrown. - This is the code to calculate points for one die: - example_code: | - ``` - choices = 1, 2, 3, 4, 5, earthworm - points = 0 - throw = choices {at} {random} - {print} 'you threw' throw - {if} throw {is} earthworm points = points + 5 {else} points = points + throw - {print} 'those are' points ' point' - ``` - Can you make the code so that you get the total score for 8 dice? To do that, you have to cut and paste some lines of the code. - example_code_2: | - Did you manage to calculate the score for 8 dice? That required a lot of cutting and pasting, right? We are going to make that easier in level 7! - 7: - story_text: | - You can also make a die again in level 5. With the `{repeat}` code you can easily roll a whole hand of dice. - Try to finish the sample code! The dashes should contain multiple commands and characters. - - But maybe you want to make a completely different die. Of course you can! - example_code: | - ``` - choices = 1, 2, 3, 4, 5, earthworm - {repeat} _ _ {print} _ _ _ - ``` - 10: - story_text: | - Is everybody taking too long throwing the dice? In this level you can let Hedy throw all the dice at once! - example_code: | - ``` - players = Ann, John, Jesse - choices = 1, 2, 3, 4, 5, 6 - {for} player {in} players - {print} player ' throws ' choices {at} {random} - {sleep} - ``` - dishes: - description: Use the computer to see who does the dishes (Start at level 2) - levels: - 3: - story_text: | - Do you always disagree at home about who should wash the dishes or change the litter box today? - Then you can let the computer choose very fairly. You can program that in this level! - You first make a list of the members of your family. Then choose '{at} {random}' from the list. - example_code: | - ``` - people {is} mom, dad, Emma, Sophie - {print} people {at} {random} - ``` - story_text_2: | - Don't feel like doing the dishes yourself? Hack the program to remove your name from the list. - 4: - story_text: | - With quotation marks you can make your dishwashing planning more beautiful. - This time the sample code is not quite complete. - - Can you complete the code by filling the blanks? Every blank must be replaced with one word of symbol. - - Tip: Don't forget the quotation marks! - 5: - story_text: | - With the `{if}` you can now have more fun with choice in the program. You can have your program respond to the choice that the computer has made. - - Can you finish the code so that it prints 'too bad' when it is your turn and otherwise 'yes!'? - Don't forget the quotes! - example_code: | - ``` - people {is} mom, dad, Emma, Sophie - dishwasher {is} people {at} {random} - {if} dishwasher {is} Sophie {print} _ too bad I have to do the dishes _ {else} {print} 'luckily no dishes because' _ 'is already washing up' - ``` - 6: - story_text_2: | - If you are extremely unlucky the previous program might choose you to to the dishes for the whole week! That's not fair! - To create a fairer system you can use the `{remove}` command to remove the chosen person from the list. This way you don't have to do the dishes again untill everybody has had a turn. - - Monday and tuesday are ready for you! Can you add the rest of the week? - And... can you come up with a solution for when your list is empty? - example_code_2: | - ``` - people = mom, dad, Emma, Sophie - dishwasher = people {at} {random} - {print} 'Monday the dishes are done by: ' dishwasher - {remove} dishwasher {from} people - dishwasher = people {at} {random} - {print} 'Tuesday the dishes are done by: ' dishwasher - {remove} dishwasher {from} people - dishwasher = people {at} {random} - ``` - 7: - story_text: | - With the `{repeat}` you can repeat pieces of code. You can use this to calculate who will be washing dishes for the entire week. - example_code: | - ``` - people = mom, dad, Emma, Sophie - {repeat} _ _ {print} 'the dishwasher is' _ - ``` - 10: - story_text: | - In this level you could make an even better dish washing shedule. - elif_command: - description: elif - levels: - 17: - example_code: | - ``` - prices = ['1 million dollars', 'an apple pie', 'nothing'] - your_price = prices[{random}] - {print} 'You win ' your_price - {if} your_price == '1 million dollars' : - {print} 'Yeah! You are rich!' - {elif} your_price == 'an apple pie' : - {print} 'Lovely, an apple pie!' - {else}: - {print} 'Better luck next time..' - ``` - for_command: - description: for command - levels: - 11: - story_text: |- - In this level, we add a new form of the `{for}`. In earlier levels, we used `{for}` with a list, but we can also use `{for}` with numbers. - We do that by adding a variable name, followed by `{in}` `{range}`. We then write the number to start at, `{to}` and the number to end at. - Try the example to see what happens! In this level again, you will need to use indentations in lines below the `{for}` statements. - fortune: - levels: - 1: - story_text: | - Have you ever been to a carnival and had your future predicted by a fortune teller? Or have you ever played with a magic eight ball? - Then you probably know that they can't really predict your future, but it's still fun to play! - - In the upcoming levels you can learn how to create your own fortune telling machine! - In level 1 you can start off easy by letting Hedy introduce herself as a fortune teller and let her {echo} the players' answers. - Like this: - example_code: | - ``` - {print} Hello, I'm Hedy the fortune teller! - {ask} Who are you? - {print} Let me take a look in my crystal ball - {print} I see... I see... - {echo} Your name is - ``` - story_text_2: | - ### Exercise - Hedy now only tells you your name. Can you expand the code so that Hedy can predict more things about you? - Obviously, Hedy isn't a very good fortune teller yet, as she can only repeat the answers that were given by the players! - Take a look in level 2 to improve your fortune teller. - 3: - story_text: | - In the previous levels you've created your first fortune telling machine, but Hedy couldn't really predict anything, only {echo}. - In this level you can use a variable and the `{at} {random}` command to really let Hedy choose an answer for you. Check out this code for instance: - example_code: | - In this example the player can {ask} Hedy a yes-no question and Hedy will pick a random answer for you. - ``` - {print} I’m Hedy the fortune teller! - question {is} {ask} What do you want to know? - {print} This is what you want to know: question - answers {is} yes, no, maybe - {print} My crystal ball says... - {sleep} 2 - {print} answers {at} {random} - ``` - story_text_2: | - ### Exercises - Now, Hedy can only answer yes, no or maybe. Can you give Hedy more answer options, like 'definitely' or '{ask} again'. - 4: - example_code: | - ``` - {print} 'Im Hedy the fortune teller!' - question {is} {ask} 'What do you want to know?' - {print} 'This is your question: ' question - answers {is} yes, no, maybe - {print} 'My crystal ball says...' - {sleep} 2 - {print} answers {at} {random} - ``` - 5: - story_text: | - In this level you'll learn to (secretly) tip the odds in your favor, when using the fortune teller! - By using `{if}` and `{else}` you can make sure that you will always get a good fotune, while other people might not. - Check out this example to find out how. - example_code: | - ``` - {print} 'Im Hedy the fortune teller!' - {print} 'I can predict {if} youll win the lottery tomorrow!' - person {is} {ask} 'Who are you?' - {if} person {is} Hedy {print} 'You will definitely win!🤩' {else} {print} 'Bad luck! Someone {else} will win!😭' - ``` - 6: - story_text: | - In this level you can use math in your predictions as a fortune teller. This allows you to make up (silly) formulas to calculate the future. - For example you could calculate how rich you'll get or how many kids you will have when you grow up. - example_code: | - ``` - {print} 'I am Hedy the fortune teller!' - {print} 'I can predict how many kids youll get when you grow up!' - age = {ask} 'How old are you?' - siblings = {ask} 'How many siblings do you have?' - length = {ask} 'How tall are you in centimetres?' - kids = length / age - kids = kids - siblings - {print} 'You will get ...' - {sleep} - {print} kids ' kids!' - ``` - - If the previous example wasn't silly enough for you, take a look at this one! - - ``` - {print} 'Im Hedy the silly fortune teller!' - {print} 'I will predict how smart you are!' - football = {ask} 'On a scale 1-10 how much do you love football?' - bananas = {ask} 'How many bananas did you eat this week?' - hygiene = {ask} 'How many times did you wash your hands today?' - result = bananas + hygiene - result = result * football - {print} 'You are ' result ' percent smart.' - ``` - 7: - story_text: | - In this level you can use the `{repeat}` command to make your machine tell multiple fortunes at once. - example_code: | - ``` - {print} 'Im Hedy the fortune teller!' - {print} 'You can {ask} 3 questions!' - {repeat} 3 {times} question = {ask} 'What do you want to know?' - answer = yes, no, maybe - {repeat} 3 {times} {print} 'My crystal ball says... ' answer {at} {random} - ``` - 8: - story_text: | - In the previous levels you've learned how to use repeat to make the fortune teller answer 3 questions in a row, but we had a problem with printing the questions. - Now that problem is solved, because of the new way of using the repeat command. - In the next example you can have your fortune teller {ask} 3 questions and also print them! - example_code: | - ``` - {print} 'I am Hedy the fortune teller!' - {print} 'You can {ask} me 3 questions.' - answers = yes, no, maybe - {repeat} 3 {times} - question = {ask} 'What do you want to know?' - {print} question - {sleep} - {print} 'My crystal ball says...' answers {at} {random} - ``` - 10: - story_text: | - In this level you'll learn how to program the game MASH (mansion, apartement, shack, house). In this game you can predict for all the players at once, what their future will look like. - example_code: | - ``` - houses = mansion, apartment, shack, house - loves = nobody, a royal, their neighbour, their true love - pets = dog, cat, elephant - names = Jenna, Ryan, Jim - {for} name {in} names - {print} name ' lives in a ' houses {at} {random} - {print} name ' will marry ' loves {at} {random} - {print} name ' will get a ' pets {at} {random} ' as their pet.' - {sleep} - ``` - 12: - story_text: | - In this level you can make your fortunes multiple words. Like in this example below: - example_code: | - ``` - fortunes = 'you will be rich', 'you will fall in love', 'you will slip on a banana peel' - {print} 'I will take a look in my crystall ball for your future.' - {print} 'I see... I see...' - {sleep} - {print} fortunes {at} {random} - ``` - functions: - levels: - 12: - example_code: | - ``` - sides = 'left', 'right' - limbs = 'hand', 'foot' - colors = 'red', 'blue', 'green', 'yellow' - - {define} turn - chosen_side = sides {at} {random} - chosen_limb = limbs _ - chosen_color = colors _ - {print} chosen_side ' ' chosen_limb ' on ' chosen_color - - {print} 'Lets play a game of Twister!' - {for} i {in} {range} 1 to _ - {call} turn - {sleep} 2 - ``` - 13: - story_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. - - For example in this code we've programmed the first verse of the song 'My Bonnie is over the ocean'. - In this example code the argument `place` is used. Place is a variable that is only used in the function, so an argument. - To use `place` we have programmed the line `define song with place`. - When the function is called, computer will replace the argument `place`, with the piece of text after `call song with`. - - ### Exercise - The next verse of this song goes: - - Last night as I lay on my pillow - Last night as I lay on my bed - Last night as I lay on my pillow - I dreamed that my Bonnie is dead - - Can you program this verse in the same way as the example? - 14: - example_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?' - - new_price = _ calculate_new_price {with} old_price, _ - {print} 'The new price is ' new_price ' dollar' - ``` - haunted: - levels: - 1: - story_text: | - In this adventure you are working towards making a game in which you have to escape from a haunted house by picking the correct door. - If you pick the right door you'll survive, but {if} not a terrible monster might... - - In level 1 we start our haunted house game by making up a scary story and {ask} the player what monster they'll see in the haunted house. - story_text_2: | - ### Exercise - Can you finish the scary story? Or make up your own haunted house story? - 2: - example_code: | - ``` - monster_1 {is} 👻 - monster_2 {is} 🤡 - monster_3 {is} 👶 - {print} You enter the haunted house. - {print} Suddenly you see a monster_1 - {print} You run into the other room, but a monster_2 is waiting there for you! - {print} Oh no! Quickly get to the kitchen. - {print} But as you enter monster_3 attacks you! - ``` - example_code_2: | - ``` - monster_1 {is} _ - monster_2 {is} _ - monster_3 {is} _ - {print} You enter the haunted house. - {print} Suddenly you see a monster_1 - {print} You run into the other room, but a monster_2 is waiting there for you! - {print} Oh no! Quickly get to the kitchen. - {print} But as you enter monster_3 attacks you! - ``` - 3: - story_text: | - In the previous levels you've made an introduction to your haunted house game, but as you might have noticed the story would always have a dreadful end. - In this level you can make your story more interactive by changing the outcome of the game; sometimes you'll get eaten, sometimes you'll escape! - Let Hedy decide randomly! - 4: - story_text: | - In this level you learn how to use quotation marks in your games. - Can you make your Haunted House level 4 proof? - example_code: | - ``` - {print} _Escape from the haunted house!_ - {print} _There are 3 doors in front of you..._ - choice {is} {ask} _Which door do you choose?_ - {print} _You picked door ..._ choice - monsters {is} a zombie, a vampire, NOTHING YOUVE ESCAPED - {print} _You see..._ - {sleep} - {print} monsters {at} {random} - ``` - 5: - story_text: | - Up until this level the haunted house game always asked the player to choose a door, but as you might have noticed, they didn't really have to answer correctly. - If the player filled in a completely random answer, the game would still work and the player might even win (despite not picking a door). - In this level you can only win the game by picking the same door Hedy picked randomly. - example_code: | - ``` - {print} 'Escape from the haunted house!' - {print} 'There are 3 doors in front of you...' - doors {is} 1, 2, 3 - monsters {is} werewolf, mummy, vampire, zombie - chosen_door {is} {ask} 'Which door do you choose?' - {print} 'You chose door...' chosen_door - {sleep} - correct_door {is} doors {at} {random} - {if} chosen_door {is} correct_door {print} 'Great! Youve escaped!' - {else} {print} 'Oh no! You are being eaten by a...' monsters {at} {random} - ``` - 9: - story_text: | - In this level you can use nesting, which allows you to make the haunted house even more interactive! - - ### Exercise - Now it's very hard to win this game, can you make it easier to win? - For example by only having 1 wrong door and 2 correct doors instead of 1 correct door and 2 wrong ones? - 11: - story_text: | - In this level we've changed the repeat command and we've added a line to our haunted house that tells the player in which room they are. - example_code: | - ``` - {print} 'Escape from the Haunted House!' - player {is} alive - doors = 1, 2, 3 - monsters = zombie, vampire, giant spider - {for} i {in} {range} 1 {to} 3 - {if} player {is} alive - correct_door = doors {at} {random} - {print} 'Room ' i - {print} 'There are 3 doors in front of you...' - chosendoor = {ask} 'Which door do you choose?' - {if} chosendoor {is} correct_door - {print} 'No monsters here!' - {else} - {print} 'You are eaten by a ' monsters {at} {random} - player = dead - {else} - {print} 'GAME OVER' - {if} player {is} alive - {print} 'Great! You survived!' - ``` - if_command: - description: Introducing the if command - levels: - 9: - story_text: | - In this level you can also put an {if} command inside another {if} command. - in_command: - description: Introducing the in command - levels: - 5: - example_code_2: | - ``` - animals is dog, cow, sheep - answer is ask 'What is your favorite animal?' - _ answer _ animals _ 'Mine too!' - _ _ 'My favorite animals are dogs, cows and sheep' - ``` - is_command: - description: introducing is command - levels: - 2: - story_text_2: | - ### Exercise - Time to make your own variables! - In the example code we made an example of the variable `favorite_animal`. In line 1 the variable is set, and in line 2 we haved used the variable in a print command. - Firstly, finish our example by filling in your favorite animal on the blank. Then make at least 3 of these codes yourself. Pick a variable, and set the variable with the {is} command. Then use it with a {print} command, just like we did. - 14: - example_code: | - ``` - age = {ask} 'How old are you?' - {if} age > 12 - {print} 'You are older than I am!' - ``` - example_code_3: | - ``` - name = {ask} 'What is your name?' - {if} name != 'Hedy' - {print} 'You are not Hedy' - ``` - - {if} age < 13 - {print} 'You are younger than me!' - {else} - {print} 'You are older than me!' - language: - levels: - 5: - story_text: | - Make your own program to practice your vocabulary in a new language. - maths: - levels: - 6: - example_code: | - ``` - {print} '5 plus 5 is ' 5 + 5 - {print} '5 minus 5 is ' 5 - 5 - {print} '5 times 5 is ' 5 * 5 - ``` - 12: - example_code_2: | - ``` - a = 'Hello ' - b = 'world!' - {print} a + b - ``` - - {print} 2.5 + 2.5 - music: - levels: - 6: - story_text: "Instead of playing notes, you can also play numbers now. Simply type `{play} 1` for the lowest note, `{play} 70` for the highest note, or anything in between.\n\n### Exercise\n This calls for musical maths! Try out the example code a couple of times with different starting numbers. \nThen, see if you can compose a song using the numbers.\n" - parrot: - levels: - 1: - story_text_2: | - ### Exercise - Can you make the parrot ask a different question? Fill in the blanks in the example! - 2: - story_text: | - Create your own online pet parrot that will copy you! - example_code: "```\n{print} Mina olen papagoi Hedy \nnimi {is} {ask} Mis su nimi on?\n{print} nimi\n{sleep}\n{print} kraaks\n{sleep}\n{print} nimi\n```\n" - story_text_2: | - ### Exercise - You can use variables to make the parrot say more than only your name. Can you complete this code? - 3: - story_text: | - Teach your parrot a new word with `{add}`. - example_code: | - ``` - words {is} squawk, Hedy - {print} Train your parrot! - new_word {is} {ask} Which word do you want to teach them? - {add} new_word {to_list} words - {print} 🧒 Say new_word , Hedy! - {print} 🦜 words {at} {random} - ``` - 4: - story_text: | - In this level we have to use quotation marks with the commands `{ask}` and `{print}`. - Can you complete the code by adding quotation marks? - 5: - story_text: | - Premeeri oma papagoid, {if} ta ütleb õige sõna! - example_code: | - ``` - words {is} squawk, Hedy - {print} 'Train your parrot!' - new_word {is} {ask} 'Which word do you want to teach them?' - {add} new_word {to_list} words - said_word {is} words {at} {random} - {print} '🧒 Say ' new_word ', Hedy!' - {print} '🦜 ' said_word - {if} said_word {is} new_word {print} '🧒 Great job, Hedy! 🍪' - {else} {print} '🧒 No, Hedy! Say ' new_word - ``` - piggybank: - levels: - 12: - story_text: | - In this adventure you learn how to make a digital piggy bank, to calculate how much money you have and how long you need to save up to buy what you want! - example_code: | - ``` - {print} 'The digital piggy bank' - wish = {ask} 'What would you like to buy?' - price = {ask} 'How much does that cost?' - saved = {ask} 'How much money have you saved already?' - allowance = {ask} 'How much pocket money do you get per week?' - to_save = price - saved - weeks = to_save / allowance - {print} 'You can buy a ' wish ' in ' weeks ' weeks.' - ``` - 14: - example_code: | - ``` - _ calculate_budget with wish, money, allowance - to_save = wish - money - weeks = to_save / allowance - {if} wish _ money - {print} 'You need to save up some more!' - {print} 'Youll need ' weeks ' more weeks.' - {else} - {print} 'Great! You have enough' - {print} 'Lets go shopping!' - - money = {ask} 'How much money have you saved?' - wish = {ask} 'How much money do you need?' - allowance = {ask} 'How much pocket money do you get each week?' - - {call} calculate_budget with _, _, _ - ``` - pressit: - levels: - 9: - story_text: | - Now that you know how to combine statements, you can create a touch type tool with `{pressed}`. - - ### Exercise - Finish the code. Each time a random letter should be chosen, which you have to press. You get a point for a correct press, and and two points deduction for a wrong press. - **(extra)** Clear the screen after each letter, and show the user how many points they have scored. - print_command: - levels: - 18: - example_code_2: | - ``` - temperature = 25 - {print}('It is ', temperature, ' degrees outside') - ``` - - {print}('My name is ', name) - random_command: - levels: - 16: - story_text: |- - We are going to make lists the Python way, with square brackets around the lists! We also keep the quotation marks around each item like we have learned in previous levels. - We use square brackets to point out a place in a list. For example: `friends[1]` is the first name on the list of friends, as you can see in the first part of the example code. The second part of the example code shows you that we can also match 2 lists using the variable i. - repeat_command: - description: repeat command - levels: - 7: - story_text: | - ## Repeat! Repeat! Repeat! - Level 7 adds the `{repeat}` command. `{repeat}` can be used to execute one line of code multiple times. Like this: - - ### Exercise - Play around with the repeat command. Can you make the happy birthday song in only 3 lines of code instead of 4 now? - 9: - story_text: | - Great job! You've reached another new level! In the previous level you've learned to use multiple lines of code in an {if} or {repeat} command. But you can't yet combine the two... - Good news! In this level you will be allowed to put an {if} inside an {if}, or inside a {repeat} command. Putting a block of code inside another block of code is called nesting. ``` Putting a block of code inside another block of code is called nesting. - example_code: | - ``` - answer = {ask} 'Are you ready to learn something new?' - {if} answer {is} yes - {print} 'Great! You can learn to use the repeat command in the if command!' - {print} 'Hooray!' - {print} 'Hooray!' - {print} 'Hooray!' - {else} - {print} 'Maybe you should practice some more in the previous level' - repeat_command_2: - description: repeat command 2 - levels: - 7: - story_text_2: | - Another interesting thing you can so with the `{repeat}` command is using variables to set the amount of times something should be repeated. In the example code you can see that we first ask the person how old they are. - Then, in line 3, the question is repeated 'age' times. So we have used the variable 'age' with the `{repeat}` command. - restaurant: - levels: - 1: - story_text_2: | - ### Exercise - Can you think of more lines to add to your restaurant code? For example, can you {ask} the guests what they'd like to drink, tell them the price, or wish them a pleasant meal? - 2: - story_text: | - In level 2 you could expand your restaurant by using variables. In level 1 Hedy could only {echo} the order once and only remember the last thing that was ordered. - Now you can use variables and Hedy can remember both the food and the drinks! - example_code: | - ``` - {print} Welcome to Hedy's restaurant! - {print} Today we're serving pizza or lasagna. - food {is} {ask} What would you like to eat? - {print} Great choice! The food is my favorite! - topping {is} {ask} Would you like meat or veggies on that? - {print} food with topping is on its way! - drinks {is} {ask} What would you like to drink with that? - {print} Thank you for your order. - {print} Your food and drinks will be right there! - ``` - story_text_2: | - ### Exercise - Can you make this code more elaborate? For example by adding drinks to the order? Or...? - 3: - example_code: | - ``` - {print} Welcome to Hedy's Random Restaurant! - {print} The only restaurant that will randomly choose your meal and its price for you! - starters {is} salad, soup, carpaccio - mains {is} pizza, brussels sprouts, spaghetti - desserts {is} brownies, ice cream, french cheeses - drinks {is} cola, beer, water - prices {is} 1 dollar, 10 dollars, 100 dollars - {print} You will start with: starters {at} {random} - {print} Then we'll serve: mains {at} {random} - {print} And as dessert: desserts {at} {random} - {print} You will get a drinks {at} {random} to drink - {print} That will be: prices {at} {random} - {print} Thank you and enjoy your meal! - ``` - story_text_2: | - Does your costumer have any allergies or do they dislike certain dishes? Then you can use the `{remove}`command to remove it from your menu. - example_code_2: | - ``` - {print} Mystery milkshake - flavors {is} strawberry, chocolate, vanilla - allergies {is} {ask} Are you allergic to any falvors? - {remove} allergies {from} flavors - {print} You get a flavors {at} {random} milkshake - ``` - 4: - story_text: | - ### Exercise - Add the quotation marks to this code to make it work! Be careful: variables should not be in quotation marks. - Then, use the `{clear}` command to only show one line at a time in your output screen. - - ### Exercise 2 - Go back to the previous level and copy your restaurant code. Make the code work in this level by adding quotation marks in the right spots and add some `{clear}` commands. - 5: - story_text: | - In this level the {if} command allows you to {ask} your customers questions and give different responses to the answers. - In the example below, you see that you can {ask} the customer {if} they want to hear the specials and Hedy can respond accordingly. - example_code: | - ``` - {print} 'Welcome to Hedys restaurant!' - special {is} {ask} 'Would you like to hear our specials today?' - {if} special {is} yes {print} 'Todays special is chicken piri piri and rice.' {else} {print} 'No problem.' - food {is} {ask} 'What would you like to eat?' - {print} 'One ' food ', coming right up!' - drink {is} {ask} 'What would you like to drink with that?' - {if} drink {is} cola {print} 'Im sorry, we are out of cola!' {else} {print} 'Great choice!' - anything {is} {ask} 'Would you like anything {else}?' - {print} 'Let me repeat your order...' - {print} 'One ' food - {if} drink {is} cola {print} 'and...' {else} {print} 'One ' drink - {if} anything {is} no {print} 'Thats it!' {else} {print} 'One ' anything - {print} 'Thank you for your order and enjoy your meal!' - ``` - 6: - story_text: | - In this level you can use maths to calculate the total price of your customer's order, which can make your virtual restaurant more realistic. - example_code: | - You can make a simple restaurant code, like this: - ``` - {print} 'Welcome to Hedys restaurant' - {print} 'Here is our menu:' - {print} 'Our main courses are pizza, lasagne, or spaghetti' - main = {ask} 'Which main course would you like?' - price = 0 - {if} main {is} pizza price = 10 - {if} main {is} lasagne price = 12 - {if} main {is} spaghetti price = 8 - {print} 'You have ordered ' main - {print} 'That will be ' price ' dollars, please' - {print} 'Thank you, enjoy your meal!' - ``` - 7: - story_text: | - In this level you've learned how to use the {repeat} command to repeat a line of code a certain amount of times. - You can use that in your restaurant to {ask} multiple people what they'd like to eat. Like this: - example_code: | - ``` - {print} 'Welcome to Hedys restaurant!' - people = {ask} 'How many people are joining us today?' - {repeat} people times food = {ask} 'What would you like to eat?' - {print} 'Thanks for your order! Its coming right up!' - ``` - 9: - story_text: | - In this level you can use nesting to make your restaurant more realistic and more fun! - For example you would {ask} for sauce {if} somebody orders fries, but you wouldn't {if} someone orders pizza! - Check out the example, and try this at your own virtual restaurant! - example_code: | - ``` - {print} 'Welcome to Hedys restaurant!' - people = {ask} 'How many people will be joining us today?' - {print} 'Great!' - price = 0 - {repeat} people {times} - food = {ask} 'What would you like to order?' - {print} food - {if} food {is} fries - price = price + 3 - sauce = {ask} 'What kind of sauce would you like with your fries?' - {if} sauce {is} no - {print} 'no sauce' - {else} - price = price + 1 - {print} 'with ' sauce - {if} food {is} pizza - price = price + 4 - {print} 'That will be ' price ' dollar' - {print} 'Enjoy your meal!' - ``` - 10: - story_text: | - In this level you'll learn how to easily {ask} your guests' orders in a short code. - example_code: | - ``` - courses = appetizer, main course, dessert - {for} course {in} courses - food = {ask} 'What would you like to eat as your ' course '?' - {print} food ' will be your ' course - ``` - story_text_2: | - Of course, you could also order for multiple people! - example_code_2: | - ``` - courses = appetizer, main course, dessert - names = Timon, Onno - {for} name {in} names - {for} course {in} courses - food = {ask} name ', what would you like to eat as your ' course '?' - {print} name ' orders ' food ' as their ' course - ``` - 11: - story_text: | - We can use the `{for} i {in} {range} 1 {to} 5` to {print} the orders from multiple customers in an orderly manner. - example_code: | - ``` - {print} 'Welcome to Restaurant Hedy!' - people = {ask} 'For how many people would you like to order?' - {for} i {in} {range} 1 {to} people - {print} 'Order number ' i - food = {ask} 'What would you like to eat?' - {print} food - {if} food {is} fries - sauce = {ask} 'What kind of sauce would you like with that?' - {print} sauce - drinks = {ask} 'What would you like to drink?' - {print} drinks - price = 4 * people - {print} 'That will be ' price ' dollars, please!' - ``` - 12: - story_text: | - From this level on you can use decimal numbers to make you menu more realistic. - example_code: | - ``` - price = 0 - food = {ask} 'What would you like to order?' - drink = {ask} 'What would you like to drink?' - {if} food {is} 'hamburger' - price = price + 6.50 - {if} food {is} 'pizza' - price = price + 5.75 - {if} drink {is} 'water' - price = price + 1.20 - {if} drink {is} 'soda' - price = price + 2.35 - {print} 'That will be ' price ' dollar, please' - ``` - 13: - story_text: | - In this level we can use the new commands to upgrade our restaurant. - We use `{and}` to see {if} two things are both the case. - example_code: | - ``` - price = 10 - food = {ask} 'What would you like to eat?' - drinks = {ask} 'What would you like to drink?' - {if} food {is} 'sandwich' {and} drinks {is} 'juice' - {print} 'Thats our discount menu' - price = price - 3 - {print} 'That will be ' price ' dollars' - ``` - rock: - default_save_name: Rock - levels: - 2: - story_text: | - In this level you can practise using the variables, so that you can make the rock, paper, scissors game in the next level! - example_code: | - ``` - choice {is} _ - {print} I choose choice - ``` - 3: - story_text_2: | - ### Exercise - Now you only have one player, so can you add a second player? - You can even use variables to name player 1 and player 2. - example_code_2: | - ``` - choices {is} rock, paper, scissors - {print} player 1 chooses... choices {at} {random} - {print} player 2 _ - ``` - 5: - story_text: | - In this level we can determine who won. - For that you need the new `{if}` code. - - Save your choice with the name of choice and the choice of computer as computer choice. - Then you can use `{if}` to see {if} they are the same or different. - Will you finish the code? - example_code: | - ``` - options {is} rock, paper, scissors - computer_choice {is} _ - choice {is} {ask} 'What do you choose?' - {print} 'you chose ' _ - {print} 'computer chose ' _ - {if} _ {is} _ {print} 'tie!' {else} {print} 'no tie' - ``` - - Fill in the correct code on the blanks to see {if} it is a draw. - 9: - story_text: | - In this level you can program the whole rock, paper, scissors game by nesting the {if}-commands. Can you finish the code? - example_code: | - ``` - choices = rock, paper, scissors - your_choice = {ask} 'What do you choose?' - {print} 'You choose ' your_choice - computer_choice = choices {at} {random} - {print} 'The computer chooses ' computer_choice - {if} computer_choice {is} your_choice - {print} 'Tie' - {if} computer_choice {is} rock - {if} your_choice {is} paper - {print} 'You win!' - {if} your_choice {is} scissors - {print} 'You lose!' - # finish this code - ``` - 10: - story_text: | - Feeling too lazy to play the game yourself? Let Hedy play it for you! - example_code: | - ``` - choices = rock, paper, scissors - players = Marleen, Michael - {for} player {in} players - {print} player ' chooses ' choices {at} {random} - ``` - 13: - story_text: | - With the `{and}` command you can shorten your rock, paper, scissors code! Check out the example code below and try to finish it. - example_code: | - ``` - options = 'rock', 'paper', 'scissors' - your_choice = {ask} 'What do you choose?' - computer_choice = options {at} {random} - {print} 'You choose ' your_choice - {print} 'The computer chooses ' computer_choice - {if} computer_choice {is} your_choice - {print} 'Tie' - {if} computer_choice {is} 'rock' {and} your_choice {is} 'paper' - {print} 'You win!' - {if} computer_choice {is} 'rock' {and} your_choice {is} 'scissors' - {print} 'The computer wins!' - ``` - 15: - example_code: | - ``` - won = 'no' - options = 'rock', 'paper', 'scissors' - {while} won == 'no' - your_choice = {ask} 'What do you choose?' - computer_choice = options {at} {random} - {print} 'you chose ' your_choice - {print} 'the computer chose ' computer_choice - {if} computer_choice == your_choice - {print} 'Tie!' - {if} computer_choice == 'rock' {and} your_choice == 'scissors' - {print} 'You lose!' - {if} computer_choice == 'rock' {and} your_choice == 'paper' - {print} 'You win!' - won = 'yes' - ``` - rock_2: - levels: - 2: - story_text: | - Now that you have learned how to use the `{ask} command, you can make your rock, paper, scissors code interavtive too! - - ### Exercise - Make the rock, paper, scissors code interactive by adding the `{ask}` command and a question to your rock, paper, scissors code. - example_code: | - ``` - choice is _ - {print} I choose choice - ``` - secret: - levels: - 12: - story_text: | - In this adventure you can create your own super spy code. Encode a message that only the right agent can decipher. - If the enemy tries to crack the code, they will get some false info to waste their time. - example_code: | - ``` - name {is} {ask} 'What is your name?' - {if} name {is} '_' - a {is} 'Go to the airport ' - {else} - a {is} 'Go to the trainstation ' - password {is} {ask} 'What is the password?' - {if} password {is} _ - b {is} 'tomorrow at 02.00' - {else} - b {is} 'today at 10.00' - {print} _ _ _ - ``` - 13: - story_text: | - The code you made in the previous level can be made a lot easier in this one with the `{and}` command. - sleep_command: - description: introducing sleep command - levels: - 2: - story_text: | - ## The sleep command - Another new command in this level is `{sleep}`, which pauses your program for a second. If you type a number behind the {sleep} command, the program pauses for that amount of seconds. - songs: - levels: - 6: - story_text: | - Songs often contain a lot of repetition. Sometimes the repetition is also based on counting. - For example, in the well-known song 'Bottles of beer'. You can program that song with a little math. - example_code: | - ``` - verse = 99 - {print} verse ' bottles of beer on the wall' - {print} verse ' bottles of beer' - {print} 'Take one down, pass it around' - verse = verse - 1 - {print} verse ' bottles of beer on the wall' - ``` - - You can now repeat lines 2 to 9 as many times as you want by copying the lines. - example_code_2: | - ``` - number = 6 - number = number - 1 - print number ' little monkeys jumping on the bed' - print 'One fell off and bumped his head' - print 'Mama called the doctor and the doctor said' - print 'NO MORE MONKEYS JUMPING ON THE BED!' - sleep - ``` - 7: - story_text: | - Songs often contain a lot of repetition. For example... Baby Shark! If you sing it, you keep singing the same thing: - - Baby Shark tututudutudu
- Baby Shark tututudutudu
- Baby Shark tututudutudu
- Baby Shark - - You can make this song much shorter with a `{repeat}`! Can you finish the code? - example_code: | - ``` - {repeat} _ _ {print} 'Baby Shark tututudutudu' - {print} 'Baby Shark' - ``` - - After Baby Shark you can of course also program other songs. There are many songs with repetition. - 8: - story_text: | - In a previous level you've programmed the song 'Bottles of beer'. You made one verse and then had to copy the verses 99 times. In level 7 you can repeat the song 99 times, just by adding one simple line! - example_code: | - ``` - verse = 99 - {repeat} 99 {times} - {print} verse ' bottles of beer on the wall' - {print} verse ' bottles of beer' - {print} 'Take one down, pass it around' - verse = verse - 1 - {print} verse ' bottles of beer on the wall' - ``` - 10: - story_text: | - In this level you can easily make the childrens' song 'Five little monkeys'. Can you make the last chorus? - You can also make the whole baby shark song (including all the other sharks in the family) in only 6 lines! - Or you can make Old MacDonald with all the different animals. - example_code: | - ``` - monkeys = 5, 4, 3, 2 - {for} monkey {in} monkeys - {print} monkey ' little monkeys jumping on the bed' - {print} 'One fell off and bumped his head' - {print} 'Mama called the doctor and the doctor said' - {print} 'NO MORE MONKEYS JUMPING ON THE BED!' - ``` - - ``` - sharks = baby, mommy, daddy, grandma, grandpa - {for} shark {in} sharks - {print} shark 'tututututudu' - {print} shark 'tututututudu' - {print} shark 'tututututudu' - {print} shark - ``` - ``` - animals = pig, dog, cow - {for} animal {in} animals - {if} animal {is} pig - sound = oink - {if} animal {is} dog - sound = woof - {if} animal {is} cow - sound = moo - {print} 'Old MacDonald had a farm' - {print} 'E I E I O!' - {print} 'and on that farm he had a ' animal - {print} 'E I E I O!' - {print} 'with a ' sound sound ' here' - {print} 'and a ' sound sound ' there' - {print} 'here a ' sound - {print} 'there a ' sound - {print} 'everywhere a ' sound sound - ``` - story_text_2: | - ### Exercise 2 - Print the song Five little moneys jumping on the bed. Look up the text if you don't remember. - - **(extra)** Print the song Old MacDonald had a farm, and make sure all animals make a different sound, using an `{if}`. - 11: - story_text: | - In this level you can use the `{for} i {in} {range}` command to make songs that use counting. - example_code: | - ``` - {for} i {in} {range} 5 {to} 1 - {print} i ' little monkeys jumping on the bed' - {print} 'One fell off and bumped his head' - {print} 'Mama called the doctor and the doctor said' - {if} i {is} 1 - {print} 'PUT THOSE MONKEYS RIGHT TO BED!' - {else} - {print} 'NO MORE MONKEYS JUMPING ON THE BED!' - ``` - songs_2: - levels: - 12: - example_code: | - ``` - {define} twinkle - {print} 'Twinkle' - {print} '...' - - {call} twinkle - {print} 'Up above the world so high' - {print} 'Like a diamond in the sky' - {call} _ - ``` - turtle: - levels: - 1: - story_text: | - You can also use Hedy to draw. By combining turns and lines, you can make a square or stairs! - - Using `{forward}` you draw a line forwards. The number behind it determines how far the turtle will walk. `{turn} {right}` turns a quarter turn in clockwise direction, `{turn} {left}` turns counter clockwise. - If you want to go backwards, you use the `{forward}` command but with a negative number. So for example `{forward} -100` - 3: - story_text: | - In this level you can use use `{at} {random}` with the drawing turtle. A random choice makes the turtle walk a different path each time. - Use `{at} {random}` to choose a value from a list. You can copy and paste lines 2 and 3 to create a longer random path. - example_code: | - ``` - nurgad {is} 10, 50, 90, 150, 250 - {turn} nurgad {at} {random} - {forward} 25 - ``` - 4: - example_code: | - ``` - {print} 'Drawing figures' - angle {is} 90 - {turn} angle - {forward} 25 - {turn} angle - {forward} 25 - ``` - 5: - example_code_2: | - ``` - direction {is} {ask} 'Do you want to go left, right, or straight ahead?' - if direction is left turn _ - if direction is right turn _ - forward 100 - ``` - 8: - story_text: | - Now that we can repeat several lines, we can make figures more easily. - We only have to set the angle once and then use that variable in the `{repeat}`. - example_code: | - ``` - angle = 90 - {repeat} 10 {times} - {turn} angle - {forward} 50 - ``` - story_text_2: | - Also, we can now improve the program that draws different figures. - Can you figure out how far the turtle has to turn here? Finish the code and you can draw any polygon you'd like! - 9: - story_text: | - Now that we can use a `{repeat}` inside a `{repeat}`, we can create more complex figures. - - ### Exercise 1 - This code creates three black triangles, change that into five pink squares. - - **(extra)** Create a figure of your own choosing consisting of at least two different shapes types. - 10: - story_text: | - In this level you can make the turtle draw a figure. - The turtle will travel the distances in the list, one by one, making bigger and bigger steps. - ### Exercise 1 - Add a 90 degree turn in the loop, so that a spiral is drawn. - Add at least 5 numbers to the list, so the spiral grows larger. - **(extra)** can you change the spiral into another shape? Experiment with numbers for the turn! - ### Exercise 2 - The spiral is drawn outwards, make it go inwards? - turtle_draw_it: - levels: - 9: - example_code: | - Hint for the nested squares: - ``` - colors = red, blue, orange, yellow, pink, purple, green, brown, black - distance = 120 - repeat 5 times - _ - ``` - Hint for the flags: - ``` - country = ask 'which country would you like to see the flag of?' - if country is 'the Netherlands' - color_1 = red - color_2 = white - color_3 = blue - ``` - 10: - example_code: | - Hint Nested Hexagon: - ``` - distances = 100, 80, 60, 40, 20 - {for} distance {in} distances - _ - ``` - - Hint Traffic Lights: - ``` - colors = red, yellow, green - {for} chosen_color {in} colors - color _ - {repeat} _ - ``` - 12: - story_text: | - ### Exercise - Recreate the drawings with the turtle! - Hint: Bracelet designing program. Firstly, define a function **for each shape** you want to use on the bacelet. Then, add the shapes to the bacelet like this: - - Bracelet Designing program - example_code: | - ``` - {define} draw_a_square - _ - - {color} white - {turn} -90 - {forward} 300 - {turn} 180 - - {for} i {in} {range} 1 {to} 5 - {color} gray - {forward} 100 - shape = {ask} 'What kind of shape would you like next on the bracelet?' - chosen_color = {ask} 'In which color?' - {color} chosen_color - {if} shape = 'square' - {call} draw_a_square - ``` - while_command: - description: while - years: - description: Countdown to the new year! - levels: - 11: - story_text: | - In this level you can use the `{for} i {in} {range}` command to countdown to the New Year. - - ### Exercise - Fill in the blanks and make the code work! - example_code: | - ``` - for _ in _ 10 to 1 - {print} i - {print} 'Happy New Year!' - ``` diff --git a/content/adventures/fa.yaml b/content/adventures/fa.yaml index 1a44f4a5398..01bb9ea3e07 100644 --- a/content/adventures/fa.yaml +++ b/content/adventures/fa.yaml @@ -1,569 +1,4 @@ adventures: - 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 in your 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. - story_text_2: | - ### Exercise - Can you make your own story in Hedy now by using `{print}` , `{ask}` and `{echo}`? - 2: - 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: - example_code_2: | - ``` - {print} He hears a sound - animals {is} 🐿, 🦔, 🦇, 🦉 - animal {is} {ask} What do you think it is? - {add} animal {to_list} animals - {print} it was a animals {at} {random} - ``` - story_text_3: | - This is an example of the `{remove}` command in your story - 5: - story_text: | - In this level you can program different endings, which will make your story even more fun. - - 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 'encounter 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}`. - 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! - 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. - 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' - ``` - add_remove_command: - name: '{add} {to} & {remove} {from}' - 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. - 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. - and_or_command: - description: introducing and or - ask_command: - description: Introduction ask command - levels: - 1: - 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. - calculator: - levels: - 6: - story_text: | - Now that you can calculate, you can also create a program to practice maths calculations. You can make up the calculations yourself, for example: - example_code: | - ``` - correct_answer = 11 * 27 - answer = {ask} 'How much is 11 times 27?' - {if} answer {is} correct_answer {print} 'good job!' - {else} {print} 'Wrong! It was ' correct_answer - ``` - story_text_2: | - You can also let the computer do random calculations on its own using {random}. - example_code_2: | - ``` - tables = 4, 5, 6, 8 - numbers = 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 - table = tables {at} {random} - number = numbers {at} {random} - correct_answer = table * number - answer = {ask} 'how much is ' table ' times ' number '?' - {if} answer {is} correct_answer {print} 'okay' - {else} {print} 'mistake! it was ' correct_answer - ``` - 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`. - 11: - example_code: | - ``` - number = 10 - {for} i {in} {range} 1 to 10 - {print} i * number - ``` - 12: - story_text: | - Now you can make a calculator that works for decimal numbers. - example_code: | - ``` - number1 = {ask} 'What is the first number?' - number2 = {ask} 'What is the second number?' - answer = number1 + number2 - {print} number1 ' plus ' number2 ' is ' answer - ``` - 14: - 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 - clear_command: - description: clear command - debugging: - levels: - 3: - 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} - ``` - 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! - 8: - 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: - 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!' - {else} - 'I'm sorry we don't sell that' - topping {is} {ask} 'What kind of topping would you like?' - sauce {is} {ask} 'What kind of sauce would you like?' - {print} One chosen_bread with topping and sauce. - price = amount * 6 - {print} 'That will be 'price dollar' please' - ``` - - price = amount * 6 - {print} 'That will be 'price dollar' please' - 10: - example_code: | - **Warning! This code needs to be debugged!** - ``` - names = Muad Hasan Samira Noura - activities = fly a kite, go swimming, go hiking, catch tan in the sun - {for} name {is} names - {print} At the beach name loves to activity at random - ``` - 11: - story_text: |- - ### Exercise - Debug this calender program. The output of this program is supposed to look like a list of dates. - For example: - - ``` - Hedy calender - Here are all the days of November - November 1 - November 2 - November 3 - ``` - And so on. - - Mind that you have to test your code extra carefully for the month February, because the amount of days in this month changes in leap years. - example_code: | - **Warning! This code needs to be debugged!** - ``` - print 'Hedy calender' - months_with_31 days = January, March, May, July, September, October, December - months_with_30_days = April, June, August, November - month = ask 'Which month would you like to see?' - if month in months_with_31_days - days = 31 - if month in months_with30_days - days = 30 - if month = February - leap_years = 2020, 2024, 2028, 2036, 2040, 2044, 2028 - year = ask 'What year is it?' - if year in leap_years - days = 29 - else - days = 28 - - print 'Here are all the days of ' moth - for i in range 1 to days - print month i - ``` - 12: - example_code: | - **Warning! This code needs to be debugged!** - ``` - define greet - greetings = 'Hello', 'Hi there', 'Goodevening' - print greetings at random - - define take_order - food = ask 'What would you like to eat?' - print 'One food' - drink = 'What would you like to drink?' - print 'One ' drink - more = ask 'Would you like anything else?' - if more is 'no' - print 'Alright' - else - print 'And ' more - print 'Thank you' - - print 'Welcome to our restaurant' - people = ask 'How many people are in your party tonight?' - for i in range 0 to people - call greet_costumer - ``` - 13: - example_code: | - **Warning! This code needs to be debugged!** - ``` - defin movie_recommendation with name - action_movies == 'Die Hard', 'Fast and Furious', 'Inglorious Bastards' - romance_movies = 'Love Actually', 'The Notebook', 'Titanic' - comedy_movies = 'Mr Bean' 'Barbie''Deadpool' - kids_movies = 'Minions', 'Paddington', 'Encanto' - if name is 'Camila' or name is 'Manuel' - recommended_movie = kids_movie at random - if name is 'Pedro' or 'Gabriella' - mood = ask 'What you in the mood for?' - if mood is 'action' - recommended_movie = comedy_movies at random - if mood is 'romance' - recommended_movie = romance_movies - if mood is 'comedy' - recommended_movie = comedy_movies at random - - print 'I would recommend ' recommended_movie ' for ' name - - name = ask 'Who is watching?' - recommendation = ask 'Would you like a recommendation?' - if recommendaion is 'yes' - print movie_recommendation with name - else - print 'No problem!' - ``` - 14: - example_code: | - **Warning! This code needs to be debugged!** - ``` - define calculate_heartbeat - print 'Press your fingertips gently against the side of your neck' - print '(just under your jawline)' - print 'Count the number of beats you feel for 15 seconds' - beats == ask 'How many beats do you feel in 15 seconds?' - heartbeat = beats*4 - print 'Your heartbeat is ' heartbeat - if heartbeat >= 60 or heartbeat <= 100 - print 'Your heartbeat seems fine' - else - if heartbeat > 60 - print 'Your heartbeat seems to be too low' - if heartbeat < 100 - print 'Your heartbeat seems to be too high' - print 'You might want to contact a medical professional' - - measure_heartbeat = ask 'Would you like to measure your heartbeat?' - if measure_heartbeat = 'yes' - call measure_heartbeat - else - 'no problem' - ``` - - print '(just under your jawline)' - print 'Count the number of beats you feel for 15 seconds' - beats == ask 'How many beats do you feel in 15 seconds?' - heartbeat = beats*4 - print 'Your heartbeat is ' heartbeat - if heartbeat >= 60 or heartbeat <= 100 - print 'Your heartbeat seems fine' - else - if heartbeat > 60 - print 'Your heartbeat seems to be too low' - if heartbeat < 100 - print 'Your heartbeat seems to be too high' - print 'You might want to contact a medical professional' - - measure_heartbeat = ask 'Would you like to measure your heartbeat?' - if measure_heartbeat = 'yes' - call measure_heartbeat - else - 'no problem' - 15: - example_code: | - **Warning! This code needs to be debugged!** - ``` - names = 'Tanya', 'Romy', 'Kayla', 'Aldrin', 'Ali' - verbs='walking', 'skipping', 'cycling', 'driving', 'running' - locations = 'on a mountaintop', 'in the supermarket', 'to the swimming pool' - hiding_spots = 'behind a tree', under a table', in a box' - sounds = 'a trumpet', 'a car crash', 'thunder' - causes_of_noise = 'a television', 'a kid with firecrackers', 'a magic elephant', 'a dream' - - chosen_ name = names at random - chosen_verb = verbs at random - chosen_location = 'locations at random' - chosen_sounds = noises at random - chosen_spot = hiding_spots random - chosen_causes = causes_of_noise at random - - print chosen_name ' was ' chosen_verb ' ' chosen_location - print 'when they suddenly heard a sound like ' sounds at random - print chosen_name ' looked around, but they couldn't discover where the noise came from' - print chosen_name ' hid ' chosen_spot' - print 'They tried to look around, but couldn't see anything from there' - hidden = 'yes' - while hidden = 'yes' - print chosen_name 'still didn't see anything' - answer = ask 'does ' chosen_name ' move from their hiding spot?' - if answer = 'yes' - hidden == 'no' - print 'chosen_name moved from' chosen_spot - print 'And then they saw it was just' chosen_cause - print chosen_name 'laughed and went on with their day' - print The End - ``` - 16: - example_code: | - **Warning! This code needs to be debugged!** - ``` - country = ['The Netherlands', 'Poland', 'Turkey', 'Zimbabwe', 'Thailand', 'Brasil', 'Peru', 'Australia', 'India', 'Romania' ] - capitals = 'Amsterdam', 'Warshaw' 'Istanbul', 'Harare', 'Bangkok', 'Brasilia', 'Lima', 'Canberra', 'New Delhi', 'Bucharest' - score = 0 - for i in range 0 to 10 - answer = ask 'What's the capital of ' countries[i] - correct = capital[i] - if answer = correct - print 'Correct!' - score = score + 1 - else - print 'Wrong,' capitals[i] 'in the capital of' countries[i] - print 'You scored ' score ' out of 10' - - ``` - 17: - example_code: | - **Warning! This code needs to be debugged!** - ``` - define food_order - toppings = ask 'pepperoni, tuna, veggie or cheese?' - size = ask 'big, medium or small?' - number_of_pizza = ask 'How many these pizzas would you like?' - - print 'YOU ORDERED' - print number_of_pizzas ' size ' topping ' pizza' - - define drinks_order - drink = ask 'water, coke, icetea, lemonade or coffee?' - number_of_drinks = ask 'How many of these drinks would you like?' - - print 'YOU ORDERED' - print number_of_drinks ' ' drink - - 'Welcome to Hedy pizza' - more_food = ask 'Would you like to order a pizza?' - while more_food = 'yes' - return food_order - more_food = ask 'Would you like to order a pizza?' - more_drinks = ask 'Would you like to order some drinks?' - while more_drinks == 'yes' - call drink_order - more_drinks == ask 'Would you like to order more drinks?' - - - print 'Thanks for ordering!' - ``` - 18: - example_code: | - **Warning! This code needs to be debugged!** - ``` - animals = ['pig', 'dog', 'cow'] - sounds = ['oink', 'woof', 'moo'] - for i in range 1 to 3 - animal = animals[i] - sound = sounds[i] - print 'Old MacDonald had a farm' - print 'E I E I O!' - print 'and on that farm he had a ' animal - print 'E I E I O!' - print 'with a ' sound sound ' here' - print 'and a ' sound sound ' there' - print 'here a ' sound - print 'there a ' sound - print 'everywhere a ' sound sound - ``` default: name: مقدمه default_save_name: مقدمه @@ -579,1504 +14,3 @@ adventures: 3: story_text: | در سطح 3 شما میتوانید یک لیست بسازید. . می توانید اجازه بدهید که کامپیوتر برای شما یک لیست بسازد شما این کا را با`{at} {random}`انجام می دهید. - 4: - story_text: | - In level 4 `{ask}` and `{print}` have changed. - - You must put text that you want to print between quotation marks. - - This is useful, because now you can print all the words you want. Also the words you used to store something with `{is}`. - - Most programming languages also use quotation marks when printing, so we are also getting a step closer to real programming! - example_code: | - ``` - print 'You need to use quotation marks from now on!' - answer is ask 'What do we need to use from now on?' - print 'We need to use ' answer - ``` - 5: - story_text: | - In level 5 there is something new, the `{if}`! With the `{if}` you can choose between two different options. - This code prints nice if you enter Hedy as a name, and boo! if you enter something else. - `{ask}` {and} `{print}` still work like they did in level 4. - example_code: | - ``` - name {is} {ask} 'what is your name?' - {if} name {is} Hedy {print} 'nice' {else} {print} 'boo!' - ``` - 6: - story_text: | - In the previous level you have practiced with `{ask}` and `{if}`. For example you can ask guests what they would like to eat. - What you can't yet do though, is calculate the price for everyone's dinner. - - In the previous level you have practiced with `{ask}` and `{if}`. For example you can ask guests what they would like to eat. - What you can't yet do though, is calculate the price for everyone's dinner. - - This level makes it possible to use addition, subtraction and multiplication in your programs. This way you can calculate the prices in your restaurant, but you could also add a secret code to give your friends and family a discount. - Another option in this level is programming your own maths game, for your little brother or sister to practice their multiplications. - Go see for yourself! - example_code: | - ``` - {print} '5 plus 5 is ' 5 + 5 - {print} '5 minus 5 is ' 5 - 5 - {print} '5 {times} 5 is ' 5 * 5 - ``` - 7: - story_text: | - Level 7 adds the `{repeat}` command. {repeat} can be used to execute one line of code multiple times. - example_code: | - ``` - {repeat} 3 {times} {print} 'Hedy is fun!' - ``` - 8: - story_text: | - `{ask}` {and} `{print}` still work as you know them. But `{if}` {and} `{repeat}` have changed! - You can now execute groups of code together, but you will have to *indent* the code. - That means putting four spaces at the beginning of the line. You will also have to indent when you just want to create a block of one line. - example_code: | - ``` - {repeat} 5 {times} - {print} 'Hello everyone' - {print} 'This is all repeated 5 times' - ``` - 10: - story_text: | - In this level we learn a new code called `{for}`. With `{for}` you can make a list and use all elements. - `{for}` creates a block, like `{repeat}` and `{if}` so all lines in the block need to start with spaces. - example_code: | - ``` - animals {is} dog, cat, blobfish - {for} animal {in} animals - {print} 'I love ' animal - ``` - 12: - story_text: | - **Decimal numbers** - So far, Hedy did not allow for decimal numbers like 1.5, but now we do allow that. Note that computers use the `.` for decimal numbers. - example_code: | - ``` - {print} 'Two and a half plus two and a half is...' - {print} 2.5 + 2.5 - ``` - - {print} 2.5 + 2.5 - 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!' - ``` - 14: - story_text: | - We are going to learn more new items. You might know them already from mathematics, the `<` and `>`. - The `<` checks if the first number is smaller than the second, for example `age < 12` checks if `age` {is} smaller than 12. - If you want to check if the first number is smaller or equal to the second, you can use `<=`, for example `age <= 11`. - The `>` checks if the first number is bigger than the second, for example `points > 10` checks if `points` is larger than 10. - If you want to check if the first number is bigger or equal to the second, you can use `>=`, for example `points >= 11`. - You use these comparisons in an `{if}`, like this: - example_code: | - ``` - age = {ask} 'How old are you?' - {if} age > 12 - {print} 'You are older than I am!' - ``` - - {if} age < 13 - {print} 'You are younger than me!' - else - {print} 'You are older than me!' - 15: - story_text: | - We are going to learn a new loop, the `{while}` loop! We continue the loop as long as the statement is true. - So don't forget to change the value in the loop. - - In the example code, we continue until a correct answer has been given. - If the correct answer is never given, the loop never ends! - example_code: | - ``` - answer = 0 - while answer != 25 - answer = ask 'What is 5 times 5?' - print 'A correct answer has been given' - ``` - 16: - story_text: | - We are going to make lists the Python way, with square brackets around the lists! We also keep the quotation marks around each item like we have learned in previous levels. - You can use the square brackets as well to point out a place in the lists. - example_code: | - ``` - friends = ['Ahmed', 'Ben', 'Cayden'] - {print} friends[1] ' is the first friend on the list.' - {print} friends[2] ' is the second friend on the list.' - {print} friends[3] ' is the third friend on the list.' - #now we will match 2 lists using the variable i - lucky_numbers = [15, 18, 6] - {for} i {in} {range} 1 {to} 3 - {print} friends[i] 's lucky number is ' lucky_numbers[i] - ``` - 17: - story_text: |- - Now we are going to change indentation a little bit. Every time that we need an indentation, we need `:` at the line before the indentation. - - In this level you can also use a new command: `{elif}`. `{elif}` is short for `{else} {if}` and you need it when you you want to make 3 (or more!) options. - Check it out! - 18: - story_text: |- - We arrived at real Python code! That means we need to use parentheses with {print} and {range} from now on. - That looks like this: - ``` - {print}('my name is Hedy!') - ``` - If you want to print more thant one items, you need to separate them by commas. - ``` - naam = 'Hedy' - {print}('my name is ', naam) - ``` - - {print}('My name is ', naam) - dice: - levels: - 3: - example_code: | - ``` - choices {is} 1, 2, 3, 4, 5, earthworm - {print} choices {at} {random} - ``` - 4: - story_text: | - In this level we can make sentences with the die value in the sentence, with quotes of course. - This time the sample code is not quite complete. Can you finish the code? - 5: - story_text: | - You can also make a die again in this level using the `{if}`. - Complete the sample code so that the code says "You can stop throwing" once you have thrown an earthworm. - - But maybe you want to recreate a die from a completely different game. That's fine too! Then make up your own reaction. Eg 'yes' for 6 and 'pity' for something {else}. - example_code: | - ``` - choices {is} 1, 2, 3, 4, 5, earthworm - throw {is} _ - {print} 'you have' _ 'thrown' - {if} _ {is} earthworm {print} 'You can stop throwing.' _ {print} 'You have to hear it again!' - ``` - 6: - story_text: | - You can also make an Earthworm die again in this, but now you can also calculate how many points have been rolled. - You may know that the worm counts 5 points for Earthworms. Now after a roll you can immediately calculate how many points you have thrown. - This is the code to calculate points for one die: - example_code: | - ``` - choices = 1, 2, 3, 4, 5, earthworm - points = 0 - throw = choices {at} {random} - {print} 'you threw' throw - {if} throw {is} earthworm points = points + 5 {else} points = points + throw - {print} 'those are' points ' point' - ``` - Can you make the code so that you get the total score for 8 dice? To do that, you have to cut and paste some lines of the code. - example_code_2: | - Did you manage to calculate the score for 8 dice? That required a lot of cutting and pasting, right? We are going to make that easier in level 7! - 7: - story_text: | - You can also make a die again in level 5. With the `{repeat}` code you can easily roll a whole hand of dice. - Try to finish the sample code! The dashes should contain multiple commands and characters. - - But maybe you want to make a completely different die. Of course you can! - example_code: | - ``` - choices = 1, 2, 3, 4, 5, earthworm - {repeat} _ _ {print} _ _ _ - ``` - 10: - story_text: | - Is everybody taking too long throwing the dice? In this level you can let Hedy throw all the dice at once! - example_code: | - ``` - players = Ann, John, Jesse - choices = 1, 2, 3, 4, 5, 6 - {for} player {in} players - {print} player ' throws ' choices {at} {random} - {sleep} - ``` - dishes: - description: Use the computer to see who does the dishes (Start at level 2) - levels: - 3: - story_text: | - Do you always disagree at home about who should wash the dishes or change the litter box today? - Then you can let the computer choose very fairly. You can program that in this level! - You first make a list of the members of your family. Then choose '{at} {random}' from the list. - example_code: | - ``` - people {is} mom, dad, Emma, Sophie - {print} people {at} {random} - ``` - story_text_2: | - Don't feel like doing the dishes yourself? Hack the program to remove your name from the list. - 4: - story_text: | - With quotation marks you can make your dishwashing planning more beautiful. - This time the sample code is not quite complete. - - Can you complete the code by filling the blanks? Every blank must be replaced with one word of symbol. - - Tip: Don't forget the quotation marks! - 5: - story_text: | - With the `{if}` you can now have more fun with choice in the program. You can have your program respond to the choice that the computer has made. - - Can you finish the code so that it prints 'too bad' when it is your turn and otherwise 'yes!'? - Don't forget the quotes! - example_code: | - ``` - people {is} mom, dad, Emma, Sophie - dishwasher {is} people {at} {random} - {if} dishwasher {is} Sophie {print} _ too bad I have to do the dishes _ {else} {print} 'luckily no dishes because' _ 'is already washing up' - ``` - 6: - story_text_2: | - If you are extremely unlucky the previous program might choose you to to the dishes for the whole week! That's not fair! - To create a fairer system you can use the `{remove}` command to remove the chosen person from the list. This way you don't have to do the dishes again untill everybody has had a turn. - - Monday and tuesday are ready for you! Can you add the rest of the week? - And... can you come up with a solution for when your list is empty? - example_code_2: | - ``` - people = mom, dad, Emma, Sophie - dishwasher = people {at} {random} - {print} 'Monday the dishes are done by: ' dishwasher - {remove} dishwasher {from} people - dishwasher = people {at} {random} - {print} 'Tuesday the dishes are done by: ' dishwasher - {remove} dishwasher {from} people - dishwasher = people {at} {random} - ``` - 7: - story_text: | - With the `{repeat}` you can repeat pieces of code. You can use this to calculate who will be washing dishes for the entire week. - example_code: | - ``` - people = mom, dad, Emma, Sophie - {repeat} _ _ {print} 'the dishwasher is' _ - ``` - 10: - story_text: | - In this level you could make an even better dish washing shedule. - elif_command: - description: elif - levels: - 17: - example_code: | - ``` - prices = ['1 million dollars', 'an apple pie', 'nothing'] - your_price = prices[{random}] - {print} 'You win ' your_price - {if} your_price == '1 million dollars' : - {print} 'Yeah! You are rich!' - {elif} your_price == 'an apple pie' : - {print} 'Lovely, an apple pie!' - {else}: - {print} 'Better luck next time..' - ``` - for_command: - description: for command - levels: - 11: - story_text: |- - In this level, we add a new form of the `{for}`. In earlier levels, we used `{for}` with a list, but we can also use `{for}` with numbers. - We do that by adding a variable name, followed by `{in}` `{range}`. We then write the number to start at, `{to}` and the number to end at. - Try the example to see what happens! In this level again, you will need to use indentations in lines below the `{for}` statements. - fortune: - levels: - 1: - story_text: | - Have you ever been to a carnival and had your future predicted by a fortune teller? Or have you ever played with a magic eight ball? - Then you probably know that they can't really predict your future, but it's still fun to play! - - In the upcoming levels you can learn how to create your own fortune telling machine! - In level 1 you can start off easy by letting Hedy introduce herself as a fortune teller and let her {echo} the players' answers. - Like this: - example_code: | - ``` - {print} Hello, I'm Hedy the fortune teller! - {ask} Who are you? - {print} Let me take a look in my crystal ball - {print} I see... I see... - {echo} Your name is - ``` - story_text_2: | - ### Exercise - Hedy now only tells you your name. Can you expand the code so that Hedy can predict more things about you? - Obviously, Hedy isn't a very good fortune teller yet, as she can only repeat the answers that were given by the players! - Take a look in level 2 to improve your fortune teller. - 3: - story_text: | - In the previous levels you've created your first fortune telling machine, but Hedy couldn't really predict anything, only {echo}. - In this level you can use a variable and the `{at} {random}` command to really let Hedy choose an answer for you. Check out this code for instance: - example_code: | - In this example the player can {ask} Hedy a yes-no question and Hedy will pick a random answer for you. - ``` - {print} I’m Hedy the fortune teller! - question {is} {ask} What do you want to know? - {print} This is what you want to know: question - answers {is} yes, no, maybe - {print} My crystal ball says... - {sleep} 2 - {print} answers {at} {random} - ``` - story_text_2: | - ### Exercises - Now, Hedy can only answer yes, no or maybe. Can you give Hedy more answer options, like 'definitely' or '{ask} again'. - 4: - example_code: | - ``` - {print} 'Im Hedy the fortune teller!' - question {is} {ask} 'What do you want to know?' - {print} 'This is your question: ' question - answers {is} yes, no, maybe - {print} 'My crystal ball says...' - {sleep} 2 - {print} answers {at} {random} - ``` - 5: - story_text: | - In this level you'll learn to (secretly) tip the odds in your favor, when using the fortune teller! - By using `{if}` and `{else}` you can make sure that you will always get a good fotune, while other people might not. - Check out this example to find out how. - example_code: | - ``` - {print} 'Im Hedy the fortune teller!' - {print} 'I can predict {if} youll win the lottery tomorrow!' - person {is} {ask} 'Who are you?' - {if} person {is} Hedy {print} 'You will definitely win!🤩' {else} {print} 'Bad luck! Someone {else} will win!😭' - ``` - 6: - story_text: | - In this level you can use math in your predictions as a fortune teller. This allows you to make up (silly) formulas to calculate the future. - For example you could calculate how rich you'll get or how many kids you will have when you grow up. - example_code: | - ``` - {print} 'I am Hedy the fortune teller!' - {print} 'I can predict how many kids youll get when you grow up!' - age = {ask} 'How old are you?' - siblings = {ask} 'How many siblings do you have?' - length = {ask} 'How tall are you in centimetres?' - kids = length / age - kids = kids - siblings - {print} 'You will get ...' - {sleep} - {print} kids ' kids!' - ``` - - If the previous example wasn't silly enough for you, take a look at this one! - - ``` - {print} 'Im Hedy the silly fortune teller!' - {print} 'I will predict how smart you are!' - football = {ask} 'On a scale 1-10 how much do you love football?' - bananas = {ask} 'How many bananas did you eat this week?' - hygiene = {ask} 'How many times did you wash your hands today?' - result = bananas + hygiene - result = result * football - {print} 'You are ' result ' percent smart.' - ``` - 7: - story_text: | - In this level you can use the `{repeat}` command to make your machine tell multiple fortunes at once. - example_code: | - ``` - {print} 'Im Hedy the fortune teller!' - {print} 'You can {ask} 3 questions!' - {repeat} 3 {times} question = {ask} 'What do you want to know?' - answer = yes, no, maybe - {repeat} 3 {times} {print} 'My crystal ball says... ' answer {at} {random} - ``` - 8: - story_text: | - In the previous levels you've learned how to use repeat to make the fortune teller answer 3 questions in a row, but we had a problem with printing the questions. - Now that problem is solved, because of the new way of using the repeat command. - In the next example you can have your fortune teller {ask} 3 questions and also print them! - example_code: | - ``` - {print} 'I am Hedy the fortune teller!' - {print} 'You can {ask} me 3 questions.' - answers = yes, no, maybe - {repeat} 3 {times} - question = {ask} 'What do you want to know?' - {print} question - {sleep} - {print} 'My crystal ball says...' answers {at} {random} - ``` - 10: - story_text: | - In this level you'll learn how to program the game MASH (mansion, apartement, shack, house). In this game you can predict for all the players at once, what their future will look like. - example_code: | - ``` - houses = mansion, apartment, shack, house - loves = nobody, a royal, their neighbour, their true love - pets = dog, cat, elephant - names = Jenna, Ryan, Jim - {for} name {in} names - {print} name ' lives in a ' houses {at} {random} - {print} name ' will marry ' loves {at} {random} - {print} name ' will get a ' pets {at} {random} ' as their pet.' - {sleep} - ``` - 12: - story_text: | - In this level you can make your fortunes multiple words. Like in this example below: - example_code: | - ``` - fortunes = 'you will be rich', 'you will fall in love', 'you will slip on a banana peel' - {print} 'I will take a look in my crystall ball for your future.' - {print} 'I see... I see...' - {sleep} - {print} fortunes {at} {random} - ``` - functions: - levels: - 12: - example_code: | - ``` - sides = 'left', 'right' - limbs = 'hand', 'foot' - colors = 'red', 'blue', 'green', 'yellow' - - {define} turn - chosen_side = sides {at} {random} - chosen_limb = limbs _ - chosen_color = colors _ - {print} chosen_side ' ' chosen_limb ' on ' chosen_color - - {print} 'Lets play a game of Twister!' - {for} i {in} {range} 1 to _ - {call} turn - {sleep} 2 - ``` - 13: - story_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. - - For example in this code we've programmed the first verse of the song 'My Bonnie is over the ocean'. - In this example code the argument `place` is used. Place is a variable that is only used in the function, so an argument. - To use `place` we have programmed the line `define song with place`. - When the function is called, computer will replace the argument `place`, with the piece of text after `call song with`. - - ### Exercise - The next verse of this song goes: - - Last night as I lay on my pillow - Last night as I lay on my bed - Last night as I lay on my pillow - I dreamed that my Bonnie is dead - - Can you program this verse in the same way as the example? - 14: - example_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?' - - new_price = _ calculate_new_price {with} old_price, _ - {print} 'The new price is ' new_price ' dollar' - ``` - haunted: - description: escape from the haunted house - levels: - 1: - story_text: | - In this adventure you are working towards making a game in which you have to escape from a haunted house by picking the correct door. - If you pick the right door you'll survive, but {if} not a terrible monster might... - - In level 1 we start our haunted house game by making up a scary story and {ask} the player what monster they'll see in the haunted house. - story_text_2: | - ### Exercise - Can you finish the scary story? Or make up your own haunted house story? - 2: - example_code: | - ``` - monster_1 {is} 👻 - monster_2 {is} 🤡 - monster_3 {is} 👶 - {print} You enter the haunted house. - {print} Suddenly you see a monster_1 - {print} You run into the other room, but a monster_2 is waiting there for you! - {print} Oh no! Quickly get to the kitchen. - {print} But as you enter monster_3 attacks you! - ``` - example_code_2: | - ``` - monster_1 {is} _ - monster_2 {is} _ - monster_3 {is} _ - {print} You enter the haunted house. - {print} Suddenly you see a monster_1 - {print} You run into the other room, but a monster_2 is waiting there for you! - {print} Oh no! Quickly get to the kitchen. - {print} But as you enter monster_3 attacks you! - ``` - 3: - story_text: | - In the previous levels you've made an introduction to your haunted house game, but as you might have noticed the story would always have a dreadful end. - In this level you can make your story more interactive by changing the outcome of the game; sometimes you'll get eaten, sometimes you'll escape! - Let Hedy decide randomly! - 4: - story_text: | - In this level you learn how to use quotation marks in your games. - Can you make your Haunted House level 4 proof? - example_code: | - ``` - {print} _Escape from the haunted house!_ - {print} _There are 3 doors in front of you..._ - choice {is} {ask} _Which door do you choose?_ - {print} _You picked door ..._ choice - monsters {is} a zombie, a vampire, NOTHING YOUVE ESCAPED - {print} _You see..._ - {sleep} - {print} monsters {at} {random} - ``` - 5: - story_text: | - Up until this level the haunted house game always asked the player to choose a door, but as you might have noticed, they didn't really have to answer correctly. - If the player filled in a completely random answer, the game would still work and the player might even win (despite not picking a door). - In this level you can only win the game by picking the same door Hedy picked randomly. - example_code: | - ``` - {print} 'Escape from the haunted house!' - {print} 'There are 3 doors in front of you...' - doors {is} 1, 2, 3 - monsters {is} werewolf, mummy, vampire, zombie - chosen_door {is} {ask} 'Which door do you choose?' - {print} 'You chose door...' chosen_door - {sleep} - correct_door {is} doors {at} {random} - {if} chosen_door {is} correct_door {print} 'Great! Youve escaped!' - {else} {print} 'Oh no! You are being eaten by a...' monsters {at} {random} - ``` - 9: - story_text: | - In this level you can use nesting, which allows you to make the haunted house even more interactive! - - ### Exercise - Now it's very hard to win this game, can you make it easier to win? - For example by only having 1 wrong door and 2 correct doors instead of 1 correct door en 2 wrong ones? - 11: - story_text: | - In this level we've changed the repeat command and we've added a line to our haunted house that tells the player in which room they are. - example_code: | - ``` - {print} 'Escape from the Haunted House!' - player {is} alive - doors = 1, 2, 3 - monsters = zombie, vampire, giant spider - {for} i {in} {range} 1 {to} 3 - {if} player {is} alive - correct_door = doors {at} {random} - {print} 'Room ' i - {print} 'There are 3 doors in front of you...' - chosendoor = {ask} 'Which door do you choose?' - {if} chosendoor {is} correct_door - {print} 'No monsters here!' - {else} - {print} 'You are eaten by a ' monsters {at} {random} - player = dead - {else} - {print} 'GAME OVER' - {if} player {is} alive - {print} 'Great! You survived!' - ``` - if_command: - description: Introducing the if command - levels: - 9: - story_text: | - In this level you can also put an {if} command inside another {if} command. - in_command: - description: Introducing the in command - levels: - 5: - example_code_2: | - ``` - animals is dog, cow, sheep - answer is ask 'What is your favorite animal?' - _ answer _ animals _ 'Mine too!' - _ _ 'My favorite animals are dogs, cows and sheep' - ``` - is_command: - description: introducing is command - levels: - 2: - story_text_2: | - ### Exercise - Time to make your own variables! - In the example code we made an example of the variable `favorite_animal`. In line 1 the variable is set, and in line 2 we haved used the variable in a print command. - Firstly, finish our example by filling in your favorite animal on the blank. Then make at least 3 of these codes yourself. Pick a variable, and set the variable with the {is} command. Then use it with a {print} command, just like we did. - 14: - example_code: | - ``` - age = {ask} 'How old are you?' - {if} age > 12 - {print} 'You are older than I am!' - ``` - example_code_3: | - ``` - name = {ask} 'What is your name?' - {if} name != 'Hedy' - {print} 'You are not Hedy' - ``` - - {if} age < 13 - {print} 'You are younger than me!' - {else} - {print} 'You are older than me!' - language: - default_save_name: language - levels: - 5: - story_text: | - Make your own program to practice your vocabulary in a new language. - maths: - levels: - 6: - example_code: | - ``` - {print} '5 plus 5 is ' 5 + 5 - {print} '5 minus 5 is ' 5 - 5 - {print} '5 times 5 is ' 5 * 5 - ``` - 12: - example_code_2: | - ``` - a = 'Hello ' - b = 'world!' - {print} a + b - ``` - - {print} 2.5 + 2.5 - music: - levels: - 6: - story_text: "Instead of playing notes, you can also play numbers now. Simply type `{play} 1` for the lowest note, `{play} 70` for the highest note, or anything in between.\n\n### Exercise\n This calls for musical maths! Try out the example code a couple of times with different starting numbers. \nThen, see if you can compose a song using the numbers.\n" - parrot: - levels: - 1: - story_text_2: | - ### Exercise - Can you make the parrot ask a different question? Fill in the blanks in the example! - 2: - story_text: | - Create your own online pet parrot that will copy you! - example_code: | - ``` - {print} Im Hedy the parrot - name {is} {ask} whats your name? - {print} name - {sleep} - {print} squawk - {sleep} - {print} name - ``` - story_text_2: | - ### Exercise - You can use variables to make the parrot say more than only your name. Can you complete this code? - 3: - story_text: | - Teach your parrot a new word with `{add}`. - example_code: | - ``` - words {is} squawk, Hedy - {print} Train your parrot! - new_word {is} {ask} Which word do you want to teach them? - {add} new_word {to_list} words - {print} 🧒 Say new_word , Hedy! - {print} 🦜 words {at} {random} - ``` - 4: - story_text: | - In this level we have to use quotation marks with the commands `{ask}` and `{print}`. - Can you complete the code by adding quotation marks? - 5: - story_text: | - Reward your parrot {if} it says the correct word! - example_code: | - ``` - words {is} squawk, Hedy - {print} 'Train your parrot!' - new_word {is} {ask} 'Which word do you want to teach them?' - {add} new_word {to_list} words - said_word {is} words {at} {random} - {print} '🧒 Say ' new_word ', Hedy!' - {print} '🦜 ' said_word - {if} said_word {is} new_word {print} '🧒 Great job, Hedy! 🍪' - {else} {print} '🧒 No, Hedy! Say ' new_word - ``` - piggybank: - levels: - 12: - story_text: | - In this adventure you learn how to make a digital piggy bank, to calculate how much money you have and how long you need to save up to buy what you want! - example_code: | - ``` - {print} 'The digital piggy bank' - wish = {ask} 'What would you like to buy?' - price = {ask} 'How much does that cost?' - saved = {ask} 'How much money have you saved already?' - allowance = {ask} 'How much pocket money do you get per week?' - to_save = price - saved - weeks = to_save / allowance - {print} 'You can buy a ' wish ' in ' weeks ' weeks.' - ``` - 14: - example_code: | - ``` - _ calculate_budget with wish, money, allowance - to_save = wish - money - weeks = to_save / allowance - {if} wish _ money - {print} 'You need to save up some more!' - {print} 'Youll need ' weeks ' more weeks.' - {else} - {print} 'Great! You have enough' - {print} 'Lets go shopping!' - - money = {ask} 'How much money have you saved?' - wish = {ask} 'How much money do you need?' - allowance = {ask} 'How much pocket money do you get each week?' - - {call} calculate_budget with _, _, _ - ``` - pressit: - levels: - 9: - story_text: | - Now that you know how to combine statements, you can create a touch type tool with `{pressed}`. - - ### Exercise - Finish the code. Each time a random letter should be chosen, which you have to press. You get a point for a correct press, and and two points deduction for a wrong press. - **(extra)** Clear the screen after each letter, and show the user how many points they have scored. - print_command: - levels: - 18: - example_code_2: | - ``` - temperature = 25 - {print}('It is ', temperature, ' degrees outside') - ``` - - {print}('My name is ', name) - random_command: - levels: - 16: - story_text: |- - We are going to make lists the Python way, with square brackets around the lists! We also keep the quotation marks around each item like we have learned in previous levels. - We use square brackets to point out a place in a list. For example: `friends[1]` is the first name on the list of friends, as you can see in the first part of the example code. The second part of the example code shows you that we can also match 2 lists using the variable i. - repeat_command: - description: repeat command - levels: - 7: - story_text: | - ## Repeat! Repeat! Repeat! - Level 7 adds the `{repeat}` command. `{repeat}` can be used to execute one line of code multiple times. Like this: - - ### Exercise - Play around with the repeat command. Can you make the happy birthday song in only 3 lines of code instead of 4 now? - 9: - story_text: | - Great job! You've reached another new level! In the previous level you've learned to use multiple lines of code in an {if} or {repeat} command. But you can't yet combine the two... - Good news! In this level you will be allowed to put an {if} inside an {if}, or inside a {repeat} command. Putting a block of code inside another block of code is called nesting. ``` Putting a block of code inside another block of code is called nesting. - example_code: | - ``` - answer = {ask} 'Are you ready to learn something new?' - {if} answer {is} yes - {print} 'Great! You can learn to use the repeat command in the if command!' - {print} 'Hooray!' - {print} 'Hooray!' - {print} 'Hooray!' - {else} - {print} 'Maybe you should practice some more in the previous level' - repeat_command_2: - description: repeat command 2 - levels: - 7: - story_text_2: | - Another interesting thing you can so with the `{repeat}` command is using variables to set the amount of times something should be repeated. In the example code you can see that we first ask the person how old they are. - Then, in line 3, the question is repeated 'age' times. So we have used the variable 'age' with the `{repeat}` command. - restaurant: - levels: - 1: - story_text_2: | - ### Exercise - Can you think of more lines to add to your restaurant code? For example, can you {ask} the guests what they'd like to drink, tell them the price, or wish them a pleasant meal? - 2: - story_text: | - In level 2 you could expand your restaurant by using variables. In level 1 Hedy could only {echo} the order once and only remember the last thing that was ordered. - Now you can use variables and Hedy can remember both the food and the drinks! - example_code: | - ``` - {print} Welcome to Hedy's restaurant! - {print} Today we're serving pizza or lasagna. - food {is} {ask} What would you like to eat? - {print} Great choice! The food is my favorite! - topping {is} {ask} Would you like meat or veggies on that? - {print} food with topping is on its way! - drinks {is} {ask} What would you like to drink with that? - {print} Thank you for your order. - {print} Your food and drinks will be right there! - ``` - story_text_2: | - ### Exercise - Can you make this code more elaborate? For example by adding drinks to the order? Or...? - 3: - example_code: | - ``` - {print} Welcome to Hedy's Random Restaurant! - {print} The only restaurant that will randomly choose your meal and its price for you! - starters {is} salad, soup, carpaccio - mains {is} pizza, brussels sprouts, spaghetti - desserts {is} brownies, ice cream, french cheeses - drinks {is} cola, beer, water - prices {is} 1 dollar, 10 dollars, 100 dollars - {print} You will start with: starters {at} {random} - {print} Then we'll serve: mains {at} {random} - {print} And as dessert: desserts {at} {random} - {print} You will get a drinks {at} {random} to drink - {print} That will be: prices {at} {random} - {print} Thank you and enjoy your meal! - ``` - story_text_2: | - Does your costumer have any allergies or do they dislike certain dishes? Then you can use the `{remove}`command to remove it from your menu. - example_code_2: | - ``` - {print} Mystery milkshake - flavors {is} strawberry, chocolate, vanilla - allergies {is} {ask} Are you allergic to any falvors? - {remove} allergies {from} flavors - {print} You get a flavors {at} {random} milkshake - ``` - 4: - story_text: | - ### Exercise - Add the quotation marks to this code to make it work! Be careful: variables should not be in quotation marks. - Then, use the `{clear}` command to only show one line at a time in your output screen. - - ### Exercise 2 - Go back to the previous level and copy your restaurant code. Make the code work in this level by adding quotation marks in the right spots and add some `{clear}` commands. - 5: - story_text: | - In this level the {if} command allows you to {ask} your customers questions and give different responses to the answers. - In the example below, you see that you can {ask} the customer {if} they want to hear the specials and Hedy can respond accordingly. - example_code: | - ``` - {print} 'Welcome to Hedys restaurant!' - special {is} {ask} 'Would you like to hear our specials today?' - {if} special {is} yes {print} 'Todays special is chicken piri piri and rice.' {else} {print} 'No problem.' - food {is} {ask} 'What would you like to eat?' - {print} 'One ' food ', coming right up!' - drink {is} {ask} 'What would you like to drink with that?' - {if} drink {is} cola {print} 'Im sorry, we are out of cola!' {else} {print} 'Great choice!' - anything {is} {ask} 'Would you like anything {else}?' - {print} 'Let me repeat your order...' - {print} 'One ' food - {if} drink {is} cola {print} 'and...' {else} {print} 'One ' drink - {if} anything {is} no {print} 'Thats it!' {else} {print} 'One ' anything - {print} 'Thank you for your order and enjoy your meal!' - ``` - 6: - story_text: | - In this level you can use maths to calculate the total price of your customer's order, which can make your virtual restaurant more realistic. - example_code: | - You can make a simple restaurant code, like this: - ``` - {print} 'Welcome to Hedys restaurant' - {print} 'Here is our menu:' - {print} 'Our main courses are pizza, lasagne, or spaghetti' - main = {ask} 'Which main course would you like?' - price = 0 - {if} main {is} pizza price = 10 - {if} main {is} lasagne price = 12 - {if} main {is} spaghetti price = 8 - {print} 'You have ordered ' main - {print} 'That will be ' price ' dollars, please' - {print} 'Thank you, enjoy your meal!' - ``` - 7: - story_text: | - In this level you've learned how to use the {repeat} command to repeat a line of code a certain amount of times. - You can use that in your restaurant to {ask} multiple people what they'd like to eat. Like this: - example_code: | - ``` - {print} 'Welcome to Hedys restaurant!' - people = {ask} 'How many people are joining us today?' - {repeat} people times food = {ask} 'What would you like to eat?' - {print} 'Thanks for your order! Its coming right up!' - ``` - 9: - story_text: | - In this level you can use nesting to make your restaurant more realistic and more fun! - For example you would {ask} for sauce {if} somebody orders fries, but you wouldn't {if} someone orders pizza! - Check out the example, and try this at your own virtual restaurant! - example_code: | - ``` - {print} 'Welcome to Hedys restaurant!' - people = {ask} 'How many people will be joining us today?' - {print} 'Great!' - price = 0 - {repeat} people {times} - food = {ask} 'What would you like to order?' - {print} food - {if} food {is} fries - price = price + 3 - sauce = {ask} 'What kind of sauce would you like with your fries?' - {if} sauce {is} no - {print} 'no sauce' - {else} - price = price + 1 - {print} 'with ' sauce - {if} food {is} pizza - price = price + 4 - {print} 'That will be ' price ' dollar' - {print} 'Enjoy your meal!' - ``` - 10: - story_text: | - In this level you'll learn how to easily {ask} your guests' orders in a short code. - example_code: | - ``` - courses = appetizer, main course, dessert - {for} course {in} courses - food = {ask} 'What would you like to eat as your ' course '?' - {print} food ' will be your ' course - ``` - story_text_2: | - Of course, you could also order for multiple people! - example_code_2: | - ``` - courses = appetizer, main course, dessert - names = Timon, Onno - {for} name {in} names - {for} course {in} courses - food = {ask} name ', what would you like to eat as your ' course '?' - {print} name ' orders ' food ' as their ' course - ``` - 11: - story_text: | - We can use the `{for} i {in} {range} 1 {to} 5` to {print} the orders from multiple customers in an orderly manner. - example_code: | - ``` - {print} 'Welcome to Restaurant Hedy!' - people = {ask} 'For how many people would you like to order?' - {for} i {in} {range} 1 {to} people - {print} 'Order number ' i - food = {ask} 'What would you like to eat?' - {print} food - {if} food {is} fries - sauce = {ask} 'What kind of sauce would you like with that?' - {print} sauce - drinks = {ask} 'What would you like to drink?' - {print} drinks - price = 4 * people - {print} 'That will be ' price ' dollars, please!' - ``` - 12: - story_text: | - From this level on you can use decimal numbers to make you menu more realistic. - example_code: | - ``` - price = 0 - food = {ask} 'What would you like to order?' - drink = {ask} 'What would you like to drink?' - {if} food {is} 'hamburger' - price = price + 6.50 - {if} food {is} 'pizza' - price = price + 5.75 - {if} drink {is} 'water' - price = price + 1.20 - {if} drink {is} 'soda' - price = price + 2.35 - {print} 'That will be ' price ' dollar, please' - ``` - 13: - story_text: | - In this level we can use the new commands to upgrade our restaurant. - We use `{and}` to see {if} two things are both the case. - example_code: | - ``` - price = 10 - food = {ask} 'What would you like to eat?' - drinks = {ask} 'What would you like to drink?' - {if} food {is} 'sandwich' {and} drinks {is} 'juice' - {print} 'Thats our discount menu' - price = price - 3 - {print} 'That will be ' price ' dollars' - ``` - rock: - default_save_name: Rock - levels: - 2: - story_text: | - In this level you can practise using the variables, so that you can make the rock, paper, scissors game in the next level! - example_code: | - ``` - choice {is} _ - {print} I choose choice - ``` - 3: - story_text_2: | - ### Exercise - Now you only have one player, so can you add a second player? - You can even use variables to name player 1 and player 2. - example_code_2: | - ``` - choices {is} rock, paper, scissors - {print} player 1 chooses... choices {at} {random} - {print} player 2 _ - ``` - 5: - story_text: | - In this level we can determine who won. - For that you need the new `{if}` code. - - Save your choice with the name of choice and the choice of computer as computer choice. - Then you can use `{if}` to see {if} they are the same or different. - Will you finish the code? - example_code: | - ``` - options {is} rock, paper, scissors - computer_choice {is} _ - choice {is} {ask} 'What do you choose?' - {print} 'you chose ' _ - {print} 'computer chose ' _ - {if} _ {is} _ {print} 'tie!' {else} {print} 'no tie' - ``` - - Fill in the correct code on the blanks to see {if} it is a draw. - 9: - story_text: | - In this level you can program the whole rock, paper, scissors game by nesting the {if}-commands. Can you finish the code? - example_code: | - ``` - choices = rock, paper, scissors - your_choice = {ask} 'What do you choose?' - {print} 'You choose ' your_choice - computer_choice = choices {at} {random} - {print} 'The computer chooses ' computer_choice - {if} computer_choice {is} your_choice - {print} 'Tie' - {if} computer_choice {is} rock - {if} your_choice {is} paper - {print} 'You win!' - {if} your_choice {is} scissors - {print} 'You lose!' - ``` - 10: - story_text: | - Feeling too lazy to play the game yourself? Let Hedy play it for you! - example_code: | - ``` - choices = rock, paper, scissors - players = Marleen, Michael - {for} player {in} players - {print} player ' chooses ' choices {at} {random} - ``` - 13: - story_text: | - With the `{and}` command you can shorten your rock, paper, scissors code! Check out the example code below and try to finish it. - example_code: | - ``` - options = 'rock', 'paper', 'scissors' - your_choice = {ask} 'What do you choose?' - computer_choice = options {at} {random} - {print} 'You choose ' your_choice - {print} 'The computer chooses ' computer_choice - {if} computer_choice {is} your_choice - {print} 'Tie' - {if} computer_choice {is} 'rock' {and} your_choice {is} 'paper' - {print} 'You win!' - {if} computer_choice {is} 'rock' {and} your_choice {is} 'scissors' - {print} 'The computer wins!' - ``` - 15: - example_code: | - ``` - won = 'no' - options = 'rock', 'paper', 'scissors' - {while} won == 'no' - your_choice = {ask} 'What do you choose?' - computer_choice = options {at} {random} - {print} 'you chose ' your_choice - {print} 'the computer chose ' computer_choice - {if} computer_choice == your_choice - {print} 'Tie!' - {if} computer_choice == 'rock' {and} your_choice == 'scissors' - {print} 'You lose!' - {if} computer_choice == 'rock' {and} your_choice == 'paper' - {print} 'You win!' - won = 'yes' - ``` - rock_2: - levels: - 2: - story_text: | - Now that you have learned how to use the `{ask} command, you can make your rock, paper, scissors code interavtive too! - - ### Exercise - Make the rock, paper, scissors code interactive by adding the `{ask}` command and a question to your rock, paper, scissors code. - example_code: | - ``` - choice is _ - {print} I choose choice - ``` - secret: - default_save_name: language - levels: - 12: - story_text: | - In this adventure you can create your own super spy code. Encode a message that only the right agent can decipher. - If the enemy tries to crack the code, they will get some false info to waste their time. - example_code: | - ``` - name {is} {ask} 'What is your name?' - {if} name {is} '_' - a {is} 'Go to the airport ' - {else} - a {is} 'Go to the trainstation ' - password {is} {ask} 'What is the password?' - {if} password {is} _ - b {is} 'tomorrow at 02.00' - {else} - b {is} 'today at 10.00' - {print} _ _ _ - ``` - 13: - story_text: | - The code you made in the previous level can be made a lot easier in this one with the `{and}` command. - sleep_command: - description: introducing sleep command - levels: - 2: - story_text: | - ## The sleep command - Another new command in this level is `{sleep}`, which pauses your program for a second. If you type a number behind the {sleep} command, the program pauses for that amount of seconds. - songs: - levels: - 6: - story_text: | - Songs often contain a lot of repetition. Sometimes the repetition is also based on counting. - For example, in the well-known song 'Bottles of beer'. You can program that song with a little math. - example_code: | - ``` - verse = 99 - {print} verse ' bottles of beer on the wall' - {print} verse ' bottles of beer' - {print} 'Take one down, pass it around' - verse = verse - 1 - {print} verse ' bottles of beer on the wall' - ``` - - You can now repeat lines 2 to 9 as many times as you want by copying the lines. - example_code_2: | - ``` - number = 6 - number = number - 1 - print number ' little monkeys jumping on the bed' - print 'One fell off and bumped his head' - print 'Mama called the doctor and the doctor said' - print 'NO MORE MONKEYS JUMPING ON THE BED!' - sleep - ``` - 7: - story_text: | - Songs often contain a lot of repetition. For example... Baby Shark! If you sing it, you keep singing the same thing: - - Baby Shark tututudutudu
- Baby Shark tututudutudu
- Baby Shark tututudutudu
- Baby Shark - - You can make this song much shorter with a `{repeat}`! Can you finish the code? - example_code: | - ``` - {repeat} _ _ {print} 'Baby Shark tututudutudu' - {print} 'Baby Shark' - ``` - - After Baby Shark you can of course also program other songs. There are many songs with repetition. - 8: - story_text: | - In a previous level you've programmed the song 'Bottles of beer'. You made one verse and then had to copy the verses 99 times. In level 7 you can repeat the song 99 times, just by adding one simple line! - example_code: | - ``` - verse = 99 - {repeat} 99 {times} - {print} verse ' bottles of beer on the wall' - {print} verse ' bottles of beer' - {print} 'Take one down, pass it around' - verse = verse - 1 - {print} verse ' bottles of beer on the wall' - ``` - 10: - story_text: | - In this level you can easily make the childrens' song 'Five little monkeys'. Can you make the last chorus? - You can also make the whole baby shark song (including all the other sharks in the family) in only 6 lines! - Or you can make Old MacDonald with all the different animals. - example_code: | - ``` - monkeys = 5, 4, 3, 2 - {for} monkey {in} monkeys - {print} monkey ' little monkeys jumping on the bed' - {print} 'One fell off and bumped his head' - {print} 'Mama called the doctor and the doctor said' - {print} 'NO MORE MONKEYS JUMPING ON THE BED!' - ``` - - ``` - sharks = baby, mommy, daddy, grandma, grandpa - {for} shark {in} sharks - {print} shark 'tututututudu' - {print} shark 'tututututudu' - {print} shark 'tututututudu' - {print} shark - ``` - ``` - animals = pig, dog, cow - {for} animal {in} animals - {if} animal {is} pig - sound = oink - {if} animal {is} dog - sound = woof - {if} animal {is} cow - sound = moo - {print} 'Old MacDonald had a farm' - {print} 'E I E I O!' - {print} 'and on that farm he had a ' animal - {print} 'E I E I O!' - {print} 'with a ' sound sound ' here' - {print} 'and a ' sound sound ' there' - {print} 'here a ' sound - {print} 'there a ' sound - {print} 'everywhere a ' sound sound - ``` - story_text_2: | - ### Exercise 2 - Print the song Five little moneys jumping on the bed. Look up the text if you don't remember. - - **(extra)** Print the song Old MacDonald had a farm, and make sure all animals make a different sound, using an `{if}`. - 11: - story_text: | - In this level you can use the `{for} i {in} {range}` command to make songs that use counting. - example_code: | - ``` - {for} i {in} {range} 5 {to} 1 - {print} i ' little monkeys jumping on the bed' - {print} 'One fell off and bumped his head' - {print} 'Mama called the doctor and the doctor said' - {if} i {is} 1 - {print} 'PUT THOSE MONKEYS RIGHT TO BED!' - {else} - {print} 'NO MORE MONKEYS JUMPING ON THE BED!' - ``` - 12: - story_text: | - In this song we can make it even easier to program '{if} you're happy and you know it, clap your hands'. Because we can put all of the actions in a variable, check it out: - example_code: | - ``` - actions = 'clap your hands', 'stomp your feet', 'shout Hurray!' - {for} action {in} actions - {for} i {in} {range} 1 {to} 2 - {print} '{if} youre happy and you know it' - {print} action - {print} '{if} youre happy and you know it and you really want to show it' - {print} '{if} youre happy and you know it' - {print} action - ``` - songs_2: - levels: - 12: - example_code: | - ``` - {define} twinkle - {print} 'Twinkle' - {print} '...' - - {call} twinkle - {print} 'Up above the world so high' - {print} 'Like a diamond in the sky' - {call} _ - ``` - turtle: - default_save_name: turtle - levels: - 1: - story_text: | - You can also use Hedy to draw. By combining turns and lines, you can make a square or stairs! - - Using `{forward}` you draw a line forwards. The number behind it determines how far the turtle will walk. `{turn} {right}` turns a quarter turn in clockwise direction, `{turn} {left}` turns counter clockwise. - 2: - story_text: | - In level 1 the turtle could only turn left or right. That is a bit boring! - In level 2 he can point his nose in all directions. - - Use 90 to turn a quarter. We call this degrees. A full turn is 360 degrees. - Can you make a figure with this code? Maybe a triangle or a circle? - example_code: | - ``` - answer {is} {ask} How many steps should the turtle make? - {forward} answer - ``` - story_text_2: | - Also, in level 1 the turtle could only turn left or right. That is a bit boring! - In level 2 he can point his nose in all directions. - - Use 90 to turn a quarter. We call this degrees. A full turn is 360 degrees. - Can you make a figure with this code? Maybe a triangle or a circle? - example_code_2: | - ``` - {print} Drawing figures - angle {is} 90 - {turn} angle - {forward} 25 - {turn} angle - {forward} 25 - ``` - 3: - story_text: | - In this level you can use use `{at} {random}` with the drawing turtle. A random choice makes the turtle walk a different path each time. - Use `{at} {random}` to choose a value from a list. You can copy and paste lines 2 and 3 to create a longer random path. - 4: - example_code: | - ``` - {print} 'Drawing figures' - angle {is} 90 - {turn} angle - {forward} 25 - {turn} angle - {forward} 25 - ``` - 5: - example_code_2: | - ``` - direction {is} {ask} 'Do you want to go left, right, or straight ahead?' - if direction is left turn _ - if direction is right turn _ - forward 100 - ``` - 8: - story_text: | - Now that we can repeat several lines, we can make figures more easily. - We only have to set the angle once and then use that variable in the `{repeat}`. - example_code: | - ``` - angle = 90 - {repeat} 10 {times} - {turn} angle - {forward} 50 - ``` - story_text_2: | - Also, we can now improve the program that draws different figures. - Can you figure out how far the turtle has to turn here? Finish the code and you can draw any polygon you'd like! - 9: - story_text: | - Now that we can use a `{repeat}` inside a `{repeat}`, we can create more complex figures. - - ### Exercise 1 - This code creates three black triangles, change that into five pink squares. - - **(extra)** Create a figure of your own choosing consisting of at least two different shapes types. - 10: - story_text: | - In this level you can make the turtle draw a figure. - The turtle will travel the distances in the list, one by one, making bigger and bigger steps. - ### Exercise 1 - Add a 90 degree turn in the loop, so that a spiral is drawn. - Add at least 5 numbers to the list, so the spiral grows larger. - **(extra)** can you change the spiral into another shape? Experiment with numbers for the turn! - ### Exercise 2 - The spiral is drawn outwards, make it go inwards? - turtle_draw_it: - levels: - 9: - example_code: | - Hint for the nested squares: - ``` - colors = red, blue, orange, yellow, pink, purple, green, brown, black - distance = 120 - repeat 5 times - _ - ``` - Hint for the flags: - ``` - country = ask 'which country would you like to see the flag of?' - if country is 'the Netherlands' - color_1 = red - color_2 = white - color_3 = blue - ``` - 10: - example_code: | - Hint Nested Hexagon: - ``` - distances = 100, 80, 60, 40, 20 - {for} distance {in} distances - _ - ``` - - Hint Traffic Lights: - ``` - colors = red, yellow, green - {for} chosen_color {in} colors - color _ - {repeat} _ - ``` - 12: - story_text: | - ### Exercise - Recreate the drawings with the turtle! - Hint: Bracelet designing program. Firstly, define a function **for each shape** you want to use on the bacelet. Then, add the shapes to the bacelet like this: - - Bracelet Designing program - example_code: | - ``` - {define} draw_a_square - _ - - {color} white - {turn} -90 - {forward} 300 - {turn} 180 - - {for} i {in} {range} 1 {to} 5 - {color} gray - {forward} 100 - shape = {ask} 'What kind of shape would you like next on the bracelet?' - chosen_color = {ask} 'In which color?' - {color} chosen_color - {if} shape = 'square' - {call} draw_a_square - ``` - while_command: - description: while - years: - description: Countdown to the new year! - levels: - 11: - story_text: | - In this level you can use the `{for} i {in} {range}` command to countdown to the New Year. - - ### Exercise - Fill in the blanks and make the code work! - example_code: | - ``` - for _ in _ 10 to 1 - {print} i - {print} 'Happy New Year!' - ``` diff --git a/content/adventures/fi.yaml b/content/adventures/fi.yaml index 897c2377514..27088568bd2 100644 --- a/content/adventures/fi.yaml +++ b/content/adventures/fi.yaml @@ -275,409 +275,6 @@ adventures: nimi = {input}("Mikä on nimesi?") {print}('Tervetuloa tähän tarinaan!') ``` - add_remove_command: - name: '{add} {to} & {remove} {from}' - 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. - 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. - and_or_command: - description: introducing and or - ask_command: - description: Introduction ask command - levels: - 1: - 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. - calculator: - levels: - 6: - 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_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`. - 11: - example_code: | - ``` - number = 10 - {for} i {in} {range} 1 to 10 - {print} i * number - ``` - 12: - story_text: | - Now you can make a calculator that works for decimal numbers. Fill in the blanks to get it to work properly! - example_code: | - ``` - number1 = {ask} 'What is the first number?' - number2 = {ask} 'What is the second number?' - answer = _ - {print} number1 ' plus ' number2 ' is ' answer - ``` - 14: - 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 - clear_command: - description: clear command - debugging: - levels: - 3: - 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} - ``` - 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! - 8: - 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: - 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!' - {else} - 'I'm sorry we don't sell that' - topping {is} {ask} 'What kind of topping would you like?' - sauce {is} {ask} 'What kind of sauce would you like?' - {print} One chosen_bread with topping and sauce. - price = amount * 6 - {print} 'That will be 'price dollar' please' - ``` - - price = amount * 6 - {print} 'That will be 'price dollar' please' - 10: - example_code: | - **Warning! This code needs to be debugged!** - ``` - names = Muad Hasan Samira Noura - activities = fly a kite, go swimming, go hiking, catch tan in the sun - {for} name {is} names - {print} At the beach name loves to activity at random - ``` - 11: - story_text: |- - ### Exercise - Debug this calender program. The output of this program is supposed to look like a list of dates. - For example: - - ``` - Hedy calender - Here are all the days of November - November 1 - November 2 - November 3 - ``` - And so on. - - Mind that you have to test your code extra carefully for the month February, because the amount of days in this month changes in leap years. - example_code: | - **Warning! This code needs to be debugged!** - ``` - print 'Hedy calender' - months_with_31 days = January, March, May, July, September, October, December - months_with_30_days = April, June, August, November - month = ask 'Which month would you like to see?' - if month in months_with_31_days - days = 31 - if month in months_with30_days - days = 30 - if month = February - leap_years = 2020, 2024, 2028, 2036, 2040, 2044, 2028 - year = ask 'What year is it?' - if year in leap_years - days = 29 - else - days = 28 - - print 'Here are all the days of ' moth - for i in range 1 to days - print month i - ``` - 12: - example_code: | - **Warning! This code needs to be debugged!** - ``` - define greet - greetings = 'Hello', 'Hi there', 'Goodevening' - print greetings at random - - define take_order - food = ask 'What would you like to eat?' - print 'One food' - drink = 'What would you like to drink?' - print 'One ' drink - more = ask 'Would you like anything else?' - if more is 'no' - print 'Alright' - else - print 'And ' more - print 'Thank you' - - print 'Welcome to our restaurant' - people = ask 'How many people are in your party tonight?' - for i in range 0 to people - call greet_costumer - ``` - 13: - example_code: | - **Warning! This code needs to be debugged!** - ``` - defin movie_recommendation with name - action_movies == 'Die Hard', 'Fast and Furious', 'Inglorious Bastards' - romance_movies = 'Love Actually', 'The Notebook', 'Titanic' - comedy_movies = 'Mr Bean' 'Barbie''Deadpool' - kids_movies = 'Minions', 'Paddington', 'Encanto' - if name is 'Camila' or name is 'Manuel' - recommended_movie = kids_movie at random - if name is 'Pedro' or 'Gabriella' - mood = ask 'What you in the mood for?' - if mood is 'action' - recommended_movie = comedy_movies at random - if mood is 'romance' - recommended_movie = romance_movies - if mood is 'comedy' - recommended_movie = comedy_movies at random - - print 'I would recommend ' recommended_movie ' for ' name - - name = ask 'Who is watching?' - recommendation = ask 'Would you like a recommendation?' - if recommendaion is 'yes' - print movie_recommendation with name - else - print 'No problem!' - ``` - 14: - example_code: | - **Warning! This code needs to be debugged!** - ``` - define calculate_heartbeat - print 'Press your fingertips gently against the side of your neck' - print '(just under your jawline)' - print 'Count the number of beats you feel for 15 seconds' - beats == ask 'How many beats do you feel in 15 seconds?' - heartbeat = beats*4 - print 'Your heartbeat is ' heartbeat - if heartbeat >= 60 or heartbeat <= 100 - print 'Your heartbeat seems fine' - else - if heartbeat > 60 - print 'Your heartbeat seems to be too low' - if heartbeat < 100 - print 'Your heartbeat seems to be too high' - print 'You might want to contact a medical professional' - - measure_heartbeat = ask 'Would you like to measure your heartbeat?' - if measure_heartbeat = 'yes' - call measure_heartbeat - else - 'no problem' - ``` - - print '(just under your jawline)' - print 'Count the number of beats you feel for 15 seconds' - beats == ask 'How many beats do you feel in 15 seconds?' - heartbeat = beats*4 - print 'Your heartbeat is ' heartbeat - if heartbeat >= 60 or heartbeat <= 100 - print 'Your heartbeat seems fine' - else - if heartbeat > 60 - print 'Your heartbeat seems to be too low' - if heartbeat < 100 - print 'Your heartbeat seems to be too high' - print 'You might want to contact a medical professional' - - measure_heartbeat = ask 'Would you like to measure your heartbeat?' - if measure_heartbeat = 'yes' - call measure_heartbeat - else - 'no problem' - 15: - example_code: | - **Warning! This code needs to be debugged!** - ``` - names = 'Tanya', 'Romy', 'Kayla', 'Aldrin', 'Ali' - verbs='walking', 'skipping', 'cycling', 'driving', 'running' - locations = 'on a mountaintop', 'in the supermarket', 'to the swimming pool' - hiding_spots = 'behind a tree', under a table', in a box' - sounds = 'a trumpet', 'a car crash', 'thunder' - causes_of_noise = 'a television', 'a kid with firecrackers', 'a magic elephant', 'a dream' - - chosen_ name = names at random - chosen_verb = verbs at random - chosen_location = 'locations at random' - chosen_sounds = noises at random - chosen_spot = hiding_spots random - chosen_causes = causes_of_noise at random - - print chosen_name ' was ' chosen_verb ' ' chosen_location - print 'when they suddenly heard a sound like ' sounds at random - print chosen_name ' looked around, but they couldn't discover where the noise came from' - print chosen_name ' hid ' chosen_spot' - print 'They tried to look around, but couldn't see anything from there' - hidden = 'yes' - while hidden = 'yes' - print chosen_name 'still didn't see anything' - answer = ask 'does ' chosen_name ' move from their hiding spot?' - if answer = 'yes' - hidden == 'no' - print 'chosen_name moved from' chosen_spot - print 'And then they saw it was just' chosen_cause - print chosen_name 'laughed and went on with their day' - print The End - ``` - 16: - example_code: | - **Warning! This code needs to be debugged!** - ``` - country = ['The Netherlands', 'Poland', 'Turkey', 'Zimbabwe', 'Thailand', 'Brasil', 'Peru', 'Australia', 'India', 'Romania' ] - capitals = 'Amsterdam', 'Warshaw' 'Istanbul', 'Harare', 'Bangkok', 'Brasilia', 'Lima', 'Canberra', 'New Delhi', 'Bucharest' - score = 0 - for i in range 0 to 10 - answer = ask 'What's the capital of ' countries[i] - correct = capital[i] - if answer = correct - print 'Correct!' - score = score + 1 - else - print 'Wrong,' capitals[i] 'in the capital of' countries[i] - print 'You scored ' score ' out of 10' - - ``` - 17: - example_code: | - **Warning! This code needs to be debugged!** - ``` - define food_order - toppings = ask 'pepperoni, tuna, veggie or cheese?' - size = ask 'big, medium or small?' - number_of_pizza = ask 'How many these pizzas would you like?' - - print 'YOU ORDERED' - print number_of_pizzas ' size ' topping ' pizza' - - define drinks_order - drink = ask 'water, coke, icetea, lemonade or coffee?' - number_of_drinks = ask 'How many of these drinks would you like?' - - print 'YOU ORDERED' - print number_of_drinks ' ' drink - - 'Welcome to Hedy pizza' - more_food = ask 'Would you like to order a pizza?' - while more_food = 'yes' - return food_order - more_food = ask 'Would you like to order a pizza?' - more_drinks = ask 'Would you like to order some drinks?' - while more_drinks == 'yes' - call drink_order - more_drinks == ask 'Would you like to order more drinks?' - - - print 'Thanks for ordering!' - ``` - 18: - example_code: | - **Warning! This code needs to be debugged!** - ``` - animals = ['pig', 'dog', 'cow'] - sounds = ['oink', 'woof', 'moo'] - for i in range 1 to 3 - animal = animals[i] - sound = sounds[i] - print 'Old MacDonald had a farm' - print 'E I E I O!' - print 'and on that farm he had a ' animal - print 'E I E I O!' - print 'with a ' sound sound ' here' - print 'and a ' sound sound ' there' - print 'here a ' sound - print 'there a ' sound - print 'everywhere a ' sound sound - ``` default: name: Johdanto description: Tason selitys @@ -791,222 +388,6 @@ adventures: ``` {print} 2.5 + 2.5 - 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!' - ``` - 14: - story_text: | - We are going to learn more new items. You might know them already from mathematics, the `<` and `>`. - The `<` checks if the first number is smaller than the second, for example age `<` 12 checks if age is smaller than 12. - If you want to check if the first number is smaller or equal to the second, you can use `<=`, for example age `<=` 11. - The `>` checks if the first number is bigger than the second, for example points `>` 10 checks if points is larger than 10. - If you want to check if the first number is bigger or equal to the second, you can use `>=`, for example points `>=` 11. - You use these comparisons in an `{if}`, like this: - example_code: | - ``` - age = {ask} 'How old are you?' - {if} age > 12 - {print} 'You are older than I am!' - ``` - - {if} age < 13 - {print} 'You are younger than me!' - {else} - {print} 'You are older than me!' - 15: - story_text: |- - We are going to learn a new loop, the `{while}` loop! We continue the loop as long as the statement is true. - So don't forget to change the value in the loop. - - In the example code, we continue until a correct answer has been given. - If the correct answer is never given, the loop never ends! - example_code: | - ``` - answer = 0 - {while} answer != 25 - answer = {ask} 'What is 5 times 5?' - {print} 'A correct answer has been given' - ``` - 16: - story_text: |- - We are going to make lists the Python way, with square brackets around the lists! We also keep the quotation marks around each item like we have learned in previous levels. - You can use the square brackets as well to point out a place in the lists. - example_code: | - ``` - friends = ['Ahmed', 'Ben', 'Cayden'] - {print} friends[1] ' is the first friend on the list.' - {print} friends[2] ' is the second friend on the list.' - {print} friends[3] ' is the third friend on the list.' - #now we will match 2 lists using the variable i - lucky_numbers = [15, 18, 6] - {for} i {in} {range} 1 {to} 3 - {print} friends[i] 's lucky number is ' lucky_numbers[i] - ``` - 17: - story_text: |- - Now we are going to change indentation a little bit. Every time that we need an indentation, we need `:` at the line before the indentation. - - In this level you can also use a new command: `{elif}`. `{elif}` is short for `{else} {if}` and you need it when you want to make 3 (or more!) options. - Check it out! - 18: - story_text: |- - We arrived at real Python code! That means we need to use parentheses with {print} and {range} from now on. - {print}('My name is ', name) - dice: - levels: - 3: - example_code: | - ``` - choices {is} 1, 2, 3, 4, 5, earthworm - {print} choices {at} {random} - ``` - 4: - story_text: | - In this level we can make sentences with the die value in the sentence, with quotes of course. - This time the sample code is not quite complete. Can you finish the code? - 5: - story_text: | - You can also make a die again in this level using the `{if}`. - Complete the sample code so that the code says "You can stop throwing" once you have thrown an earthworm. - - But maybe you want to recreate a die from a completely different game. That's fine too! Then make up your own reaction. Eg 'yes' for 6 and 'pity' for something {else}. - example_code: | - ``` - choices {is} 1, 2, 3, 4, 5, earthworm - throw {is} _ - {print} 'you have' _ 'thrown' - {if} _ {is} earthworm {print} 'You can stop throwing.' _ {print} 'You have to hear it again!' - ``` - 6: - story_text: | - You can also make an Earthworm die again in this, but now you can also calculate how many points have been rolled. - You may know that the worm counts 5 points for Earthworms. Now after a roll you can immediately calculate how many points you have thrown. - This is the code to calculate points for one die: - - ### Exercise - Can you make the code so that you get the total score for 8 dice? To do that, you have to cut and paste some lines of the code. - example_code: | - ``` - choices = 1, 2, 3, 4, 5, earthworm - points = 0 - throw = choices {at} {random} - {print} 'you threw' throw - {if} throw {is} earthworm points = points + 5 {else} points = points + throw - {print} 'those are' points ' point' - ``` - example_code_2: | - Did you manage to calculate the score for 8 dice? That required a lot of cutting and pasting, right? We are going to make that easier in level 7! - 7: - story_text: | - You can also make a die again in level 5. With the `{repeat}` code you can easily roll a whole hand of dice. - Try to finish the sample code! The dashes should contain multiple commands and characters. - - But maybe you want to make a completely different die. Of course you can! - example_code: | - ``` - choices = 1, 2, 3, 4, 5, earthworm - {repeat} _ _ {print} _ _ _ - ``` - 10: - story_text: | - Is everybody taking too long throwing the dice? In this level you can let Hedy throw all the dice at once! - Can you fill in the correct line of code on the blanks? - example_code: | - ``` - players = Ann, John, Jesse - choices = 1, 2, 3, 4, 5, 6 - _ - {print} player ' throws ' choices {at} {random} - {sleep} - ``` - dishes: - description: Use the computer to see who does the dishes (Start at level 2) - levels: - 3: - story_text: | - Do you always disagree at home about who should wash the dishes or change the litter box today? - Then you can let the computer choose very fairly. You can program that in this level! - You first make a list of the members of your family. Then choose `{at} {random}` from the list. - example_code: | - ``` - people {is} mom, dad, Emma, Sophie - {print} people {at} {random} - ``` - story_text_2: | - Don't feel like doing the dishes yourself? Hack the program by removing your name from the list with the `{remove}` `{from}` command. - 4: - story_text: | - With quotation marks you can make your dishwashing planning more beautiful. - This time the sample code is not quite complete. - - Can you complete the code by filling the blanks? Every blank must be replaced with one word of symbol. - - Tip: Don't forget the quotation marks! - 5: - story_text: | - With the `{if}` you can now have more fun with choice in the program. You can have your program respond to the choice that the computer has made. - - Can you finish the code so that it prints 'too bad' when it is your turn and otherwise 'yes!'? - Don't forget the quotes! - example_code: "```\npeople {is} mom, dad, Emma, Sophie\ndishwasher {is} people {at} {random}\n{if} dishwasher {is} Sophie {print} _ too bad I have to do the dishes _ \n{else} {print} 'luckily no dishes because' _ 'is already washing up'\n```\n" - 6: - story_text_2: | - If you are extremely unlucky the previous program might choose you to to the dishes for the whole week! That's not fair! - To create a fairer system you can use the `{remove}` command to remove the chosen person from the list. This way you don't have to do the dishes again untill everybody has had a turn. - - Monday and tuesday are ready for you! Can you add the rest of the week? - And... can you come up with a solution for when your list is empty? - example_code_2: | - ``` - people = mom, dad, Emma, Sophie - dishwasher = people {at} {random} - {print} 'Monday the dishes are done by: ' dishwasher - {remove} dishwasher {from} people - dishwasher = people {at} {random} - {print} 'Tuesday the dishes are done by: ' dishwasher - {remove} dishwasher {from} people - dishwasher = people {at} {random} - ``` - 7: - story_text: | - With the `{repeat}` you can repeat pieces of code. You can use this to calculate who will be washing dishes for the entire week. - example_code: | - ``` - people = mom, dad, Emma, Sophie - {repeat} _ _ {print} 'the dishwasher is' _ - ``` - 10: - story_text: | - In this level you could make an even better dish washing shedule. - example_code: | - ``` - days = Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday - names = mom, dad, Emma, Sophie - _ day _ days - {print} names {at} {random} ' does the dishes on ' day - ``` - elif_command: - description: elif - levels: - 17: - example_code: | - ``` - prices = ['1 million dollars', 'an apple pie', 'nothing'] - your_price = prices[{random}] - {print} 'You win ' your_price - {if} your_price == '1 million dollars' : - {print} 'Yeah! You are rich!' - {elif} your_price == 'an apple pie' : - {print} 'Lovely, an apple pie!' - {else}: - {print} 'Better luck next time..' - ``` for_command: description: for command levels: @@ -1016,1080 +397,3 @@ adventures: Teemme sen lisäämällä muuttujanimen, jota seuraa `{in}` `{range}`. Kirjoitamme sitten numeron, josta aloitetaan `{to}` ja numeron, johon lopetetaan. Kokeile esimerkkiä, niin näet mitä tapahtuu! Tällä tasolla sinun on taas käytettävä sisennyksiä `{for}` -lauseiden alapuolisilla riveillä. - fortune: - levels: - 1: - story_text: | - Have you ever been to a carnival and had your future predicted by a fortune teller? Or have you ever played with a magic eight ball? - Then you probably know that they can't really predict your future, but it's still fun to play! - - In the upcoming levels you can learn how to create your own fortune telling machine! - In level 1 you can start off easy by letting Hedy introduce herself as a fortune teller and let her {echo} the players' answers. - Like this: - example_code: | - ``` - {print} Hello, I'm Hedy the fortune teller! - {ask} Who are you? - {print} Let me take a look in my crystal ball - {print} I see... I see... - {echo} Your name is - ``` - story_text_2: | - ### Exercise - Hedy now only tells you your name. Can you expand the code so that Hedy can predict more things about you? - Obviously, Hedy isn't a very good fortune teller yet, as she can only repeat the answers that were given by the players! - Take a look in level 2 to improve your fortune teller. - 3: - story_text: | - In the previous levels you've created your first fortune telling machine, but Hedy couldn't really predict anything, only {echo}. - In this level you can use a variable and the `{at} {random}` command to really let Hedy choose an answer for you. Check out this code for instance: - 5: - story_text: | - In this level you'll learn to (secretly) tip the odds in your favor, when using the fortune teller! - By using `{if}` and `{else}` you can make sure that you will always get a good fotune, while other people might not. - Check out this example to find out how. - example_code: | - ``` - {print} 'Im Hedy the fortune teller!' - {print} 'I can predict if youll win the lottery tomorrow!' - person {is} {ask} 'Who are you?' - {if} person {is} Hedy {print} 'You will definitely win!🤩' {else} {print} 'Bad luck! Someone else will win!😭' - ``` - 6: - example_code: | - ``` - {print} 'I am Hedy the fortune teller!' - {print} 'I can predict how many kids youll get when you grow up!' - age = {ask} 'How old are you?' - siblings = {ask} 'How many siblings do you have?' - length = {ask} 'How tall are you in centimetres?' - kids = length / age - kids = kids - siblings - {print} 'You will get ...' - {sleep} - {print} kids ' kids!' - ``` - - If the previous example wasn't silly enough for you, take a look at this one! - ``` - {print} 'Im Hedy the silly fortune teller!' - {print} 'I will predict how smart you are!' - football = {ask} 'On a scale 1-10 how much do you love football?' - bananas = {ask} 'How many bananas did you eat this week?' - hygiene = {ask} 'How many times did you wash your hands today?' - result = bananas + hygiene - result = result * football - {print} 'You are ' result ' percent smart.' - ``` - 7: - story_text: | - In this level you can use the `{repeat}` command to make your machine tell multiple fortunes at once. - 8: - story_text: | - In the previous levels you've learned how to use `{repeat}` to make the fortune teller answer 3 questions in a row, but we had a problem with printing the questions. - Now that problem is solved, because of the new way of using the `{repeat}` command. - In the next example you can have your fortune teller ask 3 questions and also print them! - - ### Exercise - Can you fill in the `{repeat}` command correctly on the blanks? - example_code: | - ``` - {print} 'I am Hedy the fortune teller!' - {print} 'You can ask me 3 questions.' - answers = yes, no, maybe - _ _ _ - question = {ask} 'What do you want to know?' - {print} question - {sleep} - {print} 'My crystal ball says...' answers {at} {random} - ``` - 10: - story_text: | - In this level you'll learn how to program the game MASH (mansion, apartement, shack, house). In this game you can predict for all the players at once, what their future will look like. - example_code: | - ``` - houses = mansion, apartment, shack, house - loves = nobody, a royal, their neighbour, their true love - pets = dog, cat, elephant - names = Jenna, Ryan, Jim - {for} name {in} names - {print} name ' lives in a ' houses {at} {random} - {print} name ' will marry ' loves {at} {random} - {print} name ' will get a ' pets {at} {random} ' as their pet.' - {sleep} - ``` - 12: - story_text: | - In this level you can make your fortunes multiple words. Can you add more different fortunes to the list? - example_code: | - ``` - fortunes = 'you will slip on a banana peel', _ - {print} 'I will take a look in my crystall ball for your future.' - {print} 'I see... I see...' - {sleep} - {print} fortunes {at} {random} - ``` - functions: - levels: - 12: - example_code: | - ``` - sides = 'left', 'right' - limbs = 'hand', 'foot' - colors = 'red', 'blue', 'green', 'yellow' - - {define} turn - chosen_side = sides {at} {random} - chosen_limb = limbs _ - chosen_color = colors _ - {print} chosen_side ' ' chosen_limb ' on ' chosen_color - - {print} 'Lets play a game of Twister!' - {for} i {in} {range} 1 to _ - {call} turn - {sleep} 2 - ``` - 13: - story_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. - - For example in this code we've programmed the first verse of the song 'My Bonnie is over the ocean'. - In this example code the argument `place` is used. Place is a variable that is only used in the function, so an argument. - To use `place` we have programmed the line `define song with place`. - When the function is called, computer will replace the argument `place`, with the piece of text after `call song with`. - - ### Exercise - The next verse of this song goes: - - Last night as I lay on my pillow - Last night as I lay on my bed - Last night as I lay on my pillow - I dreamed that my Bonnie is dead - - Can you program this verse in the same way as the example? - 14: - example_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?' - - new_price = _ calculate_new_price {with} old_price, _ - {print} 'The new price is ' new_price ' dollar' - ``` - haunted: - levels: - 1: - story_text_2: | - ### Exercise - Can you finish the scary story? Or make up your own haunted house story? - 2: - example_code: | - ``` - monster_1 {is} 👻 - monster_2 {is} 🤡 - monster_3 {is} 👶 - {print} You enter the haunted house. - {print} Suddenly you see a monster_1 - {print} You run into the other room, but a monster_2 is waiting there for you! - {print} Oh no! Quickly get to the kitchen. - {print} But as you enter monster_3 attacks you! - ``` - example_code_2: | - ``` - monster_1 {is} _ - monster_2 {is} _ - monster_3 {is} _ - {print} You enter the haunted house. - {print} Suddenly you see a monster_1 - {print} You run into the other room, but a monster_2 is waiting there for you! - {print} Oh no! Quickly get to the kitchen. - {print} But as you enter monster_3 attacks you! - ``` - 3: - story_text: | - In the previous levels you've made an introduction to your haunted house game, but as you might have noticed the story would always have a dreadful end. - In this level you can make your story more interactive by changing the outcome of the game; sometimes you'll get eaten, sometimes you'll escape! - Let Hedy decide randomly! - 4: - story_text: | - In this level you learn how to use quotation marks in your games. - Can you make your Haunted House level 4 proof? - example_code: | - ``` - {print} _ Escape from the haunted house! _ - {print} _ There are 3 doors in front of you... _ - choice {is} {ask} _ Which door do you choose? _ - {print} _ You picked door ... _ choice - monsters {is} a zombie, a vampire, NOTHING YOUVE ESCAPED - {print} _ You see... _ - {sleep} - {print} monsters {at} {random} - ``` - 9: - story_text: | - In this level you can use nesting, which allows you to make the haunted house even more interactive! - - ### Exercise - Now it's very hard to win this game, can you make it easier to win? - For example by only having 1 wrong door and 2 correct doors instead of 1 correct door and 2 wrong ones? - 11: - story_text: | - In this level we've changed the repeat command and we've added a line to our haunted house that tells the player in which room they are. - - ### Exercise - Finish the program with the correct line of code. Mind: There are 3 rooms that the player needs to survive before they win! - example_code: | - ``` - {print} 'Escape from the Haunted House!' - player {is} alive - doors = 1, 2, 3 - monsters = zombie, vampire, giant spider - _ - {if} player {is} alive - correct_door = doors {at} {random} - {print} 'Room ' i - {print} 'There are 3 doors in front of you...' - chosendoor = {ask} 'Which door do you choose?' - {if} chosendoor {is} correct_door - {print} 'No monsters here!' - {else} - {print} 'You are eaten by a ' monsters {at} {random} - player = dead - {else} - {print} 'GAME OVER' - {if} player {is} alive - {print} 'Great! You survived!' - ``` - if_command: - description: Introducing the if command - levels: - 9: - story_text: | - In this level you can also put an {if} command inside another {if} command. - in_command: - description: Introducing the in command - levels: - 5: - example_code_2: | - ``` - animals is dog, cow, sheep - answer is ask 'What is your favorite animal?' - _ answer _ animals _ 'Mine too!' - _ _ 'My favorite animals are dogs, cows and sheep' - ``` - is_command: - description: introducing is command - levels: - 2: - story_text_2: | - ### Exercise - Time to make your own variables! - In the example code we made an example of the variable `favorite_animal`. In line 1 the variable is set, and in line 2 we haved used the variable in a print command. - Firstly, finish our example by filling in your favorite animal on the blank. Then make at least 3 of these codes yourself. Pick a variable, and set the variable with the {is} command. Then use it with a {print} command, just like we did. - 14: - example_code: | - ``` - age = {ask} 'How old are you?' - {if} age > 12 - {print} 'You are older than I am!' - ``` - example_code_3: | - ``` - name = {ask} 'What is your name?' - {if} name != 'Hedy' - {print} 'You are not Hedy' - ``` - - {if} age < 13 - {print} 'You are younger than me!' - {else} - {print} 'You are older than me!' - language: - levels: - 5: - story_text: | - Make your own program to practice your vocabulary in a new language. - - ### Exercise - Can you make this program for a different language? Or can you add more words to the French one? - maths: - levels: - 6: - example_code: | - ``` - {print} '5 plus 5 is ' 5 + 5 - {print} '5 minus 5 is ' 5 - 5 - {print} '5 times 5 is ' 5 * 5 - ``` - 12: - example_code_2: | - ``` - a = 'Hello ' - b = 'world!' - {print} a + b - ``` - - {print} 2.5 + 2.5 - music: - levels: - 6: - story_text: "Instead of playing notes, you can also play numbers now. Simply type `{play} 1` for the lowest note, `{play} 70` for the highest note, or anything in between.\n\n### Exercise\n This calls for musical maths! Try out the example code a couple of times with different starting numbers. \nThen, see if you can compose a song using the numbers.\n" - parrot: - levels: - 1: - story_text_2: | - ### Exercise - Can you make the parrot ask a different question? Fill in the blanks in the example! - 2: - story_text: | - Create your own online pet parrot that will copy you! - example_code: | - ``` - {print} Im Hedy the parrot - name {is} {ask} whats your name? - {print} name - {sleep} - {print} squawk - {sleep} - {print} name - ``` - story_text_2: | - ### Exercise - You can use variables to make the parrot say more than only your name. Can you complete this code? - 3: - story_text: | - Teach your parrot a new word with `{add}`. - ### Exercise - How can you make your parrot say multiple words? - example_code: | - ``` - words {is} squawk, Hedy - {print} Train your parrot! - new_word {is} {ask} Which word do you want to teach them? - {add} new_word {to_list} words - {print} 🧒 Say new_word, Hedy! - {print} 🦜 words {at} {random} - ``` - 4: - story_text: | - In this level we have to use quotation marks with the commands `{ask}` and `{print}`. - Can you complete the code by adding quotation marks? - 5: - story_text: | - Reward your parrot if it says the correct word! - Finish the code by filling in the 4 missing commands. - piggybank: - levels: - 12: - story_text: | - In this adventure you learn how to make a digital piggy bank. - Finish the code to calculate how much money you have and how long you need to save up to buy what you want! - 14: - example_code: | - ``` - _ calculate_budget with wish, money, allowance - to_save = wish - money - weeks = to_save / allowance - {if} wish _ money - {print} 'You need to save up some more!' - {print} 'Youll need ' weeks ' more weeks.' - {else} - {print} 'Great! You have enough' - {print} 'Lets go shopping!' - - money = {ask} 'How much money have you saved?' - wish = {ask} 'How much money do you need?' - allowance = {ask} 'How much pocket money do you get each week?' - - {call} calculate_budget with _, _, _ - ``` - pressit: - levels: - 9: - story_text: | - Now that you know how to combine statements, you can create a touch type tool with `{pressed}`. - - ### Exercise - Finish the code. Each time a random letter should be chosen, which you have to press. You get a point for a correct press, and and two points deduction for a wrong press. - **(extra)** Clear the screen after each letter, and show the user how many points they have scored. - print_command: - levels: - 18: - example_code_2: | - ``` - temperature = 25 - {print}('It is ', temperature, ' degrees outside') - ``` - - {print}('My name is ', name) - random_command: - levels: - 16: - story_text: |- - We are going to make lists the Python way, with square brackets around the lists! We also keep the quotation marks around each item like we have learned in previous levels. - We use square brackets to point out a place in a list. For example: `friends[1]` is the first name on the list of friends, as you can see in the first part of the example code. The second part of the example code shows you that we can also match 2 lists using the variable i. - repeat_command: - description: repeat command - levels: - 7: - story_text: | - ## Repeat! Repeat! Repeat! - Level 7 adds the `{repeat}` command. `{repeat}` can be used to execute one line of code multiple times. Like this: - - ### Exercise - Play around with the repeat command. Can you make the happy birthday song in only 3 lines of code instead of 4 now? - 9: - story_text: | - Great job! You've reached another new level! In the previous level you've learned to use multiple lines of code in an {if} or {repeat} command. But you can't yet combine the two... - Good news! In this level you will be allowed to put an {if} inside an {if}, or inside a {repeat} command. Putting a block of code inside another block of code is called nesting. ``` Putting a block of code inside another block of code is called nesting. - example_code: | - ``` - answer = {ask} 'Are you ready to learn something new?' - {if} answer {is} yes - {print} 'Great! You can learn to use the repeat command in the if command!' - {print} 'Hooray!' - {print} 'Hooray!' - {print} 'Hooray!' - {else} - {print} 'Maybe you should practice some more in the previous level' - repeat_command_2: - description: repeat command 2 - levels: - 7: - story_text_2: | - Another interesting thing you can so with the `{repeat}` command is using variables to set the amount of times something should be repeated. In the example code you can see that we first ask the person how old they are. - Then, in line 3, the question is repeated 'age' times. So we have used the variable 'age' with the `{repeat}` command. - restaurant: - levels: - 1: - story_text_2: | - ### Exercise - Can you think of more lines to add to your restaurant code? For example, can you {ask} the guests what they'd like to drink, tell them the price, or wish them a pleasant meal? - example_code_2: | - ``` - {print} Welcome to Hedy's restaurant 🍟 - {ask} What would you like to order? - {echo} So you would like to order - {print} Thanks you for your order! - {print} It's on its way! - ``` - 2: - story_text: | - In level 2 you could expand your restaurant by using variables. In level 1 Hedy could only {echo} the order once and only remember the last thing that was ordered. - Now you can use variables and Hedy can remember both the food and the toppings! - story_text_2: | - ### Exercise - Can you make this code more elaborate? For example by adding drinks to the order? Or...? - 3: - story_text: | - Having trouble to decide what you wanna have for dinner? You can let Hedy choose for you! - Simply add lists of your favorite (or least favorite) meals and Hedy can randomly choose your dinner. - You can also have a bit of fun, by letting Hedy choose the price for your dinner as well! What will you get? - ### Exercise - Can you make your own version of the random restaurant? - example_code: | - ``` - {print} Welcome to Hedy's Random Restaurant! - {print} The only restaurant that will randomly choose your meal and its price for you! - starters {is} salad, soup, carpaccio - mains {is} pizza, brussels sprouts, spaghetti - desserts {is} brownies, ice cream, french cheeses - drinks {is} cola, beer, water - prices {is} 1 dollar, 10 dollars, 100 dollars - {print} You will start with: starters {at} {random} - {print} Then we'll serve: mains {at} {random} - {print} And as dessert: desserts {at} {random} - {print} You will get a drinks {at} {random} to drink - {print} That will be: prices {at} {random} - {print} Thank you and enjoy your meal! - ``` - story_text_2: | - Does your costumer have any allergies or do they dislike certain dishes? Then you can use the `{remove}`command to remove it from your menu. - example_code_2: | - ``` - {print} Mystery milkshake - flavors {is} strawberry, chocolate, vanilla - allergies {is} {ask} Are you allergic to any falvors? - _ - {print} You get a flavors {at} {random} milkshake - ``` - 4: - story_text: | - ### Exercise - Add the quotation marks to this code to make it work! Be careful: variables should not be in quotation marks. - example_code: | - ``` - _ Add the quotation marks to this code _ - {print} Welcome to Hedys restaurant! - {print} Today we are serving pizza or lasagna. - food {is} {ask} What would you like to eat? - {print} Great choice! The food is my favorite! - topping {is} {ask} Would you like meat or veggies on that? - {print} food with topping is on its way! - drinks {is} {ask} What would you like to drink with that? - {print} Thank you for your order. - {print} Your food and drinks will be right there! - ``` - 5: - story_text: | - In this level the `{if}` command allows you to `{ask}` your customers questions and give different responses to the answers. - In the example below, you see that you can `{ask}` the customer `{if}` they want to hear the specials and Hedy can respond accordingly. - example_code: | - ``` - {print} 'Welcome to Hedys restaurant!' - special {is} {ask} 'Would you like to hear our specials today?' - {if} special {is} yes {print} 'Todays special is chicken piri piri and rice.' {else} {print} 'No problem.' - food {is} {ask} 'What would you like to eat?' - {print} 'One ' food ', coming right up!' - drink {is} {ask} 'What would you like to drink with that?' - {if} drink {is} cola {print} 'Im sorry, we are out of cola!' {else} {print} 'Great choice!' - anything {is} {ask} 'Would you like anything {else}?' - {print} 'Let me repeat your order...' - {print} 'One ' food - {if} drink {is} cola {print} 'and...' {else} {print} 'One ' drink - {if} anything {is} no {print} 'Thats it!' {else} {print} 'One ' anything - {print} 'Thank you for your order and enjoy your meal!' - ``` - 6: - story_text: | - In this level you can use maths to calculate the total price of your customer's order, which can make your virtual restaurant more realistic. - 7: - story_text: | - In this level you've learned how to use the `{repeat}` command to repeat a line of code a certain amount of times. - You can use that in your restaurant to `{ask}` multiple people what they'd like to eat. - - ### Exercise - Can you fill in the blanks? Hedy needs to repeat this question as many times as there are people. So of there are 5 people, the question needs to be asked 5 times. - example_code: | - ``` - {print} 'Welcome to Hedys restaurant!' - people = {ask} 'How many people are joining us today?' - {repeat} _ {times} food = {ask} 'What would you like to eat?' - {print} 'Thanks for your order! Its coming right up!' - ``` - 9: - story_text: | - In this level you can use nesting to make your restaurant more realistic and more fun! - For example you would ask for sauce if somebody orders fries, but you wouldn't if someone orders pizza! - - ### Exercise - This is a challenge for the real brainiacs! Each line that needs indentation has been given a blank. - Can you figure out how much indentation each line needs in order for the code to work propperly? - Good luck! - TIP: If the customer orders pizza, Hedy shouldn't ask what sauce the costumer wants. - example_code: | - ``` - {print} 'Welcome to Hedys restaurant!' - people = {ask} 'How many people will be joining us today?' - {print} 'Great!' - price = 0 - {repeat} people {times} - _ food = {ask} 'What would you like to order?' - _ {print} food - _ {if} food {is} fries - _ price = price + 3 - _ sauce = {ask} 'What kind of sauce would you like with your fries?' - _ {if} sauce {is} no - _ {print} 'no sauce' - _ {else} - _ price = price + 1 - _ {print} 'with ' sauce - _ {if} food {is} pizza - _ price = price + 4 - {print} 'That will be ' price ' dollar' - {print} 'Enjoy your meal!' - ``` - 10: - story_text: | - In this level you'll learn how to easily {ask} your guests' orders in a short code. - example_code: | - ``` - courses = appetizer, main course, dessert - {for} course {in} courses - food = {ask} 'What would you like to eat as your ' course '?' - {print} food ' will be your ' course - ``` - story_text_2: | - ### Exercise - Of course, you could also order for multiple people! - Can you add the correct amount of indentation before each line to make the code work properly? - TIP: some lines don't need any indentation at all. - example_code_2: | - ``` - _ courses = appetizer, main course, dessert - _ names = Timon, Onno - _ {for} name {in} names - _ {for} course {in} courses - _ food = {ask} name ', what would you like to eat as your ' course '?' - _ {print} name ' orders ' food ' as their ' course - ``` - 11: - story_text: | - We can use the `{for} i {in} {range} 1 {to} 5` to `{print}` the orders from multiple customers in an orderly manner. - - ### Exercise - Can you handle another indentation challenge? Get the code to work properly by adding the right amount of indentation before each line! - example_code: | - ``` - {print} 'Welcome to Restaurant Hedy!' - people = {ask} 'For how many people would you like to order?' - {for} i {in} {range} 1 {to} people - _ {print} 'Order number ' i - _ food = {ask} 'What would you like to eat?' - _ {print} food - _ {if} food {is} fries - _ sauce = {ask} 'What kind of sauce would you like with that?' - _ {print} sauce - _ drinks = {ask} 'What would you like to drink?' - _ {print} drinks - price = 4 * people - {print} 'That will be ' price ' dollars, please!' - ``` - 12: - story_text: | - From this level on you can use decimal numbers to make you menu more realistic. - - ### Exercise - Can you think of a code to give your friends and family a 15% discount? - example_code: | - ``` - price = 0 - food = {ask} 'What would you like to order?' - drink = {ask} 'What would you like to drink?' - {if} food {is} 'hamburger' - price = price + 6.50 - {if} food {is} 'pizza' - price = price + 5.75 - {if} drink {is} 'water' - price = price + 1.20 - {if} drink {is} 'soda' - price = price + 2.35 - {print} 'That will be ' price ' dollar, please' - ``` - 13: - story_text: | - In this level we can use the new commands to upgrade our restaurant. - We use `{and}` to see {if} two things are both the case. - example_code: | - ``` - price = 10 - food = {ask} 'What would you like to eat?' - drinks = {ask} 'What would you like to drink?' - {if} food {is} 'sandwich' {and} drinks {is} 'juice' - {print} 'Thats our discount menu' - price = price - 3 - {print} 'That will be ' price ' dollars' - ``` - rock: - default_save_name: Rock - levels: - 2: - story_text: | - In this level you can practise using the variables, so that you can make the rock, paper, scissors game in the next level! - example_code: | - ``` - _ {is} {ask} rock, paper, or scissors? - {print} I choose _ - ``` - 3: - example_code: | - ``` - choices {is} rock, paper, scissors - {print} choices _ _ - ``` - story_text_2: | - ### Exercise - Now you only have one player, so can you add a second player? - You can even use variables to name player 1 and player 2. - example_code_2: | - ``` - choices {is} rock, paper, scissors - {print} player 1 chooses... choices {at} {random} - {print} player 2 _ - ``` - 5: - story_text: | - In this level we can determine who won. - For that you need the new `{if}` code. - - Save your choice with the name of choice and the choice of computer as computer choice. - Then you can use `{if}` to see {if} they are the same or different. - Will you finish the code? - example_code: | - ``` - options {is} rock, paper, scissors - computer_choice {is} _ - choice {is} {ask} 'What do you choose?' - {print} 'you chose ' _ - {print} 'computer chose ' _ - {if} _ {is} _ {print} 'tie!' {else} {print} 'no tie' - ``` - - Fill in the correct code on the blanks to see {if} it is a draw. - 9: - story_text: | - In this level you can program the whole rock, paper, scissors game by nesting the {if}-commands. Can you finish the code? - example_code: | - ``` - choices = rock, paper, scissors - your_choice = {ask} 'What do you choose?' - {print} 'You choose ' your_choice - computer_choice = choices {at} {random} - {print} 'The computer chooses ' computer_choice - {if} computer_choice {is} your_choice - {print} 'Tie' - {if} computer_choice {is} rock - {if} your_choice {is} paper - {print} 'You win!' - {if} your_choice {is} scissors - {print} 'You lose!' - # finish this code - ``` - 10: - story_text: | - Feeling too lazy to play the game yourself? Let Hedy play it for you! - You only have to fill in the names of the players. - example_code: | - ``` - choices = rock, paper, scissors - players = _ - {for} player {in} players - {print} player ' chooses ' choices {at} {random} - ``` - 13: - story_text: | - With the `{and}` command you can shorten your rock, paper, scissors code! Check out the example code below and try to finish it. - rock_2: - levels: - 2: - story_text: | - Now that you have learned how to use the `{ask} command, you can make your rock, paper, scissors code interavtive too! - - ### Exercise - Make the rock, paper, scissors code interactive by adding the `{ask}` command and a question to your rock, paper, scissors code. - example_code: | - ``` - choice is _ - {print} I choose choice - ``` - secret: - levels: - 12: - story_text: | - In this adventure you can create your own super spy code. Encode a message that only the right agent can decipher. - If the enemy tries to crack the code, they will get some false info to waste their time. - - ### Exercise - Make your own secret code for your superspy. Can you make it consist of even more variables? - example_code: | - ``` - name {is} {ask} 'What is your name?' - {if} name {is} '_' - a {is} 'Go to the airport ' - {else} - a {is} 'Go to the trainstation ' - password {is} {ask} 'What is the password?' - {if} password {is} _ - b {is} 'tomorrow at 02.00' - {else} - b {is} 'today at 10.00' - {print} _ _ _ - ``` - 13: - story_text: | - Can you fill in the right command on the blank? Mind: The superspy has to answer BOTH questions correctly, before they get the confidential information! - sleep_command: - description: introducing sleep command - levels: - 2: - story_text: | - ## The sleep command - Another new command in this level is `{sleep}`, which pauses your program for a second. If you type a number behind the {sleep} command, the program pauses for that amount of seconds. - songs: - levels: - 6: - example_code_2: | - ``` - number = 6 - number = number - 1 - print number ' little monkeys jumping on the bed' - print 'One fell off and bumped his head' - print 'Mama called the doctor and the doctor said' - print 'NO MORE MONKEYS JUMPING ON THE BED!' - sleep - ``` - 7: - story_text: | - Songs often contain a lot of repetition. For example... Baby Shark! If you sing it, you keep singing the same thing: - - Baby Shark tututudutudu
- Baby Shark tututudutudu
- Baby Shark tututudutudu
- Baby Shark - - You can make this song much shorter with a `{repeat}`! Can you finish the code? - example_code: | - ``` - {repeat} _ _ {print} 'Baby Shark tututudutudu' - {print} 'Baby Shark' - ``` - - After Baby Shark you can of course also program other songs. There are many songs with repetition. - 8: - story_text: | - In a previous level you've programmed the song 'Bottles of beer'. You made one verse and then had to copy the verses 99 times. In this level you can repeat the song 99 times, just by adding one simple line! - Do you know which line of code to add on the blanks? - example_code: | - ``` - verse = 99 - _ _ _ - {print} verse ' bottles of beer on the wall' - {print} verse ' bottles of beer' - {print} 'Take one down, pass it around' - verse = verse - 1 - {print} verse ' bottles of beer on the wall' - ``` - 10: - story_text: | - In this level you can easily make the childrens' song 'Five little monkeys'. Can you make the last chorus? - You can also make the whole baby shark song (including all the other sharks in the family) in only 6 lines, using `{for}`! - Or you can make Old MacDonald with all the different animals. - - - - ### Exercises - Can you add the last verse of the monkeys on the bed, when there is only one monkey left? - - Can you make the baby shark code even shorter by using a `{repeat}` command? - - Can you add new animals to Old MacDonald's farm? - example_code: | - ``` - monkeys = 5, 4, 3, 2 - {for} monkey {in} monkeys - {print} monkey ' little monkeys jumping on the bed' - {print} 'One fell off and bumped his head' - {print} 'Mama called the doctor and the doctor said' - {print} 'NO MORE MONKEYS JUMPING ON THE BED!' - ``` - - ``` - sharks = baby, mommy, daddy, grandma, grandpa - {for} shark {in} sharks - {print} shark ' shark tututututudu' - {print} shark ' shark tututututudu' - {print} shark ' shark tututututudu' - {print} shark ' shark' - ``` - ``` - animals = pig, dog, cow - {for} animal {in} animals - {if} animal {is} pig - sound = oink - {if} animal {is} dog - sound = woof - {if} animal {is} cow - sound = moo - {print} 'Old MacDonald had a farm' - {print} 'E I E I O!' - {print} 'and on that farm he had a ' animal - {print} 'E I E I O!' - {print} 'with a ' sound sound ' here' - {print} 'and a ' sound sound ' there' - {print} 'here a ' sound - {print} 'there a ' sound - {print} 'everywhere a ' sound sound - ``` - story_text_2: | - ### Exercise 2 - Print the song Five little moneys jumping on the bed. Look up the text if you don't remember. - - **(extra)** Print the song Old MacDonald had a farm, and make sure all animals make a different sound, using an `{if}`. - 11: - story_text: | - In this level you can use the `{for} i {in} {range}` command to make songs that use counting, like the 5 little monkeys. - - ### Exercise - Fill in the blanks and make the code work! - example_code: | - ``` - _ _ _ _ 5 _ 1 - {print} i ' little monkeys jumping on the bed' - {print} 'One fell off and bumped his head' - {print} 'Mama called the doctor and the doctor said' - {if} i {is} 1 - {print} 'PUT THOSE MONKEYS RIGHT TO BED!' - {else} - {print} 'NO MORE MONKEYS JUMPING ON THE BED!' - ``` - songs_2: - levels: - 12: - example_code: | - ``` - {define} twinkle - {print} 'Twinkle' - {print} '...' - - {call} twinkle - {print} 'Up above the world so high' - {print} 'Like a diamond in the sky' - {call} _ - ``` - turtle: - levels: - 2: - story_text: | - In this level you can use variables to make the turtle interactive. For example you can ask the player how many steps the turtle must make. - example_code: | - ``` - answer {is} {ask} How many steps should the turtle make? - {forward} answer - ``` - story_text_2: | - Also, in level 1 the turtle could only turn left or right. That is a bit boring! - In level 2 he can point his nose in all directions. - - Use 90 to turn a quarter. We call this degrees. A full turn is 360 degrees. - - ### Exercise - Can you make a figure with this code? Maybe a triangle or a circle? - example_code_2: | - ``` - {print} Drawing figures - angle {is} 90 - {turn} angle - {forward} 25 - {turn} angle - {forward} 25 - ``` - 3: - story_text: | - In this level you can use use `{at} {random}` with the drawing turtle. A random choice makes the turtle walk a different path each time. - Use `{at} {random}` to choose a value from a list. - ### Exercise - Can you copy and paste lines 2 and 3 to create a longer random path? - 5: - example_code_2: | - ``` - direction {is} {ask} 'Do you want to go left, right, or straight ahead?' - if direction is left turn _ - if direction is right turn _ - forward 100 - ``` - 8: - story_text: | - Now that we can repeat several lines, we can make figures more easily. - We only have to set the angle once and then use that variable in the `{repeat}`. - example_code: | - ``` - angle = 90 - {repeat} 10 {times} - {turn} angle - {forward} 50 - ``` - story_text_2: | - Also, we can now improve the program that draws different figures. - Can you figure out how far the turtle has to turn here? Finish the code and you can draw any polygon you'd like! - 9: - story_text: | - Now that we can use a `{repeat}` inside a `{repeat}`, we can create more complex figures. - - ### Exercise 1 - This code creates three black triangles, change that into five pink squares. - - **(extra)** Create a figure of your own choosing consisting of at least two different shapes types. - 10: - story_text: | - In this level you can make the turtle draw a figure. - The turtle will travel the distances in the list, one by one, making bigger and bigger steps. - ### Exercise 1 - Add a 90 degree turn in the loop, so that a spiral is drawn. - Add at least 5 numbers to the list, so the spiral grows larger. - **(extra)** can you change the spiral into another shape? Experiment with numbers for the turn! - ### Exercise 2 - The spiral is drawn outwards, make it go inwards? - turtle_draw_it: - levels: - 9: - example_code: | - Hint for the nested squares: - ``` - colors = red, blue, orange, yellow, pink, purple, green, brown, black - distance = 120 - repeat 5 times - _ - ``` - Hint for the flags: - ``` - country = ask 'which country would you like to see the flag of?' - if country is 'the Netherlands' - color_1 = red - color_2 = white - color_3 = blue - ``` - 10: - example_code: | - Hint Nested Hexagon: - ``` - distances = 100, 80, 60, 40, 20 - {for} distance {in} distances - _ - ``` - - Hint Traffic Lights: - ``` - colors = red, yellow, green - {for} chosen_color {in} colors - color _ - {repeat} _ - ``` - 12: - story_text: | - ### Exercise - Recreate the drawings with the turtle! - Hint: Bracelet designing program. Firstly, define a function **for each shape** you want to use on the bacelet. Then, add the shapes to the bacelet like this: - - Bracelet Designing program - example_code: | - ``` - {define} draw_a_square - _ - - {color} white - {turn} -90 - {forward} 300 - {turn} 180 - - {for} i {in} {range} 1 {to} 5 - {color} gray - {forward} 100 - shape = {ask} 'What kind of shape would you like next on the bracelet?' - chosen_color = {ask} 'In which color?' - {color} chosen_color - {if} shape = 'square' - {call} draw_a_square - ``` - while_command: - description: while - years: - description: Countdown to the new year! - levels: - 11: - story_text: | - In this level you can use the `{for} i {in} {range}` command to countdown to the New Year. - - ### Exercise - Fill in the blanks and make the code work! - example_code: | - ``` - for _ in _ 10 to 1 - {print} i - {print} 'Happy New Year!' - ``` diff --git a/content/adventures/fr.yaml b/content/adventures/fr.yaml index 1db93efbe51..1a2223de382 100644 --- a/content/adventures/fr.yaml +++ b/content/adventures/fr.yaml @@ -521,30 +521,6 @@ adventures: note_moyenne = {call} _ {print} 'Ta note moyenne est ' note_moyenne ``` - calculator_2: - name: Calculatrice 2 - default_save_name: Calculatrice 2 - description: Calculatrice 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: | - ``` - # Utilise ton code de l'aventure précédente. - ``` clear_command: description: La commande {clear} levels: @@ -832,164 +808,19 @@ adventures: story_text: |- ### Exercice Déboguez ce code. Bonne chance ! - example_code: | - **Attention ! Ce code doit être débuggé !** - ``` - define calculate_heartbeat - print 'Press your fingertips gently against the side of your neck' - print '(just under your jawline)' - print 'Count the number of beats you feel for 15 seconds' - beats == ask 'How many beats do you feel in 15 seconds?' - heartbeat = beats*4 - print 'Your heartbeat is ' heartbeat - if heartbeat >= 60 or heartbeat <= 100 - print 'Your heartbeat seems fine' - else - if heartbeat > 60 - print 'Your heartbeat seems to be too low' - if heartbeat < 100 - print 'Your heartbeat seems to be too high' - print 'You might want to contact a medical professional' - - measure_heartbeat = ask 'Would you like to measure your heartbeat?' - if measure_heartbeat = 'yes' - call measure_heartbeat - else - 'no problem' - ``` - - print '(just under your jawline)' - print 'Count the number of beats you feel for 15 seconds' - beats == ask 'How many beats do you feel in 15 seconds?' - heartbeat = beats*4 - print 'Your heartbeat is ' heartbeat - if heartbeat >= 60 or heartbeat <= 100 - print 'Your heartbeat seems fine' - else - if heartbeat > 60 - print 'Your heartbeat seems to be too low' - if heartbeat < 100 - print 'Your heartbeat seems to be too high' - print 'You might want to contact a medical professional' - - measure_heartbeat = ask 'Would you like to measure your heartbeat?' - if measure_heartbeat = 'yes' - call measure_heartbeat - else - 'no problem' 15: story_text: |- ### Exercice Déboguez cette histoire pour enfants. Bonne chance ! - example_code: | - **Attention ! Ce code doit être débuggé !** - ``` - names = 'Tanya', 'Romy', 'Kayla', 'Aldrin', 'Ali' - verbs='walking', 'skipping', 'cycling', 'driving', 'running' - locations = 'on a mountaintop', 'in the supermarket', 'to the swimming pool' - hiding_spots = 'behind a tree', under a table', in a box' - sounds = 'a trumpet', 'a car crash', 'thunder' - causes_of_noise = 'a television', 'a kid with firecrackers', 'a magic elephant', 'a dream' - - chosen_ name = names at random - chosen_verb = verbs at random - chosen_location = 'locations at random' - chosen_sounds = noises at random - chosen_spot = hiding_spots random - chosen_causes = causes_of_noise at random - - print chosen_name ' was ' chosen_verb ' ' chosen_location - print 'when they suddenly heard a sound like ' sounds at random - print chosen_name ' looked around, but they couldn't discover where the noise came from' - print chosen_name ' hid ' chosen_spot' - print 'They tried to look around, but couldn't see anything from there' - hidden = 'yes' - while hidden = 'yes' - print chosen_name 'still didn't see anything' - answer = ask 'does ' chosen_name ' move from their hiding spot?' - if answer = 'yes' - hidden == 'no' - print 'chosen_name moved from' chosen_spot - print 'And then they saw it was just' chosen_cause - print chosen_name 'laughed and went on with their day' - print The End - ``` 16: story_text: |- ### Exercice Déboguer ce code. Bonne chance ! Astuce : Assurez-vous de ne voir votre score qu'une fois à la fin. - example_code: | - **Attention ! Ce code doit être débuggé !** - ``` - country = ['The Netherlands', 'Poland', 'Turkey', 'Zimbabwe', 'Thailand', 'Brasil', 'Peru', 'Australia', 'India', 'Romania' ] - capitals = 'Amsterdam', 'Warshaw' 'Istanbul', 'Harare', 'Bangkok', 'Brasilia', 'Lima', 'Canberra', 'New Delhi', 'Bucharest' - score = 0 - for i in range 0 to 10 - answer = ask 'What's the capital of ' countries[i] - correct = capital[i] - if answer = correct - print 'Correct!' - score = score + 1 - else - print 'Wrong,' capitals[i] 'in the capital of' countries[i] - print 'You scored ' score ' out of 10' - - ``` 17: story_text: |- ### Exercice Déboguez ce code. Bonne chance ! - example_code: | - **Attention ! Ce code doit être débuggé !** - ``` - define food_order - toppings = ask 'pepperoni, tuna, veggie or cheese?' - size = ask 'big, medium or small?' - number_of_pizza = ask 'How many these pizzas would you like?' - - print 'YOU ORDERED' - print number_of_pizzas ' size ' topping ' pizza' - - define drinks_order - drink = ask 'water, coke, icetea, lemonade or coffee?' - number_of_drinks = ask 'How many of these drinks would you like?' - - print 'YOU ORDERED' - print number_of_drinks ' ' drink - - 'Welcome to Hedy pizza' - more_food = ask 'Would you like to order a pizza?' - while more_food = 'yes' - return food_order - more_food = ask 'Would you like to order a pizza?' - more_drinks = ask 'Would you like to order some drinks?' - while more_drinks == 'yes' - call drink_order - more_drinks == ask 'Would you like to order more drinks?' - - - print 'Thanks for ordering!' - ``` - 18: - example_code: | - **Attention ! Ce code doit être débuggé !** - ``` - animals = ['pig', 'dog', 'cow'] - sounds = ['oink', 'woof', 'moo'] - for i in range 1 to 3 - animal = animals[i] - sound = sounds[i] - print 'Old MacDonald had a farm' - print 'E I E I O!' - print 'and on that farm he had a ' animal - print 'E I E I O!' - print 'with a ' sound sound ' here' - print 'and a ' sound sound ' there' - print 'here a ' sound - print 'there a ' sound - print 'everywhere a ' sound sound - ``` default: description: Explication du niveau levels: diff --git a/content/adventures/fr_CA.yaml b/content/adventures/fr_CA.yaml index 7f55c966d77..0ee497b09bb 100644 --- a/content/adventures/fr_CA.yaml +++ b/content/adventures/fr_CA.yaml @@ -532,20 +532,6 @@ adventures: description: Calculatrice 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: | ``` # Utilise ton code de l'aventure précédente. diff --git a/content/adventures/fy.yaml b/content/adventures/fy.yaml index d2f422d983b..86b58e423e5 100644 --- a/content/adventures/fy.yaml +++ b/content/adventures/fy.yaml @@ -1,577 +1,4 @@ adventures: - 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 in your 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. - story_text_2: | - ### Exercise - Can you make your own story in Hedy now by using `{print}` , `{ask}` and `{echo}`? - 2: - 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_2: | - The command `{add}` can also come in handy in your story. For example - story_text_3: | - This is an example of the `{remove}` command in your story - 5: - story_text: | - In this level you can program different endings, which will make your story even more fun. - - 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 'encounter 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}`. - 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! - 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. - 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: - 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!' - add_remove_command: - name: '{add} {to} & {remove} {from}' - 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. - 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. - and_or_command: - description: introducing and or - ask_command: - description: Introduction ask command - levels: - 1: - 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. - calculator: - levels: - 6: - story_text: | - Now that you can calculate, you can also create a program to practice maths calculations. You can make up the calculations yourself, for example: - example_code: | - ``` - correct_answer = 11 * 27 - answer = {ask} 'How much is 11 times 27?' - {if} answer {is} correct_answer {print} 'good job!' - {else} {print} 'Wrong! It was ' correct_answer - ``` - story_text_2: | - You can also let the computer do random calculations on its own using {random}. - example_code_2: | - ``` - tables = 4, 5, 6, 8 - numbers = 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 - table = tables {at} {random} - number = numbers {at} {random} - correct_answer = table * number - answer = {ask} 'how much is ' table ' times ' number '?' - {if} answer {is} correct_answer {print} 'okay' - {else} {print} 'mistake! it was ' correct_answer - ``` - 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`. - 11: - example_code: | - ``` - number = 10 - {for} i {in} {range} 1 to 10 - {print} i * number - ``` - 12: - story_text: | - Now you can make a calculator that works for decimal numbers. - example_code: | - ``` - number1 = {ask} 'What is the first number?' - number2 = {ask} 'What is the second number?' - answer = number1 + number2 - {print} number1 ' plus ' number2 ' is ' answer - 14: - 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 - clear_command: - description: clear command - debugging: - levels: - 3: - 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} - ``` - 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! - 8: - 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: - 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!' - {else} - 'I'm sorry we don't sell that' - topping {is} {ask} 'What kind of topping would you like?' - sauce {is} {ask} 'What kind of sauce would you like?' - {print} One chosen_bread with topping and sauce. - price = amount * 6 - {print} 'That will be 'price dollar' please' - ``` - - price = amount * 6 - {print} 'That will be 'price dollar' please' - 10: - example_code: | - **Warning! This code needs to be debugged!** - ``` - names = Muad Hasan Samira Noura - activities = fly a kite, go swimming, go hiking, catch tan in the sun - {for} name {is} names - {print} At the beach name loves to activity at random - ``` - 11: - story_text: |- - ### Exercise - Debug this calender program. The output of this program is supposed to look like a list of dates. - For example: - - ``` - Hedy calender - Here are all the days of November - November 1 - November 2 - November 3 - ``` - And so on. - - Mind that you have to test your code extra carefully for the month February, because the amount of days in this month changes in leap years. - example_code: | - **Warning! This code needs to be debugged!** - ``` - print 'Hedy calender' - months_with_31 days = January, March, May, July, September, October, December - months_with_30_days = April, June, August, November - month = ask 'Which month would you like to see?' - if month in months_with_31_days - days = 31 - if month in months_with30_days - days = 30 - if month = February - leap_years = 2020, 2024, 2028, 2036, 2040, 2044, 2028 - year = ask 'What year is it?' - if year in leap_years - days = 29 - else - days = 28 - - print 'Here are all the days of ' moth - for i in range 1 to days - print month i - ``` - 12: - example_code: | - **Warning! This code needs to be debugged!** - ``` - define greet - greetings = 'Hello', 'Hi there', 'Goodevening' - print greetings at random - - define take_order - food = ask 'What would you like to eat?' - print 'One food' - drink = 'What would you like to drink?' - print 'One ' drink - more = ask 'Would you like anything else?' - if more is 'no' - print 'Alright' - else - print 'And ' more - print 'Thank you' - - print 'Welcome to our restaurant' - people = ask 'How many people are in your party tonight?' - for i in range 0 to people - call greet_costumer - ``` - 13: - example_code: | - **Warning! This code needs to be debugged!** - ``` - defin movie_recommendation with name - action_movies == 'Die Hard', 'Fast and Furious', 'Inglorious Bastards' - romance_movies = 'Love Actually', 'The Notebook', 'Titanic' - comedy_movies = 'Mr Bean' 'Barbie''Deadpool' - kids_movies = 'Minions', 'Paddington', 'Encanto' - if name is 'Camila' or name is 'Manuel' - recommended_movie = kids_movie at random - if name is 'Pedro' or 'Gabriella' - mood = ask 'What you in the mood for?' - if mood is 'action' - recommended_movie = comedy_movies at random - if mood is 'romance' - recommended_movie = romance_movies - if mood is 'comedy' - recommended_movie = comedy_movies at random - - print 'I would recommend ' recommended_movie ' for ' name - - name = ask 'Who is watching?' - recommendation = ask 'Would you like a recommendation?' - if recommendaion is 'yes' - print movie_recommendation with name - else - print 'No problem!' - ``` - 14: - example_code: | - **Warning! This code needs to be debugged!** - ``` - define calculate_heartbeat - print 'Press your fingertips gently against the side of your neck' - print '(just under your jawline)' - print 'Count the number of beats you feel for 15 seconds' - beats == ask 'How many beats do you feel in 15 seconds?' - heartbeat = beats*4 - print 'Your heartbeat is ' heartbeat - if heartbeat >= 60 or heartbeat <= 100 - print 'Your heartbeat seems fine' - else - if heartbeat > 60 - print 'Your heartbeat seems to be too low' - if heartbeat < 100 - print 'Your heartbeat seems to be too high' - print 'You might want to contact a medical professional' - - measure_heartbeat = ask 'Would you like to measure your heartbeat?' - if measure_heartbeat = 'yes' - call measure_heartbeat - else - 'no problem' - ``` - - print '(just under your jawline)' - print 'Count the number of beats you feel for 15 seconds' - beats == ask 'How many beats do you feel in 15 seconds?' - heartbeat = beats*4 - print 'Your heartbeat is ' heartbeat - if heartbeat >= 60 or heartbeat <= 100 - print 'Your heartbeat seems fine' - else - if heartbeat > 60 - print 'Your heartbeat seems to be too low' - if heartbeat < 100 - print 'Your heartbeat seems to be too high' - print 'You might want to contact a medical professional' - - measure_heartbeat = ask 'Would you like to measure your heartbeat?' - if measure_heartbeat = 'yes' - call measure_heartbeat - else - 'no problem' - 15: - example_code: | - **Warning! This code needs to be debugged!** - ``` - names = 'Tanya', 'Romy', 'Kayla', 'Aldrin', 'Ali' - verbs='walking', 'skipping', 'cycling', 'driving', 'running' - locations = 'on a mountaintop', 'in the supermarket', 'to the swimming pool' - hiding_spots = 'behind a tree', under a table', in a box' - sounds = 'a trumpet', 'a car crash', 'thunder' - causes_of_noise = 'a television', 'a kid with firecrackers', 'a magic elephant', 'a dream' - - chosen_ name = names at random - chosen_verb = verbs at random - chosen_location = 'locations at random' - chosen_sounds = noises at random - chosen_spot = hiding_spots random - chosen_causes = causes_of_noise at random - - print chosen_name ' was ' chosen_verb ' ' chosen_location - print 'when they suddenly heard a sound like ' sounds at random - print chosen_name ' looked around, but they couldn't discover where the noise came from' - print chosen_name ' hid ' chosen_spot' - print 'They tried to look around, but couldn't see anything from there' - hidden = 'yes' - while hidden = 'yes' - print chosen_name 'still didn't see anything' - answer = ask 'does ' chosen_name ' move from their hiding spot?' - if answer = 'yes' - hidden == 'no' - print 'chosen_name moved from' chosen_spot - print 'And then they saw it was just' chosen_cause - print chosen_name 'laughed and went on with their day' - print The End - ``` - 16: - example_code: | - **Warning! This code needs to be debugged!** - ``` - country = ['The Netherlands', 'Poland', 'Turkey', 'Zimbabwe', 'Thailand', 'Brasil', 'Peru', 'Australia', 'India', 'Romania' ] - capitals = 'Amsterdam', 'Warshaw' 'Istanbul', 'Harare', 'Bangkok', 'Brasilia', 'Lima', 'Canberra', 'New Delhi', 'Bucharest' - score = 0 - for i in range 0 to 10 - answer = ask 'What's the capital of ' countries[i] - correct = capital[i] - if answer = correct - print 'Correct!' - score = score + 1 - else - print 'Wrong,' capitals[i] 'in the capital of' countries[i] - print 'You scored ' score ' out of 10' - - ``` - 17: - example_code: | - **Warning! This code needs to be debugged!** - ``` - define food_order - toppings = ask 'pepperoni, tuna, veggie or cheese?' - size = ask 'big, medium or small?' - number_of_pizza = ask 'How many these pizzas would you like?' - - print 'YOU ORDERED' - print number_of_pizzas ' size ' topping ' pizza' - - define drinks_order - drink = ask 'water, coke, icetea, lemonade or coffee?' - number_of_drinks = ask 'How many of these drinks would you like?' - - print 'YOU ORDERED' - print number_of_drinks ' ' drink - - 'Welcome to Hedy pizza' - more_food = ask 'Would you like to order a pizza?' - while more_food = 'yes' - return food_order - more_food = ask 'Would you like to order a pizza?' - more_drinks = ask 'Would you like to order some drinks?' - while more_drinks == 'yes' - call drink_order - more_drinks == ask 'Would you like to order more drinks?' - - - print 'Thanks for ordering!' - ``` - 18: - example_code: | - **Warning! This code needs to be debugged!** - ``` - animals = ['pig', 'dog', 'cow'] - sounds = ['oink', 'woof', 'moo'] - for i in range 1 to 3 - animal = animals[i] - sound = sounds[i] - print 'Old MacDonald had a farm' - print 'E I E I O!' - print 'and on that farm he had a ' animal - print 'E I E I O!' - print 'with a ' sound sound ' here' - print 'and a ' sound sound ' there' - print 'here a ' sound - print 'there a ' sound - print 'everywhere a ' sound sound - ``` default: levels: 1: @@ -677,1572 +104,30 @@ adventures: Kinst no meardere rigels tegearre werhelje. Dan moatst de rigel dytst werhelje wolst wol ynspringe, dat wol sizze dat se mei fjouwer spaasjes begjinne moatte. Ek atst mar ien rigel werhelje wolst, moatst ynspringe! - + example_code: | ``` repeat 5 times print 'Goeie allegearre' print 'Dit wurdt allegearre 5 keer werhelle' ``` - example_code: | - ``` - {repeat} 5 {times} - {print} 'Hello everyone' - {print} 'This is all repeated 5 times' - ``` - 10: - story_text: | - In dit level leren we een nieuwe code, de code `for`. Met `for` kun je alle dingen in een lijstje gebruiken. - `for` mag meerdere regels gebruiken, net zoals de `repeat` and `if`, dus alle regels eronder moeten met spaties beginnen. - - ``` - dieren is hond, kat, papegaai - for dier in dieren - print dier ' is een leuk dier!' - ``` - example_code: | - ``` - animals {is} dog, cat, blobfish - {for} animal {in} animals - {print} 'I love ' animal - ``` - 12: - story_text: | - So far, Hedy did not allow for decimal numbers like 1.5, but now we do allow that. Note that cmputers use the . for decimal numbers. - - For this level on you will also have to use quotation marks when storing a text with `is`: - - ``` - name = 'Hedy' - print 'Hello ' name - ``` - - For numbers, you do not use quotation marks in the `is`: - ``` - score = 25 - print 'You got ' score - ``` - example_code: | - ``` - {print} 'Two and a half plus two and a half is...' - {print} 2.5 + 2.5 - ``` - - print 2.5 + 2.5 13: story_text: We sille no `and` en `or` brûke. Ast 2 dingen kontroleare wolst, hoechst net mear 2 `if`-kes yninoar te dwaan, mar kinst no `and` brûke. Beide dingen yn 'e if moeten waar zijn als je een `and` gebruikt. We kunnen ek `or` brûke. Daarbij moet er 1 fan de twa waar zijn. - 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!' - ``` 14: story_text: |- We sille nije tekens leare, do kinst se miskien al fan rekkenjen as wiskunde: `<` en `>`. De `<` sjocht oft it earste getal lytser is as it twadde lykas `4 < 5`. De `>` sjocht oft eat grutter is as it twadde getal, lykas `6 > 5`. example_code: | ``` - age = {ask} 'How old are you?' - {if} age > 12 - {print} 'You are older than I am!' - ``` - if leeftyd < 13 print 'Dan bist jonger as ik!' else print 'Dan bist âlder as ik!' + ``` 15: story_text: 'No sille wy in nije lus leare: De `while`-lus. We gean troch sa lang de koade dy''t yn''e lus stiet `True` is. Dus bij de foarbyldkoade gean wy troch oant der in goed antwurd jûn is. As der nea in goed antwurd jûn wurdt, dan stoppet de lus nea!' - example_code: | - ``` - answer = 0 - while answer != 25 - answer = ask 'What is 5 times 5?' - print 'A correct answer has been given' - ``` 16: story_text: No sette wy fjouwerkante heakjes om listen. We moatte no ek inkele oanhellingstekens (') om dingen in listen sette. - example_code: | - ``` - friends = ['Ahmed', 'Ben', 'Cayden'] - {print} friends[1] ' is the first friend on the list.' - {print} friends[2] ' is the second friend on the list.' - {print} friends[3] ' is the third friend on the list.' - #now we will match 2 lists using the variable i - lucky_numbers = [15, 18, 6] - {for} i {in} {range} 1 {to} 3 - {print} friends[i] 's lucky number is ' lucky_numbers[i] - ``` 17: story_text: |- No feroarje wy noch in lyts stikje dat te dwaan hat mei it ynspringjen. Eltse kear dat wy ynspringe moatte wy in ':' der efter sette. - 18: - story_text: |- - We arrived at real Python code! That means we need to use parentheses with {print} and {range} from now on. - {print}('My name is ', naam) - dice: - levels: - 3: - example_code: | - ``` - choices {is} 1, 2, 3, 4, 5, earthworm - {print} choices {at} {random} - ``` - 4: - story_text: | - In this level we can make sentences with the die value in the sentence, with quotes of course. - This time the sample code is not quite complete. Can you finish the code? - 5: - story_text: | - You can also make a die again in this level using the `{if}`. - Complete the sample code so that the code says "You can stop throwing" once you have thrown an earthworm. - - But maybe you want to recreate a die from a completely different game. That's fine too! Then make up your own reaction. Eg 'yes' for 6 and 'pity' for something {else}. - example_code: | - ``` - choices {is} 1, 2, 3, 4, 5, earthworm - throw {is} _ - {print} 'you have' _ 'thrown' - {if} _ {is} earthworm {print} 'You can stop throwing.' _ {print} 'You have to hear it again!' - ``` - 6: - story_text: | - You can also make an Earthworm die again in this, but now you can also calculate how many points have been rolled. - You may know that the worm counts 5 points for Earthworms. Now after a roll you can immediately calculate how many points you have thrown. - This is the code to calculate points for one die: - example_code: | - ``` - choices = 1, 2, 3, 4, 5, earthworm - points = 0 - throw = choices {at} {random} - {print} 'you threw' throw - {if} throw {is} earthworm points = points + 5 {else} points = points + throw - {print} 'those are' points ' point' - ``` - Can you make the code so that you get the total score for 8 dice? To do that, you have to cut and paste some lines of the code. - example_code_2: | - Did you manage to calculate the score for 8 dice? That required a lot of cutting and pasting, right? We are going to make that easier in level 7! - 7: - story_text: | - You can also make a die again in level 5. With the `{repeat}` code you can easily roll a whole hand of dice. - Try to finish the sample code! The dashes should contain multiple commands and characters. - - But maybe you want to make a completely different die. Of course you can! - example_code: | - ``` - choices = 1, 2, 3, 4, 5, earthworm - {repeat} _ _ {print} _ _ _ - ``` - 10: - story_text: | - Is everybody taking too long throwing the dice? In this level you can let Hedy throw all the dice at once! - example_code: | - ``` - players = Ann, John, Jesse - choices = 1, 2, 3, 4, 5, 6 - {for} player {in} players - {print} player ' throws ' choices {at} {random} - {sleep} - ``` - dishes: - description: Use the computer to see who does the dishes (Start at level 2) - levels: - 3: - story_text: | - Do you always disagree at home about who should wash the dishes or change the litter box today? - Then you can let the computer choose very fairly. You can program that in this level! - You first make a list of the members of your family. Then choose '{at} {random}' from the list. - example_code: | - ``` - people {is} mom, dad, Emma, Sophie - {print} people {at} {random} - ``` - Don't feel like doing the dishes yourself? Hack the program to remove your name from the list. - - ``` - people {is} mom, dad, Emma, Sophie - your_name {is} {ask} Who are you? - {remove} your_name {from} people - {print} people {at} {random} does the dishes - ``` - story_text_2: | - Don't feel like doing the dishes yourself? Hack the program to remove your name from the list. - 4: - story_text: | - With quotation marks you can make your dishwashing planning more beautiful. - This time the sample code is not quite complete. - - Can you complete the code by filling the blanks? Every blank must be replaced with one word of symbol. - - Tip: Don't forget the quotation marks! - 5: - story_text: | - With the `{if}` you can now have more fun with choice in the program. You can have your program respond to the choice that the computer has made. - - Can you finish the code so that it prints 'too bad' when it is your turn and otherwise 'yes!'? - Don't forget the quotes! - example_code: | - ``` - people {is} mom, dad, Emma, Sophie - dishwasher {is} people {at} {random} - {if} dishwasher {is} Sophie {print} _ too bad I have to do the dishes _ {else} {print} 'luckily no dishes because' _ 'is already washing up' - ``` - 6: - story_text_2: | - If you are extremely unlucky the previous program might choose you to to the dishes for the whole week! That's not fair! - To create a fairer system you can use the `{remove}` command to remove the chosen person from the list. This way you don't have to do the dishes again untill everybody has had a turn. - - Monday and tuesday are ready for you! Can you add the rest of the week? - And... can you come up with a solution for when your list is empty? - example_code_2: | - ``` - people = mom, dad, Emma, Sophie - dishwasher = people {at} {random} - {print} 'Monday the dishes are done by: ' dishwasher - {remove} dishwasher {from} people - dishwasher = people {at} {random} - {print} 'Tuesday the dishes are done by: ' dishwasher - {remove} dishwasher {from} people - dishwasher = people {at} {random} - ``` - 7: - story_text: | - With the `{repeat}` you can repeat pieces of code. You can use this to calculate who will be washing dishes for the entire week. - example_code: | - ``` - people = mom, dad, Emma, Sophie - {repeat} _ _ {print} 'the dishwasher is' _ - ``` - 10: - story_text: | - In this level you could make an even better dish washing shedule. - elif_command: - description: elif - levels: - 17: - example_code: | - ``` - prices = ['1 million dollars', 'an apple pie', 'nothing'] - your_price = prices[{random}] - {print} 'You win ' your_price - {if} your_price == '1 million dollars' : - {print} 'Yeah! You are rich!' - {elif} your_price == 'an apple pie' : - {print} 'Lovely, an apple pie!' - {else}: - {print} 'Better luck next time..' - ``` - for_command: - description: for command - levels: - 11: - story_text: |- - In this level, we add a new form of the `{for}`. In earlier levels, we used `{for}` with a list, but we can also use `{for}` with numbers. - We do that by adding a variable name, followed by `{in}` `{range}`. We then write the number to start at, `{to}` and the number to end at. - Try the example to see what happens! In this level again, you will need to use indentations in lines below the `{for}` statements. - fortune: - levels: - 1: - story_text: | - Have you ever been to a carnival and had your future predicted by a fortune teller? Or have you ever played with a magic eight ball? - Then you probably know that they can't really predict your future, but it's still fun to play! - - In the upcoming levels you can learn how to create your own fortune telling machine! - In level 1 you can start off easy by letting Hedy introduce herself as a fortune teller and let her {echo} the players' answers. - Like this: - example_code: | - ``` - {print} Hello, I'm Hedy the fortune teller! - {ask} Who are you? - {print} Let me take a look in my crystal ball - {print} I see... I see... - {echo} Your name is - ``` - - ### Exercise - Hedy now only tells you your name. Can you expand the code so that Hedy can predict more things about you? - - Obviously, Hedy isn't a very good fortune teller yet, as she can only repeat the answers that were given by the players! - Take a look in level 2 to improve your fortune teller. - story_text_2: | - ### Exercise - Hedy now only tells you your name. Can you expand the code so that Hedy can predict more things about you? - Obviously, Hedy isn't a very good fortune teller yet, as she can only repeat the answers that were given by the players! - Take a look in level 2 to improve your fortune teller. - 3: - story_text: | - In the previous levels you've created your first fortune telling machine, but Hedy couldn't really predict anything, only {echo}. - In this level you can use a variable and the `{at} {random}` command to really let Hedy choose an answer for you. Check out this code for instance: - example_code: | - In this example the player can {ask} Hedy a yes-no question and Hedy will pick a random answer for you. - ``` - {print} I’m Hedy the fortune teller! - question {is} {ask} What do you want to know? - {print} This is what you want to know: question - answers {is} yes, no, maybe - {print} My crystal ball says... - {sleep} 2 - {print} answers {at} {random} - ``` - - ### Exercises - Now, Hedy can only answer yes, no or maybe. Can you give Hedy more answer options, like 'definitely' or '{ask} again'. - story_text_2: | - ### Exercises - Now, Hedy can only answer yes, no or maybe. Can you give Hedy more answer options, like 'definitely' or '{ask} again'. - 4: - example_code: | - ``` - {print} 'Im Hedy the fortune teller!' - question {is} {ask} 'What do you want to know?' - {print} 'This is your question: ' question - answers {is} yes, no, maybe - {print} 'My crystal ball says...' - {sleep} 2 - {print} answers {at} {random} - ``` - 5: - story_text: | - In this level you'll learn to (secretly) tip the odds in your favor, when using the fortune teller! - By using `{if}` and `{else}` you can make sure that you will always get a good fotune, while other people might not. - Check out this example to find out how. - example_code: | - ``` - {print} 'Im Hedy the fortune teller!' - {print} 'I can predict {if} youll win the lottery tomorrow!' - person {is} {ask} 'Who are you?' - {if} person {is} Hedy {print} 'You will definitely win!🤩' {else} {print} 'Bad luck! Someone {else} will win!😭' - ``` - 6: - story_text: | - In this level you can use math in your predictions as a fortune teller. This allows you to make up (silly) formulas to calculate the future. - For example you could calculate how rich you'll get or how many kids you will have when you grow up. - example_code: | - ``` - {print} 'I am Hedy the fortune teller!' - {print} 'I can predict how many kids youll get when you grow up!' - age = {ask} 'How old are you?' - siblings = {ask} 'How many siblings do you have?' - length = {ask} 'How tall are you in centimetres?' - kids = length / age - kids = kids - siblings - {print} 'You will get ...' - {sleep} - {print} kids ' kids!' - ``` - - If the previous example wasn't silly enough for you, take a look at this one! - - ``` - {print} 'Im Hedy the silly fortune teller!' - {print} 'I will predict how smart you are!' - football = {ask} 'On a scale 1-10 how much do you love football?' - bananas = {ask} 'How many bananas did you eat this week?' - hygiene = {ask} 'How many times did you wash your hands today?' - result = bananas + hygiene - result = result * football - {print} 'You are ' result ' percent smart.' - ``` - 7: - story_text: | - In this level you can use the `{repeat}` command to make your machine tell multiple fortunes at once. - example_code: | - ``` - {print} 'Im Hedy the fortune teller!' - {print} 'You can {ask} 3 questions!' - {repeat} 3 {times} question = {ask} 'What do you want to know?' - answer = yes, no, maybe - {repeat} 3 {times} {print} 'My crystal ball says... ' answer {at} {random} - ``` - - ### Exercise - As you can see, the questions aren't printed in this example. That's because the variable `question` was changed 3 times. - Every time the player fills in the new answer, Hedy overwrites the previous one, so the first answer the player gave is forgotten. - This means you can't print all the questions this way. - - By using 3 different variables instead of 1 (for example `question1` , `question2` and `question3`), you could solve the problem and print the questions. - This does mean that you can only use `{repeat}` for the answers, and you will have to ask and print all the questions separately. - Can you do it? - - In the upcoming levels the layout of {repeat} command will change, which enables you to repeat multiple lines at once. - 8: - story_text: | - In the previous levels you've learned how to use repeat to make the fortune teller answer 3 questions in a row, but we had a problem with printing the questions. - Now that problem is solved, because of the new way of using the repeat command. - In the next example you can have your fortune teller {ask} 3 questions and also print them! - example_code: | - ``` - {print} 'I am Hedy the fortune teller!' - {print} 'You can {ask} me 3 questions.' - answers = yes, no, maybe - {repeat} 3 {times} - question = {ask} 'What do you want to know?' - {print} question - {sleep} - {print} 'My crystal ball says...' answers {at} {random} - ``` - 10: - story_text: | - In this level you'll learn how to program the game MASH (mansion, apartement, shack, house). In this game you can predict for all the players at once, what their future will look like. - example_code: | - ``` - houses = mansion, apartment, shack, house - loves = nobody, a royal, their neighbour, their true love - pets = dog, cat, elephant - names = Jenna, Ryan, Jim - {for} name {in} names - {print} name ' lives in a ' houses {at} {random} - {print} name ' will marry ' loves {at} {random} - {print} name ' will get a ' pets {at} {random} ' as their pet.' - {sleep} - ``` - 12: - story_text: | - In this level you can make your fortunes multiple words. Like in this example below: - example_code: | - ``` - fortunes = 'you will be rich', 'you will fall in love', 'you will slip on a banana peel' - {print} 'I will take a look in my crystall ball for your future.' - {print} 'I see... I see...' - {sleep} - {print} fortunes {at} {random} - ``` - functions: - levels: - 12: - example_code: | - ``` - sides = 'left', 'right' - limbs = 'hand', 'foot' - colors = 'red', 'blue', 'green', 'yellow' - - {define} turn - chosen_side = sides {at} {random} - chosen_limb = limbs _ - chosen_color = colors _ - {print} chosen_side ' ' chosen_limb ' on ' chosen_color - - {print} 'Lets play a game of Twister!' - {for} i {in} {range} 1 to _ - {call} turn - {sleep} 2 - ``` - 13: - story_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. - - For example in this code we've programmed the first verse of the song 'My Bonnie is over the ocean'. - In this example code the argument `place` is used. Place is a variable that is only used in the function, so an argument. - To use `place` we have programmed the line `define song with place`. - When the function is called, computer will replace the argument `place`, with the piece of text after `call song with`. - - ### Exercise - The next verse of this song goes: - - Last night as I lay on my pillow - Last night as I lay on my bed - Last night as I lay on my pillow - I dreamed that my Bonnie is dead - - Can you program this verse in the same way as the example? - 14: - example_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?' - - new_price = _ calculate_new_price {with} old_price, _ - {print} 'The new price is ' new_price ' dollar' - ``` - haunted: - description: escape from the haunted house - levels: - 1: - story_text: | - In this adventure you are working towards making a game in which you have to escape from a haunted house by picking the correct door. - If you pick the right door you'll survive, but {if} not a terrible monster might... - - In level 1 we start our haunted house game by making up a scary story and {ask} the player what monster they'll see in the haunted house. - story_text_2: | - ### Exercise - Can you finish the scary story? Or make up your own haunted house story? - 2: - story_text: | - In this haunted house you can choose your monsters with emojis. Of course you could also use words. - - ``` - monster1 {is} 👻 - monster2 {is} 🤡 - monster3 {is} 👶 - {print} You enter the haunted house. - {print} Suddenly you see a monster1 - {print} You run into the other room, but a monster2 is waiting there for you! - {print} Oh no! Quickly get to the kitchen. - {print} But as you enter monster3 attacks you! - ``` - example_code: | - ``` - monster_1 {is} 👻 - monster_2 {is} 🤡 - monster_3 {is} 👶 - {print} You enter the haunted house. - {print} Suddenly you see a monster_1 - {print} You run into the other room, but a monster_2 is waiting there for you! - {print} Oh no! Quickly get to the kitchen. - {print} But as you enter monster_3 attacks you! - ``` - example_code_2: | - ``` - monster_1 {is} _ - monster_2 {is} _ - monster_3 {is} _ - {print} You enter the haunted house. - {print} Suddenly you see a monster_1 - {print} You run into the other room, but a monster_2 is waiting there for you! - {print} Oh no! Quickly get to the kitchen. - {print} But as you enter monster_3 attacks you! - ``` - 3: - story_text: | - In the previous levels you've made an introduction to your haunted house game, but as you might have noticed the story would always have a dreadful end. - In this level you can make your story more interactive by changing the outcome of the game; sometimes you'll get eaten, sometimes you'll escape! - Let Hedy decide randomly! - 4: - story_text: | - In this level you learn how to use quotation marks in your games. - Can you make your Haunted House level 4 proof? - example_code: | - ``` - {print} _Escape from the haunted house!_ - {print} _There are 3 doors in front of you..._ - choice {is} {ask} _Which door do you choose?_ - {print} _You picked door ..._ choice - monsters {is} a zombie, a vampire, NOTHING YOUVE ESCAPED - {print} _You see..._ - {sleep} - {print} monsters {at} {random} - ``` - 5: - story_text: | - Up until this level the haunted house game always asked the player to choose a door, but as you might have noticed, they didn't really have to answer correctly. - If the player filled in a completely random answer, the game would still work and the player might even win (despite not picking a door). - In this level you can only win the game by picking the same door Hedy picked randomly. - example_code: | - ``` - {print} 'Escape from the haunted house!' - {print} 'There are 3 doors in front of you...' - doors {is} 1, 2, 3 - monsters {is} werewolf, mummy, vampire, zombie - chosen_door {is} {ask} 'Which door do you choose?' - {print} 'You chose door...' chosen_door - {sleep} - correct_door {is} doors {at} {random} - {if} chosen_door {is} correct_door {print} 'Great! Youve escaped!' - {else} {print} 'Oh no! You are being eaten by a...' monsters {at} {random} - ``` - 9: - story_text: | - In this level you can use nesting, which allows you to make the haunted house even more interactive! - example_code: | - ``` - {print} 'Escape from the Haunted House!' - player = alive - doors = 1, 2, 3 - monsters = zombie, vampire, giant spider - {repeat} 3 {times} - {if} player {is} alive - correct_door {is} doors {at} {random} - {print} 'There are 3 doors in front of you...' - chosen_door = {ask} 'Which door do you choose?' - {if} chosen_door {is} correct_door - {print} 'No monsters here!' - {else} - {print} 'You are eaten by a ' monsters {at} {random} - player = dead - {else} - {print} 'GAME OVER' - {if} player {is} alive - {print} 'Great! You survived!' - ``` - ### Exercise - Now it's very hard to win this game, can you make it easier to win? - For example by only having 1 wrong door and 2 correct doors instead of 1 correct door en 2 wrong ones? - 11: - story_text: | - In this level we've changed the repeat command and we've added a line to our haunted house that tells the player in which room they are. - example_code: | - ``` - {print} 'Escape from the Haunted House!' - player {is} alive - doors = 1, 2, 3 - monsters = zombie, vampire, giant spider - {for} i {in} {range} 1 {to} 3 - {if} player {is} alive - correct_door = doors {at} {random} - {print} 'Room ' i - {print} 'There are 3 doors in front of you...' - chosendoor = {ask} 'Which door do you choose?' - {if} chosendoor {is} correct_door - {print} 'No monsters here!' - {else} - {print} 'You are eaten by a ' monsters {at} {random} - player = dead - {else} - {print} 'GAME OVER' - {if} player {is} alive - {print} 'Great! You survived!' - ``` - if_command: - description: Introducing the if command - levels: - 9: - story_text: | - In this level you can also put an {if} command inside another {if} command. - in_command: - description: Introducing the in command - levels: - 5: - example_code_2: | - ``` - animals is dog, cow, sheep - answer is ask 'What is your favorite animal?' - _ answer _ animals _ 'Mine too!' - _ _ 'My favorite animals are dogs, cows and sheep' - ``` - is_command: - description: introducing is command - levels: - 2: - story_text_2: | - ### Exercise - Time to make your own variables! - In the example code we made an example of the variable `favorite_animal`. In line 1 the variable is set, and in line 2 we haved used the variable in a print command. - Firstly, finish our example by filling in your favorite animal on the blank. Then make at least 3 of these codes yourself. Pick a variable, and set the variable with the {is} command. Then use it with a {print} command, just like we did. - 14: - example_code: | - ``` - age = {ask} 'How old are you?' - {if} age > 12 - {print} 'You are older than I am!' - ``` - example_code_3: | - ``` - name = {ask} 'What is your name?' - {if} name != 'Hedy' - {print} 'You are not Hedy' - ``` - - {if} age < 13 - {print} 'You are younger than me!' - {else} - {print} 'You are older than me!' - language: - default_save_name: language - levels: - 5: - story_text: | - Make your own program to practice your vocabulary in a new language. - - ``` - {print} 'Learn French!' - cat {is} {ask} '🐱' - {if} cat {is} chat {print} 'Terrific!' - {else} {print} 'No, cat is chat' - frog {is} {ask} '🐸' - {if} frog {is} grenouille {print} 'Super!' - {else} {print} 'No, frog is grenouille' - ``` - maths: - levels: - 6: - example_code: | - ``` - {print} '5 plus 5 is ' 5 + 5 - {print} '5 minus 5 is ' 5 - 5 - {print} '5 times 5 is ' 5 * 5 - ``` - 12: - example_code_2: | - ``` - a = 'Hello ' - b = 'world!' - {print} a + b - ``` - - {print} 2.5 + 2.5 - music: - levels: - 6: - story_text: "Instead of playing notes, you can also play numbers now. Simply type `{play} 1` for the lowest note, `{play} 70` for the highest note, or anything in between.\n\n### Exercise\n This calls for musical maths! Try out the example code a couple of times with different starting numbers. \nThen, see if you can compose a song using the numbers.\n" - parrot: - levels: - 1: - story_text_2: | - ### Exercise - Can you make the parrot ask a different question? Fill in the blanks in the example! - 2: - story_text: | - Create your own online pet parrot that will copy you! - example_code: | - ``` - {print} Im Hedy the parrot - name {is} {ask} whats your name? - {print} name - {sleep} - {print} squawk - {sleep} - {print} name - ``` - story_text_2: | - ### Exercise - You can use variables to make the parrot say more than only your name. Can you complete this code? - 3: - story_text: | - Teach your parrot a new word with `{add}`. - example_code: | - ``` - words {is} squawk, Hedy - {print} Train your parrot! - new_word {is} {ask} Which word do you want to teach them? - {add} new_word {to_list} words - {print} 🧒 Say new_word , Hedy! - {print} 🦜 words {at} {random} - ``` - 4: - story_text: | - In this level we have to use quotation marks with the commands `{ask}` and `{print}`. - Can you complete the code by adding quotation marks? - 5: - story_text: | - Reward your parrot {if} it says the correct word! - example_code: | - ``` - words {is} squawk, Hedy - {print} 'Train your parrot!' - new_word {is} {ask} 'Which word do you want to teach them?' - {add} new_word {to_list} words - said_word {is} words {at} {random} - {print} '🧒 Say ' new_word ', Hedy!' - {print} '🦜 ' said_word - {if} said_word {is} new_word {print} '🧒 Great job, Hedy! 🍪' - {else} {print} '🧒 No, Hedy! Say ' new_word - ``` - piggybank: - levels: - 12: - story_text: | - In this adventure you learn how to make a digital piggy bank, to calculate how much money you have and how long you need to save up to buy what you want! - example_code: | - ``` - {print} 'The digital piggy bank' - wish = {ask} 'What would you like to buy?' - price = {ask} 'How much does that cost?' - saved = {ask} 'How much money have you saved already?' - allowance = {ask} 'How much pocket money do you get per week?' - to_save = price - saved - weeks = to_save / allowance - {print} 'You can buy a ' wish ' in ' weeks ' weeks.' - 14: - example_code: | - ``` - _ calculate_budget with wish, money, allowance - to_save = wish - money - weeks = to_save / allowance - {if} wish _ money - {print} 'You need to save up some more!' - {print} 'Youll need ' weeks ' more weeks.' - {else} - {print} 'Great! You have enough' - {print} 'Lets go shopping!' - - money = {ask} 'How much money have you saved?' - wish = {ask} 'How much money do you need?' - allowance = {ask} 'How much pocket money do you get each week?' - - {call} calculate_budget with _, _, _ - ``` - pressit: - levels: - 9: - story_text: | - Now that you know how to combine statements, you can create a touch type tool with `{pressed}`. - - ### Exercise - Finish the code. Each time a random letter should be chosen, which you have to press. You get a point for a correct press, and and two points deduction for a wrong press. - **(extra)** Clear the screen after each letter, and show the user how many points they have scored. - print_command: - levels: - 18: - example_code_2: | - ``` - temperature = 25 - {print}('It is ', temperature, ' degrees outside') - ``` - - {print}('My name is ', name) - random_command: - levels: - 16: - story_text: |- - We are going to make lists the Python way, with square brackets around the lists! We also keep the quotation marks around each item like we have learned in previous levels. - We use square brackets to point out a place in a list. For example: `friends[1]` is the first name on the list of friends, as you can see in the first part of the example code. The second part of the example code shows you that we can also match 2 lists using the variable i. - repeat_command: - description: repeat command - levels: - 7: - story_text: | - ## Repeat! Repeat! Repeat! - Level 7 adds the `{repeat}` command. `{repeat}` can be used to execute one line of code multiple times. Like this: - - ### Exercise - Play around with the repeat command. Can you make the happy birthday song in only 3 lines of code instead of 4 now? - 9: - story_text: | - Great job! You've reached another new level! In the previous level you've learned to use multiple lines of code in an {if} or {repeat} command. But you can't yet combine the two... - Good news! In this level you will be allowed to put an {if} inside an {if}, or inside a {repeat} command. Putting a block of code inside another block of code is called nesting. ``` Putting a block of code inside another block of code is called nesting. - example_code: | - ``` - answer = {ask} 'Are you ready to learn something new?' - {if} answer {is} yes - {print} 'Great! You can learn to use the repeat command in the if command!' - {print} 'Hooray!' - {print} 'Hooray!' - {print} 'Hooray!' - {else} - {print} 'Maybe you should practice some more in the previous level' - repeat_command_2: - description: repeat command 2 - levels: - 7: - story_text_2: | - Another interesting thing you can so with the `{repeat}` command is using variables to set the amount of times something should be repeated. In the example code you can see that we first ask the person how old they are. - Then, in line 3, the question is repeated 'age' times. So we have used the variable 'age' with the `{repeat}` command. - restaurant: - levels: - 1: - story_text_2: | - ### Exercise - Can you think of more lines to add to your restaurant code? For example, can you {ask} the guests what they'd like to drink, tell them the price, or wish them a pleasant meal? - 2: - story_text: | - In level 2 you could expand your restaurant by using variables. In level 1 Hedy could only {echo} the order once and only remember the last thing that was ordered. - Now you can use variables and Hedy can remember both the food and the drinks! - example_code: | - ``` - {print} Welcome to Hedy's restaurant! - {print} Today we're serving pizza or lasagna. - food {is} {ask} What would you like to eat? - {print} Great choice! The food is my favorite! - topping {is} {ask} Would you like meat or veggies on that? - {print} food with topping is on its way! - drinks {is} {ask} What would you like to drink with that? - {print} Thank you for your order. - {print} Your food and drinks will be right there! - ``` - story_text_2: | - ### Exercise - Can you make this code more elaborate? For example by adding drinks to the order? Or...? - 3: - example_code: | - ``` - {print} Welcome to Hedy's Random Restaurant! - {print} The only restaurant that will randomly choose your meal and its price for you! - starters {is} salad, soup, carpaccio - mains {is} pizza, brussels sprouts, spaghetti - desserts {is} brownies, ice cream, french cheeses - drinks {is} cola, beer, water - prices {is} 1 dollar, 10 dollars, 100 dollars - {print} You will start with: starters {at} {random} - {print} Then we'll serve: mains {at} {random} - {print} And as dessert: desserts {at} {random} - {print} You will get a drinks {at} {random} to drink - {print} That will be: prices {at} {random} - {print} Thank you and enjoy your meal! - ``` - story_text_2: | - Does your costumer have any allergies or do they dislike certain dishes? Then you can use the `{remove}`command to remove it from your menu. - example_code_2: | - ``` - {print} Mystery milkshake - flavors {is} strawberry, chocolate, vanilla - allergies {is} {ask} Are you allergic to any falvors? - {remove} allergies {from} flavors - {print} You get a flavors {at} {random} milkshake - ``` - 4: - story_text: | - ### Exercise - Add the quotation marks to this code to make it work! Be careful: variables should not be in quotation marks. - Then, use the `{clear}` command to only show one line at a time in your output screen. - - ### Exercise 2 - Go back to the previous level and copy your restaurant code. Make the code work in this level by adding quotation marks in the right spots and add some `{clear}` commands. - 5: - story_text: | - In this level the {if} command allows you to {ask} your customers questions and give different responses to the answers. - In the example below, you see that you can {ask} the customer {if} they want to hear the specials and Hedy can respond accordingly. - example_code: | - ``` - {print} 'Welcome to Hedys restaurant!' - special {is} {ask} 'Would you like to hear our specials today?' - {if} special {is} yes {print} 'Todays special is chicken piri piri and rice.' {else} {print} 'No problem.' - food {is} {ask} 'What would you like to eat?' - {print} 'One ' food ', coming right up!' - drink {is} {ask} 'What would you like to drink with that?' - {if} drink {is} cola {print} 'Im sorry, we are out of cola!' {else} {print} 'Great choice!' - anything {is} {ask} 'Would you like anything {else}?' - {print} 'Let me repeat your order...' - {print} 'One ' food - {if} drink {is} cola {print} 'and...' {else} {print} 'One ' drink - {if} anything {is} no {print} 'Thats it!' {else} {print} 'One ' anything - {print} 'Thank you for your order and enjoy your meal!' - ``` - - ### Exercise - Can you think of more questions to {ask} the customers when they are ordering, and make up different responses to their answers by using the {if} command? - 6: - story_text: | - In this level you can use maths to calculate the total price of your customer's order, which can make your virtual restaurant more realistic. - example_code: | - You can make a simple restaurant code, like this: - ``` - {print} 'Welcome to Hedys restaurant' - {print} 'Here is our menu:' - {print} 'Our main courses are pizza, lasagne, or spaghetti' - main = {ask} 'Which main course would you like?' - price = 0 - {if} main {is} pizza price = 10 - {if} main {is} lasagne price = 12 - {if} main {is} spaghetti price = 8 - {print} 'You have ordered ' main - {print} 'That will be ' price ' dollars, please' - {print} 'Thank you, enjoy your meal!' - ``` - 7: - story_text: | - In this level you've learned how to use the {repeat} command to repeat a line of code a certain amount of times. - You can use that in your restaurant to {ask} multiple people what they'd like to eat. Like this: - - ``` - {print} 'Welcome to Hedys restaurant!' - people = {ask} 'How many people are joining us today?' - {repeat} people times food = {ask} 'What would you like to eat?' - {print} 'Thanks for your order! Its coming right up!' - ``` - example_code: | - ``` - {print} 'Welcome to Hedys restaurant!' - people = {ask} 'How many people are joining us today?' - {repeat} people times food = {ask} 'What would you like to eat?' - {print} 'Thanks for your order! Its coming right up!' - ``` - 9: - story_text: | - In this level you can use nesting to make your restaurant more realistic and more fun! - For example you would {ask} for sauce {if} somebody orders fries, but you wouldn't {if} someone orders pizza! - Check out the example, and try this at your own virtual restaurant! - example_code: | - ``` - {print} 'Welcome to Hedys restaurant!' - people = {ask} 'How many people will be joining us today?' - {print} 'Great!' - price = 0 - {repeat} people {times} - food = {ask} 'What would you like to order?' - {print} food - {if} food {is} fries - price = price + 3 - sauce = {ask} 'What kind of sauce would you like with your fries?' - {if} sauce {is} no - {print} 'no sauce' - {else} - price = price + 1 - {print} 'with ' sauce - {if} food {is} pizza - price = price + 4 - {print} 'That will be ' price ' dollar' - {print} 'Enjoy your meal!' - ``` - 10: - story_text: | - In this level you'll learn how to easily {ask} your guests' orders in a short code. - example_code: | - ``` - courses = appetizer, main course, dessert - {for} course {in} courses - food = {ask} 'What would you like to eat as your ' course '?' - {print} food ' will be your ' course - ``` - story_text_2: | - Of course, you could also order for multiple people! - example_code_2: | - ``` - courses = appetizer, main course, dessert - names = Timon, Onno - {for} name {in} names - {for} course {in} courses - food = {ask} name ', what would you like to eat as your ' course '?' - {print} name ' orders ' food ' as their ' course - ``` - 11: - story_text: | - We can use the `{for} i {in} {range} 1 {to} 5` to {print} the orders from multiple customers in an orderly manner. - example_code: | - ``` - {print} 'Welcome to Restaurant Hedy!' - people = {ask} 'For how many people would you like to order?' - {for} i {in} {range} 1 {to} people - {print} 'Order number ' i - food = {ask} 'What would you like to eat?' - {print} food - {if} food {is} fries - sauce = {ask} 'What kind of sauce would you like with that?' - {print} sauce - drinks = {ask} 'What would you like to drink?' - {print} drinks - price = 4 * people - {print} 'That will be ' price ' dollars, please!' - ``` - 12: - story_text: | - From this level on you can use decimal numbers to make you menu more realistic. - example_code: | - ``` - price = 0 - food = {ask} 'What would you like to order?' - drink = {ask} 'What would you like to drink?' - {if} food {is} 'hamburger' - price = price + 6.50 - {if} food {is} 'pizza' - price = price + 5.75 - {if} drink {is} 'water' - price = price + 1.20 - {if} drink {is} 'soda' - price = price + 2.35 - {print} 'That will be ' price ' dollar, please' - ``` - 13: - story_text: | - In this level we can use the new commands to upgrade our restaurant. - We use `{and}` to see {if} two things are both the case. - example_code: | - ``` - price = 10 - food = {ask} 'What would you like to eat?' - drinks = {ask} 'What would you like to drink?' - {if} food {is} 'sandwich' {and} drinks {is} 'juice' - {print} 'Thats our discount menu' - price = price - 3 - {print} 'That will be ' price ' dollars' - ``` - rock: - default_save_name: Rock - levels: - 2: - story_text: | - In this level you can practise using the variables, so that you can make the rock, paper, scissors game in the next level! - example_code: | - ``` - choice {is} _ - {print} I choose choice - ``` - 3: - story_text_2: | - ### Exercise - Now you only have one player, so can you add a second player? - You can even use variables to name player 1 and player 2. - example_code_2: | - ``` - choices {is} rock, paper, scissors - {print} player 1 chooses... choices {at} {random} - {print} player 2 _ - ``` - 5: - story_text: | - In this level we can determine who won. - For that you need the new `{if}` code. - - Save your choice with the name of choice and the choice of computer as computer choice. - Then you can use `{if}` to see {if} they are the same or different. - Will you finish the code? - example_code: | - ``` - options {is} rock, paper, scissors - computer_choice {is} _ - choice {is} {ask} What do you choose? - {print} 'you chose ' _ - {print} 'computer chose ' _ - {if} _ {is} _ {print} 'tie!' {else} {print} 'no tie' - ``` - - Fill in the correct code on the blanks to see {if} it is a draw. - 9: - story_text: | - In this level you can program the whole rock, paper, scissors game by nesting the {if}-commands. Can you finish the code? - example_code: | - ``` - choices = rock, paper, scissors - your_choice = {ask} 'What do you choose?' - {print} 'You choose ' your_choice - computer_choice = choices {at} {random} - {print} 'The computer chooses ' computer_choice - {if} computer_choice {is} your_choice - {print} 'Tie' - {if} computer_choice {is} rock - {if} your_choice {is} paper - {print} 'You win!' - {if} your_choice {is} scissors - {print} 'You lose!' - # finish this code - ``` - 10: - story_text: | - Feeling too lazy to play the game yourself? Let Hedy play it for you! - example_code: | - ``` - choices = rock, paper, scissors - players = Marleen, Michael - {for} player {in} players - {print} player ' chooses ' choices {at} {random} - ``` - 13: - story_text: | - With the `{and}` command you can shorten your rock, paper, scissors code! Check out the example code below and try to finish it. - example_code: | - ``` - options = 'rock', 'paper', 'scissors' - your_choice = {ask} 'What do you choose?' - computer_choice = options {at} {random} - {print} 'You choose ' your_choice - {print} 'The computer chooses ' computer_choice - {if} computer_choice {is} your_choice - {print} 'Tie' - {if} computer_choice {is} 'rock' {and} your_choice {is} 'paper' - {print} 'You win!' - {if} computer_choice {is} 'rock' {and} your_choice {is} 'scissors' - {print} 'The computer wins!' - ``` - 15: - example_code: | - ``` - won = 'no' - options = 'rock', 'paper', 'scissors' - {while} won == 'no' - your_choice = {ask} 'What do you choose?' - computer_choice = options {at} {random} - {print} 'you chose ' your_choice - {print} 'the computer chose ' computer_choice - {if} computer_choice == your_choice - {print} 'Tie!' - {if} computer_choice == 'rock' {and} your_choice == 'scissors' - {print} 'You lose!' - {if} computer_choice == 'rock' {and} your_choice == 'paper' - {print} 'You win!' - won = 'yes' - rock_2: - levels: - 2: - story_text: | - Now that you have learned how to use the `{ask} command, you can make your rock, paper, scissors code interavtive too! - - ### Exercise - Make the rock, paper, scissors code interactive by adding the `{ask}` command and a question to your rock, paper, scissors code. - example_code: | - ``` - choice is _ - {print} I choose choice - ``` - secret: - default_save_name: language - levels: - 12: - story_text: | - In this adventure you can create your own super spy code. Encode a message that only the right agent can decipher. - If the enemy tries to crack the code, they will get some false info to waste their time. - example_code: | - ``` - name {is} {ask} 'What is your name?' - {if} name {is} '_' - a {is} 'Go to the airport ' - {else} - a {is} 'Go to the trainstation ' - password {is} {ask} 'What is the password?' - {if} password {is} _ - b {is} 'tomorrow at 02.00' - {else} - b {is} 'today at 10.00' - {print} _ _ _ - ``` - 13: - story_text: | - The code you made in the previous level can be made a lot easier in this one with the `{and}` command. - sleep_command: - description: introducing sleep command - levels: - 2: - story_text: | - ## The sleep command - Another new command in this level is `{sleep}`, which pauses your program for a second. If you type a number behind the {sleep} command, the program pauses for that amount of seconds. - songs: - levels: - 6: - story_text: | - Songs often contain a lot of repetition. Sometimes the repetition is also based on counting. - For example, in the well-known song 'Bottles of beer'. You can program that song with a little math. - example_code: | - ``` - verse = 99 - {print} verse ' bottles of beer on the wall' - {print} verse ' bottles of beer' - {print} 'Take one down, pass it around' - verse = verse - 1 - {print} verse ' bottles of beer on the wall' - ``` - - You can now repeat lines 2 to 9 as many times as you want by copying the lines. - example_code_2: | - ``` - number = 6 - number = number - 1 - print number ' little monkeys jumping on the bed' - print 'One fell off and bumped his head' - print 'Mama called the doctor and the doctor said' - print 'NO MORE MONKEYS JUMPING ON THE BED!' - sleep - ``` - 7: - story_text: | - Songs often contain a lot of repetition. For example... Baby Shark! If you sing it, you keep singing the same thing: - - Baby Shark tututudutudu
- Baby Shark tututudutudu
- Baby Shark tututudutudu
- Baby Shark - - You can make this song much shorter with a `{repeat}`! Can you finish the code? - example_code: | - ``` - {repeat} _ _ {print} 'Baby Shark tututudutudu' - {print} 'Baby Shark' - ``` - - After Baby Shark you can of course also program other songs. There are many songs with repetition. - 8: - story_text: | - In a previous level you've programmed the song 'Bottles of beer'. You made one verse and then had to copy the verses 99 times. In level 7 you can repeat the song 99 times, just by adding one simple line! - example_code: | - ``` - verse = 99 - {repeat} 99 {times} - {print} verse ' bottles of beer on the wall' - {print} verse ' bottles of beer' - {print} 'Take one down, pass it around' - verse = verse - 1 - {print} verse ' bottles of beer on the wall' - ``` - 10: - story_text: | - In this level you can easily make the childrens' song 'Five little monkeys'. Can you make the last chorus? - You can also make the whole baby shark song (including all the other sharks in the family) in only 6 lines! - Or you can make Old MacDonald with all the different animals. - example_code: | - ``` - monkeys = 5, 4, 3, 2 - {for} monkey {in} monkeys - {print} monkey ' little monkeys jumping on the bed' - {print} 'One fell off and bumped his head' - {print} 'Mama called the doctor and the doctor said' - {print} 'NO MORE MONKEYS JUMPING ON THE BED!' - ``` - - ``` - sharks = baby, mommy, daddy, grandma, grandpa - {for} shark {in} sharks - {print} shark 'tututututudu' - {print} shark 'tututututudu' - {print} shark 'tututututudu' - {print} shark - ``` - ``` - animals = pig, dog, cow - {for} animal {in} animals - {if} animal {is} pig - sound = oink - {if} animal {is} dog - sound = woof - {if} animal {is} cow - sound = moo - {print} 'Old MacDonald had a farm' - {print} 'E I E I O!' - {print} 'and on that farm he had a ' animal - {print} 'E I E I O!' - {print} 'with a ' sound sound ' here' - {print} 'and a ' sound sound ' there' - {print} 'here a ' sound - {print} 'there a ' sound - {print} 'everywhere a ' sound sound - ``` - story_text_2: | - ### Exercise 2 - Print the song Five little moneys jumping on the bed. Look up the text if you don't remember. - - **(extra)** Print the song Old MacDonald had a farm, and make sure all animals make a different sound, using an `{if}`. - 11: - story_text: | - In this level you can use the `{for} i {in} {range}` command to make songs that use counting. - example_code: | - ``` - {for} i {in} {range} 5 {to} 1 - {print} i ' little monkeys jumping on the bed' - {print} 'One fell off and bumped his head' - {print} 'Mama called the doctor and the doctor said' - {if} i {is} 1 - {print} 'PUT THOSE MONKEYS RIGHT TO BED!' - {else} - {print} 'NO MORE MONKEYS JUMPING ON THE BED!' - ``` - 12: - story_text: | - In this song we can make it even easier to program '{if} you're happy and you know it, clap your hands'. Because we can put all of the actions in a variable, check it out: - example_code: | - ``` - actions = 'clap your hands', 'stomp your feet', 'shout Hurray!' - {for} action {in} actions - {for} i {in} {range} 1 {to} 2 - {print} '{if} youre happy and you know it' - {print} action - {print} '{if} youre happy and you know it and you really want to show it' - {print} '{if} youre happy and you know it' - {print} action - ``` - 16: - story_text: | - In this level, you can program a song like OldMacDonald even more quickly. You can connect the right animal to the right sound by simply putting them in the same place in the list. - The Drunken Sailor is also quickly made in this level. You only need 8 lines for the entire song, check it out! - - ### Exercise - Complete the Old MacDonald song by setting the variable `animal` to `animals[i]` and `sound` to `sounds[i]`. - - ``` - animals = ['pig', 'dog', 'cow'] - sounds = ['oink', 'woof', 'moo'] - {for} i {in} {range} 1 {to} 3 - animal = _ - sound = _ - {print} 'Old MacDonald had a farm' - {print} 'E I E I O!' - {print} 'and on that farm he had a ' animal - {print} 'E I E I O!' - {print} 'with a ' sound sound ' here' - {print} 'and a ' sound sound ' there' - {print} 'here a ' sound - {print} 'there a ' sound - {print} 'everywhere a ' sound sound - ``` - - ``` - lines = ['what shall we do with the drunken sailor', 'shave his belly with a rusty razor', 'put him in a long boat till hes sober'] - {for} line {in} lines - {for} i {in} {range} 1 {to} 3 - {print} line - {print} 'early in the morning' - {for} i {in} {range} 1 {to} 3 - {print} 'way hay and up she rises' - {print} 'early in the morning' - ``` - songs_2: - levels: - 12: - example_code: | - ``` - {define} twinkle - {print} 'Twinkle' - {print} '...' - - {call} twinkle - {print} 'Up above the world so high' - {print} 'Like a diamond in the sky' - {call} _ - ``` - turtle: - default_save_name: turtle - levels: - 1: - story_text: | - In level 1 you can also use Hedy to draw. By combining turns and lines, you can make a square or a stair! - - Using `{forward}` you draw a line forwards. The number behind it determines how far the turtle will walk. `{turn} right` turns a quarter turn in clockwise direction, `{turn} left` turns counter clockwise. - example_code_2: | - ``` - {turn} {right} - {forward} 20 - {turn} {left} - {forward} 20 - ``` - 2: - story_text: | - In level 1 the turtle could only turn left or right. That is a bit boring! - In level 2 he can point his nose in all directions. - - Use 90 to turn a quarter. We call this degrees. A full turn is 360 degrees. - Can you make a figure with this code? Maybe a triangle or a circle? - example_code: | - ``` - answer {is} {ask} How many steps should the turtle make? - {forward} answer - ``` - story_text_2: | - Also, in level 1 the turtle could only turn left or right. That is a bit boring! - In level 2 he can point his nose in all directions. - - Use 90 to turn a quarter. We call this degrees. A full turn is 360 degrees. - Can you make a figure with this code? Maybe a triangle or a circle? - example_code_2: | - ``` - {print} Drawing figures - angle {is} 90 - {turn} angle - {forward} 25 - {turn} angle - {forward} 25 - ``` - 3: - story_text: | - In this level you can use use `{random}` with the drawing turtle. A random choice makes the turtle walk a different path each time. - Use `{at} {random}` to choose a value from a list. You can copy and paste lines 2 and 3 to create a longer random path. - 4: - example_code: | - ``` - {print} 'Drawing figures' - angle {is} 90 - {turn} angle - {forward} 25 - {turn} angle - {forward} 25 - ``` - 5: - example_code_2: | - ``` - direction {is} {ask} 'Do you want to go left, right, or straight ahead?' - if direction is left turn _ - if direction is right turn _ - forward 100 - ``` - 8: - story_text: | - Now that we can repeat several lines, we can make figures more easily. - We only have to set the angle once and then use that variable in the `{repeat}`. - example_code: | - ``` - angle = 90 - {repeat} 10 {times} - {turn} angle - {forward} 50 - ``` - story_text_2: | - Also, we can now improve the program that draws different figures. - Can you figure out how far the turtle has to turn here? Finish the code and you can draw any polygon you'd like! - 9: - story_text: | - Now that we can use a `{repeat}` inside a `{repeat}`, we can create more complex figures. - - ### Exercise 1 - This code creates three black triangles, change that into five pink squares. - - **(extra)** Create a figure of your own choosing consisting of at least two different shapes types. - 10: - story_text: | - In this level you can make the turtle draw a figure. - The turtle will travel the distances in the list, one by one, making bigger and bigger steps. - ### Exercise 1 - Add a 90 degree turn in the loop, so that a spiral is drawn. - Add at least 5 numbers to the list, so the spiral grows larger. - **(extra)** can you change the spiral into another shape? Experiment with numbers for the turn! - ### Exercise 2 - The spiral is drawn outwards, make it go inwards? - turtle_draw_it: - levels: - 9: - example_code: | - Hint for the nested squares: - ``` - colors = red, blue, orange, yellow, pink, purple, green, brown, black - distance = 120 - repeat 5 times - _ - ``` - Hint for the flags: - ``` - country = ask 'which country would you like to see the flag of?' - if country is 'the Netherlands' - color_1 = red - color_2 = white - color_3 = blue - ``` - 10: - example_code: | - Hint Nested Hexagon: - ``` - distances = 100, 80, 60, 40, 20 - {for} distance {in} distances - _ - ``` - - Hint Traffic Lights: - ``` - colors = red, yellow, green - {for} chosen_color {in} colors - color _ - {repeat} _ - ``` - 12: - story_text: | - ### Exercise - Recreate the drawings with the turtle! - Hint: Bracelet designing program. Firstly, define a function **for each shape** you want to use on the bacelet. Then, add the shapes to the bacelet like this: - - Bracelet Designing program - example_code: | - ``` - {define} draw_a_square - _ - - {color} white - {turn} -90 - {forward} 300 - {turn} 180 - - {for} i {in} {range} 1 {to} 5 - {color} gray - {forward} 100 - shape = {ask} 'What kind of shape would you like next on the bracelet?' - chosen_color = {ask} 'In which color?' - {color} chosen_color - {if} shape = 'square' - {call} draw_a_square - ``` - while_command: - description: while - years: - description: Countdown to the new year! - levels: - 11: - story_text: | - In this level you can use the `{for} i {in} {range}` command to countdown to the New Year. - - ### Exercise - Fill in the blanks and make the code work! - example_code: | - ``` - for _ in _ 10 to 1 - {print} i - {print} 'Happy New Year!' - ``` diff --git a/content/adventures/he.yaml b/content/adventures/he.yaml index bb306e46454..12db33fb0c1 100644 --- a/content/adventures/he.yaml +++ b/content/adventures/he.yaml @@ -208,454 +208,11 @@ adventures: שם = 'מלכת אנגליה' {print} שם 'אכלה פיסת עוגה, כשלפתע...' ``` - 13: - story_text: | - By using the `{and}` and `{or}` commands, you can shorten your stories. For example, check out the dragon story. - 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' - ``` - add_remove_command: - name: '{add} {to} & {remove} {from}' - 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. - 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. and_or_command: default_save_name: ו או description: הצגת {and} ו {or} ask_command: description: הצגת הפקודה {ask} - levels: - 1: - 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. - calculator: - levels: - 6: - story_text: | - Now that you can calculate, you can also create a program to practice maths calculations. You can make up the calculations yourself, for example: - example_code: | - ``` - correct_answer = 11 * 27 - answer = {ask} 'How much is 11 times 27?' - {if} answer {is} correct_answer {print} 'good job!' - {else} {print} 'Wrong! It was ' correct_answer - ``` - story_text_2: | - You can also let the computer do random calculations on its own using {random}. - example_code_2: | - ``` - tables = 4, 5, 6, 8 - numbers = 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 - table = tables {at} {random} - number = numbers {at} {random} - correct_answer = table * number - answer = {ask} 'how much is ' table ' times ' number '?' - {if} answer {is} correct_answer {print} 'okay' - {else} {print} 'mistake! it was ' correct_answer - ``` - 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`. - 11: - example_code: | - ``` - number = 10 - {for} i {in} {range} 1 to 10 - {print} i * number - ``` - 12: - story_text: | - Now you can make a calculator that works for decimal numbers. - example_code: | - ``` - number1 = {ask} 'What is the first number?' - number2 = {ask} 'What is the second number?' - answer = number1 + number2 - {print} number1 ' plus ' number2 ' is ' answer - ``` - 14: - 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 - clear_command: - description: clear command - debugging: - levels: - 3: - 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} - ``` - 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! - 8: - 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: - 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!' - {else} - 'I'm sorry we don't sell that' - topping {is} {ask} 'What kind of topping would you like?' - sauce {is} {ask} 'What kind of sauce would you like?' - {print} One chosen_bread with topping and sauce. - price = amount * 6 - {print} 'That will be 'price dollar' please' - ``` - - price = amount * 6 - {print} 'That will be 'price dollar' please' - 10: - example_code: | - **Warning! This code needs to be debugged!** - ``` - names = Muad Hasan Samira Noura - activities = fly a kite, go swimming, go hiking, catch tan in the sun - {for} name {is} names - {print} At the beach name loves to activity at random - ``` - 11: - story_text: |- - ### Exercise - Debug this calender program. The output of this program is supposed to look like a list of dates. - For example: - - ``` - Hedy calender - Here are all the days of November - November 1 - November 2 - November 3 - ``` - And so on. - - Mind that you have to test your code extra carefully for the month February, because the amount of days in this month changes in leap years. - example_code: | - **Warning! This code needs to be debugged!** - ``` - print 'Hedy calender' - months_with_31 days = January, March, May, July, September, October, December - months_with_30_days = April, June, August, November - month = ask 'Which month would you like to see?' - if month in months_with_31_days - days = 31 - if month in months_with30_days - days = 30 - if month = February - leap_years = 2020, 2024, 2028, 2036, 2040, 2044, 2028 - year = ask 'What year is it?' - if year in leap_years - days = 29 - else - days = 28 - - print 'Here are all the days of ' moth - for i in range 1 to days - print month i - ``` - 12: - example_code: | - **Warning! This code needs to be debugged!** - ``` - define greet - greetings = 'Hello', 'Hi there', 'Goodevening' - print greetings at random - - define take_order - food = ask 'What would you like to eat?' - print 'One food' - drink = 'What would you like to drink?' - print 'One ' drink - more = ask 'Would you like anything else?' - if more is 'no' - print 'Alright' - else - print 'And ' more - print 'Thank you' - - print 'Welcome to our restaurant' - people = ask 'How many people are in your party tonight?' - for i in range 0 to people - call greet_costumer - ``` - 13: - example_code: | - **Warning! This code needs to be debugged!** - ``` - defin movie_recommendation with name - action_movies == 'Die Hard', 'Fast and Furious', 'Inglorious Bastards' - romance_movies = 'Love Actually', 'The Notebook', 'Titanic' - comedy_movies = 'Mr Bean' 'Barbie''Deadpool' - kids_movies = 'Minions', 'Paddington', 'Encanto' - if name is 'Camila' or name is 'Manuel' - recommended_movie = kids_movie at random - if name is 'Pedro' or 'Gabriella' - mood = ask 'What you in the mood for?' - if mood is 'action' - recommended_movie = comedy_movies at random - if mood is 'romance' - recommended_movie = romance_movies - if mood is 'comedy' - recommended_movie = comedy_movies at random - - print 'I would recommend ' recommended_movie ' for ' name - - name = ask 'Who is watching?' - recommendation = ask 'Would you like a recommendation?' - if recommendaion is 'yes' - print movie_recommendation with name - else - print 'No problem!' - ``` - 14: - example_code: | - **Warning! This code needs to be debugged!** - ``` - define calculate_heartbeat - print 'Press your fingertips gently against the side of your neck' - print '(just under your jawline)' - print 'Count the number of beats you feel for 15 seconds' - beats == ask 'How many beats do you feel in 15 seconds?' - heartbeat = beats*4 - print 'Your heartbeat is ' heartbeat - if heartbeat >= 60 or heartbeat <= 100 - print 'Your heartbeat seems fine' - else - if heartbeat > 60 - print 'Your heartbeat seems to be too low' - if heartbeat < 100 - print 'Your heartbeat seems to be too high' - print 'You might want to contact a medical professional' - - measure_heartbeat = ask 'Would you like to measure your heartbeat?' - if measure_heartbeat = 'yes' - call measure_heartbeat - else - 'no problem' - ``` - - print '(just under your jawline)' - print 'Count the number of beats you feel for 15 seconds' - beats == ask 'How many beats do you feel in 15 seconds?' - heartbeat = beats*4 - print 'Your heartbeat is ' heartbeat - if heartbeat >= 60 or heartbeat <= 100 - print 'Your heartbeat seems fine' - else - if heartbeat > 60 - print 'Your heartbeat seems to be too low' - if heartbeat < 100 - print 'Your heartbeat seems to be too high' - print 'You might want to contact a medical professional' - - measure_heartbeat = ask 'Would you like to measure your heartbeat?' - if measure_heartbeat = 'yes' - call measure_heartbeat - else - 'no problem' - 15: - example_code: | - **Warning! This code needs to be debugged!** - ``` - names = 'Tanya', 'Romy', 'Kayla', 'Aldrin', 'Ali' - verbs='walking', 'skipping', 'cycling', 'driving', 'running' - locations = 'on a mountaintop', 'in the supermarket', 'to the swimming pool' - hiding_spots = 'behind a tree', under a table', in a box' - sounds = 'a trumpet', 'a car crash', 'thunder' - causes_of_noise = 'a television', 'a kid with firecrackers', 'a magic elephant', 'a dream' - - chosen_ name = names at random - chosen_verb = verbs at random - chosen_location = 'locations at random' - chosen_sounds = noises at random - chosen_spot = hiding_spots random - chosen_causes = causes_of_noise at random - - print chosen_name ' was ' chosen_verb ' ' chosen_location - print 'when they suddenly heard a sound like ' sounds at random - print chosen_name ' looked around, but they couldn't discover where the noise came from' - print chosen_name ' hid ' chosen_spot' - print 'They tried to look around, but couldn't see anything from there' - hidden = 'yes' - while hidden = 'yes' - print chosen_name 'still didn't see anything' - answer = ask 'does ' chosen_name ' move from their hiding spot?' - if answer = 'yes' - hidden == 'no' - print 'chosen_name moved from' chosen_spot - print 'And then they saw it was just' chosen_cause - print chosen_name 'laughed and went on with their day' - print The End - ``` - 16: - example_code: | - **Warning! This code needs to be debugged!** - ``` - country = ['The Netherlands', 'Poland', 'Turkey', 'Zimbabwe', 'Thailand', 'Brasil', 'Peru', 'Australia', 'India', 'Romania' ] - capitals = 'Amsterdam', 'Warshaw' 'Istanbul', 'Harare', 'Bangkok', 'Brasilia', 'Lima', 'Canberra', 'New Delhi', 'Bucharest' - score = 0 - for i in range 0 to 10 - answer = ask 'What's the capital of ' countries[i] - correct = capital[i] - if answer = correct - print 'Correct!' - score = score + 1 - else - print 'Wrong,' capitals[i] 'in the capital of' countries[i] - print 'You scored ' score ' out of 10' - - ``` - 17: - example_code: | - **Warning! This code needs to be debugged!** - ``` - define food_order - toppings = ask 'pepperoni, tuna, veggie or cheese?' - size = ask 'big, medium or small?' - number_of_pizza = ask 'How many these pizzas would you like?' - - print 'YOU ORDERED' - print number_of_pizzas ' size ' topping ' pizza' - - define drinks_order - drink = ask 'water, coke, icetea, lemonade or coffee?' - number_of_drinks = ask 'How many of these drinks would you like?' - - print 'YOU ORDERED' - print number_of_drinks ' ' drink - - 'Welcome to Hedy pizza' - more_food = ask 'Would you like to order a pizza?' - while more_food = 'yes' - return food_order - more_food = ask 'Would you like to order a pizza?' - more_drinks = ask 'Would you like to order some drinks?' - while more_drinks == 'yes' - call drink_order - more_drinks == ask 'Would you like to order more drinks?' - - - print 'Thanks for ordering!' - ``` - 18: - example_code: | - **Warning! This code needs to be debugged!** - ``` - animals = ['pig', 'dog', 'cow'] - sounds = ['oink', 'woof', 'moo'] - for i in range 1 to 3 - animal = animals[i] - sound = sounds[i] - print 'Old MacDonald had a farm' - print 'E I E I O!' - print 'and on that farm he had a ' animal - print 'E I E I O!' - print 'with a ' sound sound ' here' - print 'and a ' sound sound ' there' - print 'here a ' sound - print 'there a ' sound - print 'everywhere a ' sound sound - ``` default: name: הקדמה default_save_name: הקדמה @@ -781,13 +338,6 @@ adventures: {print} 'את הדי האמיתית!' ``` 14: - story_text: | - We are going to learn more new items. You might know them already from mathematics, the `<` and `>`. - The `<` checks if the first number is smaller than the second, for example age `<` 12 checks if age is smaller than 12. - If you want to check if the first number is smaller or equal to the second, you can use `<=`, for example age `<=` 11. - The `>` checks if the first number is bigger than the second, for example points `>` 10 checks if points is larger than 10. - If you want to check if the first number is bigger or equal to the second, you can use `>=`, for example points `>=` 11. - You use these comparisons in an `{if}`, like this: example_code: | ``` גיל = {ask} 'בת כמה את?' @@ -825,585 +375,59 @@ adventures: {print} 'מספר המזל של ' חברים[א] {print} 'הוא ' מספרי_מזל[א] ``` - 17: - story_text: |- - Now we are going to change indentation a little bit. Every time that we need an indentation, we need `:` at the line before the indentation. - - In this level you can also use a new command: `{elif}`. `{elif}` is short for `{else} {if}` and you need it when you want to make 3 (or more!) options. - Check it out! - 18: - story_text: |- - We arrived at real Python code! That means we need to use parentheses with {print} and {range} from now on. - {print}('My name is ', name) - dice: - levels: - 3: - example_code: | - ``` - choices {is} 1, 2, 3, 4, 5, earthworm - {print} choices {at} {random} - ``` - 4: - story_text: | - In this level we can make sentences with the die value in the sentence, with quotes of course. - This time the sample code is not quite complete. Can you finish the code? - 5: - story_text: | - You can also make a die again in this level using the `{if}`. - Complete the sample code so that the code says "You can stop throwing" once you have thrown an earthworm. - - But maybe you want to recreate a die from a completely different game. That's fine too! Then make up your own reaction. Eg 'yes' for 6 and 'pity' for something {else}. - example_code: | - ``` - choices {is} 1, 2, 3, 4, 5, earthworm - throw {is} _ - {print} 'you have' _ 'thrown' - {if} _ {is} earthworm {print} 'You can stop throwing.' _ {print} 'You have to hear it again!' - ``` - 6: - story_text: | - You can also make an Earthworm die again in this, but now you can also calculate how many points have been rolled. - You may know that the worm counts 5 points for Earthworms. Now after a roll you can immediately calculate how many points you have thrown. - This is the code to calculate points for one die: - example_code: | - ``` - choices = 1, 2, 3, 4, 5, earthworm - points = 0 - throw = choices {at} {random} - {print} 'you threw' throw - {if} throw {is} earthworm points = points + 5 {else} points = points + throw - {print} 'those are' points ' point' - ``` - Can you make the code so that you get the total score for 8 dice? To do that, you have to cut and paste some lines of the code. - example_code_2: | - Did you manage to calculate the score for 8 dice? That required a lot of cutting and pasting, right? We are going to make that easier in level 7! - 7: - story_text: | - You can also make a die again in level 5. With the `{repeat}` code you can easily roll a whole hand of dice. - Try to finish the sample code! The dashes should contain multiple commands and characters. - - But maybe you want to make a completely different die. Of course you can! - example_code: | - ``` - choices = 1, 2, 3, 4, 5, earthworm - {repeat} _ _ {print} _ _ _ - ``` - 10: - story_text: | - Is everybody taking too long throwing the dice? In this level you can let Hedy throw all the dice at once! - example_code: | - ``` - players = Ann, John, Jesse - choices = 1, 2, 3, 4, 5, 6 - {for} player {in} players - {print} player ' throws ' choices {at} {random} - {sleep} - ``` - dishes: - description: Use the computer to see who does the dishes (Start at level 2) - levels: - 3: - story_text: | - Do you always disagree at home about who should wash the dishes or change the litter box today? - Then you can let the computer choose very fairly. You can program that in this level! - You first make a list of the members of your family. Then choose '{at} {random}' from the list. - example_code: | - ``` - people {is} mom, dad, Emma, Sophie - {print} people {at} {random} - ``` - story_text_2: | - Don't feel like doing the dishes yourself? Hack the program to remove your name from the list. - 4: - story_text: | - With quotation marks you can make your dishwashing planning more beautiful. - This time the sample code is not quite complete. - - Can you complete the code by filling the blanks? Every blank must be replaced with one word of symbol. - - Tip: Don't forget the quotation marks! - 5: - story_text: | - With the `{if}` you can now have more fun with choice in the program. You can have your program respond to the choice that the computer has made. - - Can you finish the code so that it prints 'too bad' when it is your turn and otherwise 'yes!'? - Don't forget the quotes! - example_code: | - ``` - people {is} mom, dad, Emma, Sophie - dishwasher {is} people {at} {random} - {if} dishwasher {is} Sophie {print} _ too bad I have to do the dishes _ {else} {print} 'luckily no dishes because' _ 'is already washing up' - ``` - 6: - story_text_2: | - If you are extremely unlucky the previous program might choose you to to the dishes for the whole week! That's not fair! - To create a fairer system you can use the `{remove}` command to remove the chosen person from the list. This way you don't have to do the dishes again untill everybody has had a turn. - - Monday and tuesday are ready for you! Can you add the rest of the week? - And... can you come up with a solution for when your list is empty? - example_code_2: | - ``` - people = mom, dad, Emma, Sophie - dishwasher = people {at} {random} - {print} 'Monday the dishes are done by: ' dishwasher - {remove} dishwasher {from} people - dishwasher = people {at} {random} - {print} 'Tuesday the dishes are done by: ' dishwasher - {remove} dishwasher {from} people - dishwasher = people {at} {random} - ``` - 7: - story_text: | - With the `{repeat}` you can repeat pieces of code. You can use this to calculate who will be washing dishes for the entire week. - example_code: | - ``` - people = mom, dad, Emma, Sophie - {repeat} _ _ {print} 'the dishwasher is' _ - ``` - 10: - story_text: | - In this level you could make an even better dish washing shedule. - elif_command: - description: elif - levels: - 17: - example_code: | - ``` - prices = ['1 million dollars', 'an apple pie', 'nothing'] - your_price = prices[{random}] - {print} 'You win ' your_price - {if} your_price == '1 million dollars' : - {print} 'Yeah! You are rich!' - {elif} your_price == 'an apple pie' : - {print} 'Lovely, an apple pie!' - {else}: - {print} 'Better luck next time..' - ``` - for_command: - description: for command - levels: - 11: - story_text: |- - In this level, we add a new form of the `{for}`. In earlier levels, we used `{for}` with a list, but we can also use `{for}` with numbers. - We do that by adding a variable name, followed by `{in}` `{range}`. We then write the number to start at, `{to}` and the number to end at. - Try the example to see what happens! In this level again, you will need to use indentations in lines below the `{for}` statements. - fortune: + parrot: + name: תוכי + default_save_name: תוכי + description: צרו לעצמכם.ן תוכי מחמד שיחקה אתכם.ן! levels: 1: story_text: | - Have you ever been to a carnival and had your future predicted by a fortune teller? Or have you ever played with a magic eight ball? - Then you probably know that they can't really predict your future, but it's still fun to play! - - In the upcoming levels you can learn how to create your own fortune telling machine! - In level 1 you can start off easy by letting Hedy introduce herself as a fortune teller and let her {echo} the players' answers. - Like this: + צרו תוכי מחמד שיחקה אתכם.ן! example_code: | ``` - {print} Hello, I'm Hedy the fortune teller! - {ask} Who are you? - {print} Let me take a look in my crystal ball - {print} I see... I see... - {echo} Your name is + {print} אני הֶדִי התוכי + {ask} מה שמך? + {echo} + {echo} ``` story_text_2: | ### Exercise - Hedy now only tells you your name. Can you expand the code so that Hedy can predict more things about you? - Obviously, Hedy isn't a very good fortune teller yet, as she can only repeat the answers that were given by the players! - Take a look in level 2 to improve your fortune teller. - 3: - story_text: | - In the previous levels you've created your first fortune telling machine, but Hedy couldn't really predict anything, only {echo}. - In this level you can use a variable and the `{at} {random}` command to really let Hedy choose an answer for you. Check out this code for instance: - story_text_2: | - ### Exercises - Now, Hedy can only answer yes, no or maybe. Can you give Hedy more answer options, like 'definitely' or '{ask} again'. - 4: - example_code: | - ``` - {print} 'Im Hedy the fortune teller!' - question {is} {ask} 'What do you want to know?' - {print} 'This is your question: ' question - answers {is} yes, no, maybe - {print} 'My crystal ball says...' - {sleep} 2 - {print} answers {at} {random} - ``` - 5: - story_text: | - In this level you'll learn to (secretly) tip the odds in your favor, when using the fortune teller! - By using `{if}` and `{else}` you can make sure that you will always get a good fotune, while other people might not. - Check out this example to find out how. - example_code: | - ``` - {print} 'Im Hedy the fortune teller!' - {print} 'I can predict {if} youll win the lottery tomorrow!' - person {is} {ask} 'Who are you?' - {if} person {is} Hedy {print} 'You will definitely win!🤩' {else} {print} 'Bad luck! Someone {else} will win!😭' - ``` - 6: + Can you make the parrot ask a different question? Fill in the blanks in the example! + 2: story_text: | - In this level you can use math in your predictions as a fortune teller. This allows you to make up (silly) formulas to calculate the future. - For example you could calculate how rich you'll get or how many kids you will have when you grow up. + צרו תוכי מחמד שיחקה אתכם.ן! example_code: | ``` - {print} 'I am Hedy the fortune teller!' - {print} 'I can predict how many kids youll get when you grow up!' - age = {ask} 'How old are you?' - siblings = {ask} 'How many siblings do you have?' - length = {ask} 'How tall are you in centimetres?' - kids = length / age - kids = kids - siblings - {print} 'You will get ...' + {print} אני הֶדִי התוכי + שם {is} {ask} מה שמך? + {print} שם {sleep} - {print} kids ' kids!' - ``` - - If the previous example wasn't silly enough for you, take a look at this one! - - ``` - {print} 'Im Hedy the silly fortune teller!' - {print} 'I will predict how smart you are!' - football = {ask} 'On a scale 1-10 how much do you love football?' - bananas = {ask} 'How many bananas did you eat this week?' - hygiene = {ask} 'How many times did you wash your hands today?' - result = bananas + hygiene - result = result * football - {print} 'You are ' result ' percent smart.' - ``` - 7: - story_text: | - In this level you can use the `{repeat}` command to make your machine tell multiple fortunes at once. - example_code: | - ``` - {print} 'Im Hedy the fortune teller!' - {print} 'You can {ask} 3 questions!' - {repeat} 3 {times} question = {ask} 'What do you want to know?' - answer = yes, no, maybe - {repeat} 3 {times} {print} 'My crystal ball says... ' answer {at} {random} + {print} סקוואק! + {sleep} + {print} שם ``` - 8: + story_text_2: | + ### Exercise + You can use variables to make the parrot say more than only your name. Can you complete this code? + 3: story_text: | - In the previous levels you've learned how to use repeat to make the fortune teller answer 3 questions in a row, but we had a problem with printing the questions. - Now that problem is solved, because of the new way of using the repeat command. - In the next example you can have your fortune teller {ask} 3 questions and also print them! + למדו את התוכי שלכם.ן מילה חדשה עם `{add}`. example_code: | ``` - {print} 'I am Hedy the fortune teller!' - {print} 'You can {ask} me 3 questions.' - answers = yes, no, maybe - {repeat} 3 {times} - question = {ask} 'What do you want to know?' - {print} question - {sleep} - {print} 'My crystal ball says...' answers {at} {random} + מילים {is} סקוואק, הֶדִי + {print} אלפו את התוכי שלכם.ן! + מילה_חדשה {is} {ask} איזו מילה תרצו ללמד את התוכי? + {add} מילה_חדשה {to_list} מילים + {print} 🧒 אמרי מילה_חדשה, הֶדִי! + {print} 🦜 מילים {at} {random} ``` - 10: + 4: story_text: | - In this level you'll learn how to program the game MASH (mansion, apartement, shack, house). In this game you can predict for all the players at once, what their future will look like. - example_code: | - ``` - houses = mansion, apartment, shack, house - loves = nobody, a royal, their neighbour, their true love - pets = dog, cat, elephant - names = Jenna, Ryan, Jim - {for} name {in} names - {print} name ' lives in a ' houses {at} {random} - {print} name ' will marry ' loves {at} {random} - {print} name ' will get a ' pets {at} {random} ' as their pet.' - {sleep} - ``` - 12: + In this level we have to use quotation marks with the commands `{ask}` and `{print}`. + Can you complete the code by adding quotation marks? + 5: story_text: | - In this level you can make your fortunes multiple words. Like in this example below: - example_code: | - ``` - fortunes = 'you will be rich', 'you will fall in love', 'you will slip on a banana peel' - {print} 'I will take a look in my crystall ball for your future.' - {print} 'I see... I see...' - {sleep} - {print} fortunes {at} {random} - ``` - functions: - levels: - 12: - example_code: | - ``` - sides = 'left', 'right' - limbs = 'hand', 'foot' - colors = 'red', 'blue', 'green', 'yellow' - - {define} turn - chosen_side = sides {at} {random} - chosen_limb = limbs _ - chosen_color = colors _ - {print} chosen_side ' ' chosen_limb ' on ' chosen_color - - {print} 'Lets play a game of Twister!' - {for} i {in} {range} 1 to _ - {call} turn - {sleep} 2 - ``` - 13: - story_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. - - For example in this code we've programmed the first verse of the song 'My Bonnie is over the ocean'. - In this example code the argument `place` is used. Place is a variable that is only used in the function, so an argument. - To use `place` we have programmed the line `define song with place`. - When the function is called, computer will replace the argument `place`, with the piece of text after `call song with`. - - ### Exercise - The next verse of this song goes: - - Last night as I lay on my pillow - Last night as I lay on my bed - Last night as I lay on my pillow - I dreamed that my Bonnie is dead - - Can you program this verse in the same way as the example? - 14: - example_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?' - - new_price = _ calculate_new_price {with} old_price, _ - {print} 'The new price is ' new_price ' dollar' - ``` - haunted: - levels: - 1: - story_text: | - In this adventure you are working towards making a game in which you have to escape from a haunted house by picking the correct door. - If you pick the right door you'll survive, but {if} not a terrible monster might... - - In level 1 we start our haunted house game by making up a scary story and {ask} the player what monster they'll see in the haunted house. - story_text_2: | - ### Exercise - Can you finish the scary story? Or make up your own haunted house story? - 2: - example_code: | - ``` - monster_1 {is} 👻 - monster_2 {is} 🤡 - monster_3 {is} 👶 - {print} You enter the haunted house. - {print} Suddenly you see a monster_1 - {print} You run into the other room, but a monster_2 is waiting there for you! - {print} Oh no! Quickly get to the kitchen. - {print} But as you enter monster_3 attacks you! - ``` - example_code_2: | - ``` - monster_1 {is} _ - monster_2 {is} _ - monster_3 {is} _ - {print} You enter the haunted house. - {print} Suddenly you see a monster_1 - {print} You run into the other room, but a monster_2 is waiting there for you! - {print} Oh no! Quickly get to the kitchen. - {print} But as you enter monster_3 attacks you! - ``` - 3: - story_text: | - In the previous levels you've made an introduction to your haunted house game, but as you might have noticed the story would always have a dreadful end. - In this level you can make your story more interactive by changing the outcome of the game; sometimes you'll get eaten, sometimes you'll escape! - Let Hedy decide randomly! - 4: - story_text: | - In this level you learn how to use quotation marks in your games. - Can you make your Haunted House level 4 proof? - example_code: | - ``` - {print} _Escape from the haunted house!_ - {print} _There are 3 doors in front of you..._ - choice {is} {ask} _Which door do you choose?_ - {print} _You picked door ..._ choice - monsters {is} a zombie, a vampire, NOTHING YOUVE ESCAPED - {print} _You see..._ - {sleep} - {print} monsters {at} {random} - ``` - 5: - story_text: | - Up until this level the haunted house game always asked the player to choose a door, but as you might have noticed, they didn't really have to answer correctly. - If the player filled in a completely random answer, the game would still work and the player might even win (despite not picking a door). - In this level you can only win the game by picking the same door Hedy picked randomly. - example_code: | - ``` - {print} 'Escape from the haunted house!' - {print} 'There are 3 doors in front of you...' - doors {is} 1, 2, 3 - monsters {is} werewolf, mummy, vampire, zombie - chosen_door {is} {ask} 'Which door do you choose?' - {print} 'You chose door...' chosen_door - {sleep} - correct_door {is} doors {at} {random} - {if} chosen_door {is} correct_door {print} 'Great! Youve escaped!' - {else} {print} 'Oh no! You are being eaten by a...' monsters {at} {random} - ``` - 9: - story_text: | - In this level you can use nesting, which allows you to make the haunted house even more interactive! - - ### Exercise - Now it's very hard to win this game, can you make it easier to win? - For example by only having 1 wrong door and 2 correct doors instead of 1 correct door and 2 wrong ones? - 11: - story_text: | - In this level we've changed the repeat command and we've added a line to our haunted house that tells the player in which room they are. - example_code: | - ``` - {print} 'Escape from the Haunted House!' - player {is} alive - doors = 1, 2, 3 - monsters = zombie, vampire, giant spider - {for} i {in} {range} 1 {to} 3 - {if} player {is} alive - correct_door = doors {at} {random} - {print} 'Room ' i - {print} 'There are 3 doors in front of you...' - chosendoor = {ask} 'Which door do you choose?' - {if} chosendoor {is} correct_door - {print} 'No monsters here!' - {else} - {print} 'You are eaten by a ' monsters {at} {random} - player = dead - {else} - {print} 'GAME OVER' - {if} player {is} alive - {print} 'Great! You survived!' - ``` - if_command: - description: Introducing the if command - levels: - 9: - story_text: | - In this level you can also put an {if} command inside another {if} command. - in_command: - description: Introducing the in command - levels: - 5: - example_code_2: | - ``` - animals is dog, cow, sheep - answer is ask 'What is your favorite animal?' - _ answer _ animals _ 'Mine too!' - _ _ 'My favorite animals are dogs, cows and sheep' - ``` - is_command: - description: introducing is command - levels: - 2: - story_text_2: | - ### Exercise - Time to make your own variables! - In the example code we made an example of the variable `favorite_animal`. In line 1 the variable is set, and in line 2 we haved used the variable in a print command. - Firstly, finish our example by filling in your favorite animal on the blank. Then make at least 3 of these codes yourself. Pick a variable, and set the variable with the {is} command. Then use it with a {print} command, just like we did. - 14: - example_code: | - ``` - age = {ask} 'How old are you?' - {if} age > 12 - {print} 'You are older than I am!' - ``` - example_code_3: | - ``` - name = {ask} 'What is your name?' - {if} name != 'Hedy' - {print} 'You are not Hedy' - ``` - - {if} age < 13 - {print} 'You are younger than me!' - {else} - {print} 'You are older than me!' - language: - levels: - 5: - story_text: | - Make your own program to practice your vocabulary in a new language. - maths: - levels: - 6: - example_code: | - ``` - {print} '5 plus 5 is ' 5 + 5 - {print} '5 minus 5 is ' 5 - 5 - {print} '5 times 5 is ' 5 * 5 - ``` - 12: - example_code_2: | - ``` - a = 'Hello ' - b = 'world!' - {print} a + b - ``` - - {print} 2.5 + 2.5 - music: - levels: - 6: - story_text: "Instead of playing notes, you can also play numbers now. Simply type `{play} 1` for the lowest note, `{play} 70` for the highest note, or anything in between.\n\n### Exercise\n This calls for musical maths! Try out the example code a couple of times with different starting numbers. \nThen, see if you can compose a song using the numbers.\n" - parrot: - name: תוכי - default_save_name: תוכי - description: צרו לעצמכם.ן תוכי מחמד שיחקה אתכם.ן! - levels: - 1: - story_text: | - צרו תוכי מחמד שיחקה אתכם.ן! - example_code: | - ``` - {print} אני הֶדִי התוכי - {ask} מה שמך? - {echo} - {echo} - ``` - story_text_2: | - ### Exercise - Can you make the parrot ask a different question? Fill in the blanks in the example! - 2: - story_text: | - צרו תוכי מחמד שיחקה אתכם.ן! - example_code: | - ``` - {print} אני הֶדִי התוכי - שם {is} {ask} מה שמך? - {print} שם - {sleep} - {print} סקוואק! - {sleep} - {print} שם - ``` - story_text_2: | - ### Exercise - You can use variables to make the parrot say more than only your name. Can you complete this code? - 3: - story_text: | - למדו את התוכי שלכם.ן מילה חדשה עם `{add}`. - example_code: | - ``` - מילים {is} סקוואק, הֶדִי - {print} אלפו את התוכי שלכם.ן! - מילה_חדשה {is} {ask} איזו מילה תרצו ללמד את התוכי? - {add} מילה_חדשה {to_list} מילים - {print} 🧒 אמרי מילה_חדשה, הֶדִי! - {print} 🦜 מילים {at} {random} - ``` - 4: - story_text: | - In this level we have to use quotation marks with the commands `{ask}` and `{print}`. - Can you complete the code by adding quotation marks? - 5: - story_text: | - תנו פרס לתוכי שלכם אם הוא אומר את המילה הנכונה! + תנו פרס לתוכי שלכם אם הוא אומר את המילה הנכונה! example_code: | ``` מילים {is} סקוואק, הֶדִי @@ -1416,726 +440,3 @@ adventures: {if} מילה_שנאמרה {is} מילה_חדשה {print} '🧒עבודה טובה, הֶדִי! 🍪' {else} {print} '🧒 לא, הֶדִי! תגידי ' מילה_חדשה ``` - piggybank: - levels: - 12: - story_text: | - In this adventure you learn how to make a digital piggy bank, to calculate how much money you have and how long you need to save up to buy what you want! - example_code: | - ``` - {print} 'The digital piggy bank' - wish = {ask} 'What would you like to buy?' - price = {ask} 'How much does that cost?' - saved = {ask} 'How much money have you saved already?' - allowance = {ask} 'How much pocket money do you get per week?' - to_save = price - saved - weeks = to_save / allowance - {print} 'You can buy a ' wish ' in ' weeks ' weeks.' - ``` - 14: - example_code: | - ``` - _ calculate_budget with wish, money, allowance - to_save = wish - money - weeks = to_save / allowance - {if} wish _ money - {print} 'You need to save up some more!' - {print} 'Youll need ' weeks ' more weeks.' - {else} - {print} 'Great! You have enough' - {print} 'Lets go shopping!' - - money = {ask} 'How much money have you saved?' - wish = {ask} 'How much money do you need?' - allowance = {ask} 'How much pocket money do you get each week?' - - {call} calculate_budget with _, _, _ - ``` - pressit: - levels: - 9: - story_text: | - Now that you know how to combine statements, you can create a touch type tool with `{pressed}`. - - ### Exercise - Finish the code. Each time a random letter should be chosen, which you have to press. You get a point for a correct press, and and two points deduction for a wrong press. - **(extra)** Clear the screen after each letter, and show the user how many points they have scored. - print_command: - levels: - 18: - example_code_2: | - ``` - temperature = 25 - {print}('It is ', temperature, ' degrees outside') - ``` - - {print}('My name is ', name) - random_command: - levels: - 16: - story_text: |- - We are going to make lists the Python way, with square brackets around the lists! We also keep the quotation marks around each item like we have learned in previous levels. - We use square brackets to point out a place in a list. For example: `friends[1]` is the first name on the list of friends, as you can see in the first part of the example code. The second part of the example code shows you that we can also match 2 lists using the variable i. - repeat_command: - description: repeat command - levels: - 7: - story_text: | - ## Repeat! Repeat! Repeat! - Level 7 adds the `{repeat}` command. `{repeat}` can be used to execute one line of code multiple times. Like this: - - ### Exercise - Play around with the repeat command. Can you make the happy birthday song in only 3 lines of code instead of 4 now? - 9: - story_text: | - Great job! You've reached another new level! In the previous level you've learned to use multiple lines of code in an {if} or {repeat} command. But you can't yet combine the two... - Good news! In this level you will be allowed to put an {if} inside an {if}, or inside a {repeat} command. Putting a block of code inside another block of code is called nesting. ``` Putting a block of code inside another block of code is called nesting. - example_code: | - ``` - answer = {ask} 'Are you ready to learn something new?' - {if} answer {is} yes - {print} 'Great! You can learn to use the repeat command in the if command!' - {print} 'Hooray!' - {print} 'Hooray!' - {print} 'Hooray!' - {else} - {print} 'Maybe you should practice some more in the previous level' - repeat_command_2: - description: repeat command 2 - levels: - 7: - story_text_2: | - Another interesting thing you can so with the `{repeat}` command is using variables to set the amount of times something should be repeated. In the example code you can see that we first ask the person how old they are. - Then, in line 3, the question is repeated 'age' times. So we have used the variable 'age' with the `{repeat}` command. - restaurant: - levels: - 1: - story_text_2: | - ### Exercise - Can you think of more lines to add to your restaurant code? For example, can you {ask} the guests what they'd like to drink, tell them the price, or wish them a pleasant meal? - example_code_2: | - ``` - {print} Welcome to Hedy's restaurant 🍟 - {ask} What would you like to order? - {echo} So you would like to order - {print} Thanks you for your order! - {print} It's on its way! - ``` - 2: - story_text: | - In level 2 you could expand your restaurant by using variables. In level 1 Hedy could only {echo} the order once and only remember the last thing that was ordered. - Now you can use variables and Hedy can remember both the food and the drinks! - example_code: | - ``` - {print} Welcome to Hedy's restaurant! - {print} Today we're serving pizza or lasagna. - food {is} {ask} What would you like to eat? - {print} Great choice! The food is my favorite! - topping {is} {ask} Would you like meat or veggies on that? - {print} food with topping is on its way! - drinks {is} {ask} What would you like to drink with that? - {print} Thank you for your order. - {print} Your food and drinks will be right there! - ``` - story_text_2: | - ### Exercise - Can you make this code more elaborate? For example by adding drinks to the order? Or...? - 3: - example_code: | - ``` - {print} Welcome to Hedy's Random Restaurant! - {print} The only restaurant that will randomly choose your meal and its price for you! - starters {is} salad, soup, carpaccio - mains {is} pizza, brussels sprouts, spaghetti - desserts {is} brownies, ice cream, french cheeses - drinks {is} cola, beer, water - prices {is} 1 dollar, 10 dollars, 100 dollars - {print} You will start with: starters {at} {random} - {print} Then we'll serve: mains {at} {random} - {print} And as dessert: desserts {at} {random} - {print} You will get a drinks {at} {random} to drink - {print} That will be: prices {at} {random} - {print} Thank you and enjoy your meal! - ``` - story_text_2: | - Does your costumer have any allergies or do they dislike certain dishes? Then you can use the `{remove}`command to remove it from your menu. - example_code_2: | - ``` - {print} Mystery milkshake - flavors {is} strawberry, chocolate, vanilla - allergies {is} {ask} Are you allergic to any falvors? - {remove} allergies {from} flavors - {print} You get a flavors {at} {random} milkshake - ``` - 4: - story_text: | - ### Exercise - Add the quotation marks to this code to make it work! Be careful: variables should not be in quotation marks. - Then, use the `{clear}` command to only show one line at a time in your output screen. - - ### Exercise 2 - Go back to the previous level and copy your restaurant code. Make the code work in this level by adding quotation marks in the right spots and add some `{clear}` commands. - 5: - story_text: | - In this level the {if} command allows you to {ask} your customers questions and give different responses to the answers. - In the example below, you see that you can {ask} the customer {if} they want to hear the specials and Hedy can respond accordingly. - example_code: | - ``` - {print} 'Welcome to Hedys restaurant!' - special {is} {ask} 'Would you like to hear our specials today?' - {if} special {is} yes {print} 'Todays special is chicken piri piri and rice.' {else} {print} 'No problem.' - food {is} {ask} 'What would you like to eat?' - {print} 'One ' food ', coming right up!' - drink {is} {ask} 'What would you like to drink with that?' - {if} drink {is} cola {print} 'Im sorry, we are out of cola!' {else} {print} 'Great choice!' - anything {is} {ask} 'Would you like anything {else}?' - {print} 'Let me repeat your order...' - {print} 'One ' food - {if} drink {is} cola {print} 'and...' {else} {print} 'One ' drink - {if} anything {is} no {print} 'Thats it!' {else} {print} 'One ' anything - {print} 'Thank you for your order and enjoy your meal!' - ``` - 6: - story_text: | - In this level you can use maths to calculate the total price of your customer's order, which can make your virtual restaurant more realistic. - 7: - story_text: | - In this level you've learned how to use the {repeat} command to repeat a line of code a certain amount of times. - You can use that in your restaurant to {ask} multiple people what they'd like to eat. Like this: - example_code: | - ``` - {print} 'Welcome to Hedys restaurant!' - people = {ask} 'How many people are joining us today?' - {repeat} people times food = {ask} 'What would you like to eat?' - {print} 'Thanks for your order! Its coming right up!' - ``` - 9: - story_text: | - In this level you can use nesting to make your restaurant more realistic and more fun! - For example you would {ask} for sauce {if} somebody orders fries, but you wouldn't {if} someone orders pizza! - Check out the example, and try this at your own virtual restaurant! - example_code: | - ``` - {print} 'Welcome to Hedys restaurant!' - people = {ask} 'How many people will be joining us today?' - {print} 'Great!' - price = 0 - {repeat} people {times} - food = {ask} 'What would you like to order?' - {print} food - {if} food {is} fries - price = price + 3 - sauce = {ask} 'What kind of sauce would you like with your fries?' - {if} sauce {is} no - {print} 'no sauce' - {else} - price = price + 1 - {print} 'with ' sauce - {if} food {is} pizza - price = price + 4 - {print} 'That will be ' price ' dollar' - {print} 'Enjoy your meal!' - ``` - 10: - story_text: | - In this level you'll learn how to easily {ask} your guests' orders in a short code. - example_code: | - ``` - courses = appetizer, main course, dessert - {for} course {in} courses - food = {ask} 'What would you like to eat as your ' course '?' - {print} food ' will be your ' course - ``` - example_code_2: | - ``` - courses = appetizer, main course, dessert - names = Timon, Onno - {for} name {in} names - {for} course {in} courses - food = {ask} name ', what would you like to eat as your ' course '?' - {print} name ' orders ' food ' as their ' course - ``` - 11: - story_text: | - We can use the `{for} i {in} {range} 1 {to} 5` to {print} the orders from multiple customers in an orderly manner. - example_code: | - ``` - {print} 'Welcome to Restaurant Hedy!' - people = {ask} 'For how many people would you like to order?' - {for} i {in} {range} 1 {to} people - {print} 'Order number ' i - food = {ask} 'What would you like to eat?' - {print} food - {if} food {is} fries - sauce = {ask} 'What kind of sauce would you like with that?' - {print} sauce - drinks = {ask} 'What would you like to drink?' - {print} drinks - price = 4 * people - {print} 'That will be ' price ' dollars, please!' - ``` - 12: - story_text: | - From this level on you can use decimal numbers to make you menu more realistic. - example_code: | - ``` - price = 0 - food = {ask} 'What would you like to order?' - drink = {ask} 'What would you like to drink?' - {if} food {is} 'hamburger' - price = price + 6.50 - {if} food {is} 'pizza' - price = price + 5.75 - {if} drink {is} 'water' - price = price + 1.20 - {if} drink {is} 'soda' - price = price + 2.35 - {print} 'That will be ' price ' dollar, please' - ``` - 13: - story_text: | - In this level we can use the new commands to upgrade our restaurant. - We use `{and}` to see {if} two things are both the case. - example_code: | - ``` - price = 10 - food = {ask} 'What would you like to eat?' - drinks = {ask} 'What would you like to drink?' - {if} food {is} 'sandwich' {and} drinks {is} 'juice' - {print} 'Thats our discount menu' - price = price - 3 - {print} 'That will be ' price ' dollars' - ``` - rock: - default_save_name: Rock - levels: - 1: - example_code: | - ``` - {print} what do you choose? - {ask} choose from rock, paper or scissors - {echo} so your choice was: - ``` - Instead of using words, you could also use emojis of course: ✊✋✌ - 2: - story_text: | - In this level you can practise using the variables, so that you can make the rock, paper, scissors game in the next level! - example_code: | - ``` - choice {is} _ - {print} I choose choice - ``` - 3: - example_code: | - ``` - choices {is} rock, paper, scissors - {print} choices {at} {random} - ``` - story_text_2: | - ### Exercise - Now you only have one player, so can you add a second player? - You can even use variables to name player 1 and player 2. - example_code_2: | - ``` - choices {is} rock, paper, scissors - {print} player 1 chooses... choices {at} {random} - {print} player 2 _ - ``` - 5: - story_text: | - In this level we can determine who won. - For that you need the new `{if}` code. - - Save your choice with the name of choice and the choice of computer as computer choice. - Then you can use `{if}` to see {if} they are the same or different. - Will you finish the code? - example_code: | - ``` - options {is} rock, paper, scissors - computer_choice {is} _ - choice {is} {ask} 'What do you choose?' - {print} 'you chose ' _ - {print} 'computer chose ' _ - {if} _ {is} _ {print} 'tie!' {else} {print} 'no tie' - ``` - - Fill in the correct code on the blanks to see {if} it is a draw. - 9: - story_text: | - In this level you can program the whole rock, paper, scissors game by nesting the {if}-commands. Can you finish the code? - example_code: | - ``` - choices = rock, paper, scissors - your_choice = {ask} 'What do you choose?' - {print} 'You choose ' your_choice - computer_choice = choices {at} {random} - {print} 'The computer chooses ' computer_choice - {if} computer_choice {is} your_choice - {print} 'Tie' - {if} computer_choice {is} rock - {if} your_choice {is} paper - {print} 'You win!' - {if} your_choice {is} scissors - {print} 'You lose!' - # finish this code - ``` - 10: - story_text: | - Feeling too lazy to play the game yourself? Let Hedy play it for you! - example_code: | - ``` - choices = rock, paper, scissors - players = Marleen, Michael - {for} player {in} players - {print} player ' chooses ' choices {at} {random} - ``` - 13: - story_text: | - With the `{and}` command you can shorten your rock, paper, scissors code! Check out the example code below and try to finish it. - example_code: | - ``` - options = 'rock', 'paper', 'scissors' - your_choice = {ask} 'What do you choose?' - computer_choice = options {at} {random} - {print} 'You choose ' your_choice - {print} 'The computer chooses ' computer_choice - {if} computer_choice {is} your_choice - {print} 'Tie' - {if} computer_choice {is} 'rock' {and} your_choice {is} 'paper' - {print} 'You win!' - {if} computer_choice {is} 'rock' {and} your_choice {is} 'scissors' - {print} 'The computer wins!' - ``` - 15: - example_code: | - ``` - won = 'no' - options = 'rock', 'paper', 'scissors' - {while} won == 'no' - your_choice = {ask} 'What do you choose?' - computer_choice = options {at} {random} - {print} 'you chose ' your_choice - {print} 'the computer chose ' computer_choice - {if} computer_choice == your_choice - {print} 'Tie!' - {if} computer_choice == 'rock' {and} your_choice == 'scissors' - {print} 'You lose!' - {if} computer_choice == 'rock' {and} your_choice == 'paper' - {print} 'You win!' - won = 'yes' - ``` - rock_2: - levels: - 2: - story_text: | - Now that you have learned how to use the `{ask} command, you can make your rock, paper, scissors code interavtive too! - - ### Exercise - Make the rock, paper, scissors code interactive by adding the `{ask}` command and a question to your rock, paper, scissors code. - example_code: | - ``` - choice is _ - {print} I choose choice - ``` - secret: - levels: - 12: - story_text: | - In this adventure you can create your own super spy code. Encode a message that only the right agent can decipher. - If the enemy tries to crack the code, they will get some false info to waste their time. - example_code: | - ``` - name {is} {ask} 'What is your name?' - {if} name {is} '_' - a {is} 'Go to the airport ' - {else} - a {is} 'Go to the trainstation ' - password {is} {ask} 'What is the password?' - {if} password {is} _ - b {is} 'tomorrow at 02.00' - {else} - b {is} 'today at 10.00' - {print} _ _ _ - ``` - 13: - story_text: | - The code you made in the previous level can be made a lot easier in this one with the `{and}` command. - sleep_command: - description: introducing sleep command - levels: - 2: - story_text: | - ## The sleep command - Another new command in this level is `{sleep}`, which pauses your program for a second. If you type a number behind the {sleep} command, the program pauses for that amount of seconds. - songs: - levels: - 6: - story_text: | - Songs often contain a lot of repetition. Sometimes the repetition is also based on counting. - For example, in the well-known song 'Bottles of beer'. You can program that song with a little math. - example_code: | - ``` - verse = 99 - {print} verse ' bottles of beer on the wall' - {print} verse ' bottles of beer' - {print} 'Take one down, pass it around' - verse = verse - 1 - {print} verse ' bottles of beer on the wall' - ``` - - You can now repeat lines 2 to 9 as many times as you want by copying the lines. - example_code_2: | - ``` - number = 6 - number = number - 1 - print number ' little monkeys jumping on the bed' - print 'One fell off and bumped his head' - print 'Mama called the doctor and the doctor said' - print 'NO MORE MONKEYS JUMPING ON THE BED!' - sleep - ``` - 7: - story_text: | - Songs often contain a lot of repetition. For example... Baby Shark! If you sing it, you keep singing the same thing: - - Baby Shark tututudutudu
- Baby Shark tututudutudu
- Baby Shark tututudutudu
- Baby Shark - - You can make this song much shorter with a `{repeat}`! Can you finish the code? - example_code: | - ``` - {repeat} _ _ {print} 'Baby Shark tututudutudu' - {print} 'Baby Shark' - ``` - - After Baby Shark you can of course also program other songs. There are many songs with repetition. - 8: - story_text: | - In a previous level you've programmed the song 'Bottles of beer'. You made one verse and then had to copy the verses 99 times. In level 7 you can repeat the song 99 times, just by adding one simple line! - example_code: | - ``` - verse = 99 - {repeat} 99 {times} - {print} verse ' bottles of beer on the wall' - {print} verse ' bottles of beer' - {print} 'Take one down, pass it around' - verse = verse - 1 - {print} verse ' bottles of beer on the wall' - ``` - 10: - story_text: | - In this level you can easily make the childrens' song 'Five little monkeys'. Can you make the last chorus? - You can also make the whole baby shark song (including all the other sharks in the family) in only 6 lines! - Or you can make Old MacDonald with all the different animals. - example_code: | - ``` - monkeys = 5, 4, 3, 2 - {for} monkey {in} monkeys - {print} monkey ' little monkeys jumping on the bed' - {print} 'One fell off and bumped his head' - {print} 'Mama called the doctor and the doctor said' - {print} 'NO MORE MONKEYS JUMPING ON THE BED!' - ``` - - ``` - sharks = baby, mommy, daddy, grandma, grandpa - {for} shark {in} sharks - {print} shark 'tututututudu' - {print} shark 'tututututudu' - {print} shark 'tututututudu' - {print} shark - ``` - ``` - animals = pig, dog, cow - {for} animal {in} animals - {if} animal {is} pig - sound = oink - {if} animal {is} dog - sound = woof - {if} animal {is} cow - sound = moo - {print} 'Old MacDonald had a farm' - {print} 'E I E I O!' - {print} 'and on that farm he had a ' animal - {print} 'E I E I O!' - {print} 'with a ' sound sound ' here' - {print} 'and a ' sound sound ' there' - {print} 'here a ' sound - {print} 'there a ' sound - {print} 'everywhere a ' sound sound - ``` - story_text_2: | - ### Exercise 2 - Print the song Five little moneys jumping on the bed. Look up the text if you don't remember. - - **(extra)** Print the song Old MacDonald had a farm, and make sure all animals make a different sound, using an `{if}`. - 11: - story_text: | - In this level you can use the `{for} i {in} {range}` command to make songs that use counting. - example_code: | - ``` - {for} i {in} {range} 5 {to} 1 - {print} i ' little monkeys jumping on the bed' - {print} 'One fell off and bumped his head' - {print} 'Mama called the doctor and the doctor said' - {if} i {is} 1 - {print} 'PUT THOSE MONKEYS RIGHT TO BED!' - {else} - {print} 'NO MORE MONKEYS JUMPING ON THE BED!' - ``` - songs_2: - levels: - 12: - example_code: | - ``` - {define} twinkle - {print} 'Twinkle' - {print} '...' - - {call} twinkle - {print} 'Up above the world so high' - {print} 'Like a diamond in the sky' - {call} _ - ``` - turtle: - levels: - 1: - story_text: | - You can also use Hedy to draw. By combining turns and lines, you can make a square or stairs! - - Using `{forward}` you draw a line forwards. The number behind it determines how far the turtle will walk. `{turn} {right}` turns a quarter turn in clockwise direction, `{turn} {left}` turns counter clockwise. - If you want to go backwards, you use the `{forward}` command but with a negative number. So for example `{forward} -100` - 3: - story_text: | - In this level you can use use `{at} {random}` with the drawing turtle. A random choice makes the turtle walk a different path each time. - Use `{at} {random}` to choose a value from a list. You can copy and paste lines 2 and 3 to create a longer random path. - 4: - example_code: | - ``` - {print} 'Drawing figures' - angle {is} 90 - {turn} angle - {forward} 25 - {turn} angle - {forward} 25 - ``` - 5: - example_code_2: | - ``` - direction {is} {ask} 'Do you want to go left, right, or straight ahead?' - if direction is left turn _ - if direction is right turn _ - forward 100 - ``` - 8: - story_text: | - Now that we can repeat several lines, we can make figures more easily. - We only have to set the angle once and then use that variable in the `{repeat}`. - example_code: | - ``` - angle = 90 - {repeat} 10 {times} - {turn} angle - {forward} 50 - ``` - story_text_2: | - Also, we can now improve the program that draws different figures. - Can you figure out how far the turtle has to turn here? Finish the code and you can draw any polygon you'd like! - 9: - story_text: | - Now that we can use a `{repeat}` inside a `{repeat}`, we can create more complex figures. - - ### Exercise 1 - This code creates three black triangles, change that into five pink squares. - - **(extra)** Create a figure of your own choosing consisting of at least two different shapes types. - 10: - story_text: | - In this level you can make the turtle draw a figure. - The turtle will travel the distances in the list, one by one, making bigger and bigger steps. - ### Exercise 1 - Add a 90 degree turn in the loop, so that a spiral is drawn. - Add at least 5 numbers to the list, so the spiral grows larger. - **(extra)** can you change the spiral into another shape? Experiment with numbers for the turn! - ### Exercise 2 - The spiral is drawn outwards, make it go inwards? - turtle_draw_it: - levels: - 9: - example_code: | - Hint for the nested squares: - ``` - colors = red, blue, orange, yellow, pink, purple, green, brown, black - distance = 120 - repeat 5 times - _ - ``` - Hint for the flags: - ``` - country = ask 'which country would you like to see the flag of?' - if country is 'the Netherlands' - color_1 = red - color_2 = white - color_3 = blue - ``` - 10: - example_code: | - Hint Nested Hexagon: - ``` - distances = 100, 80, 60, 40, 20 - {for} distance {in} distances - _ - ``` - - Hint Traffic Lights: - ``` - colors = red, yellow, green - {for} chosen_color {in} colors - color _ - {repeat} _ - ``` - 12: - story_text: | - ### Exercise - Recreate the drawings with the turtle! - Hint: Bracelet designing program. Firstly, define a function **for each shape** you want to use on the bacelet. Then, add the shapes to the bacelet like this: - - Bracelet Designing program - example_code: | - ``` - {define} draw_a_square - _ - - {color} white - {turn} -90 - {forward} 300 - {turn} 180 - - {for} i {in} {range} 1 {to} 5 - {color} gray - {forward} 100 - shape = {ask} 'What kind of shape would you like next on the bracelet?' - chosen_color = {ask} 'In which color?' - {color} chosen_color - {if} shape = 'square' - {call} draw_a_square - ``` - while_command: - description: while - years: - description: Countdown to the new year! - levels: - 11: - story_text: | - In this level you can use the `{for} i {in} {range}` command to countdown to the New Year. - - ### Exercise - Fill in the blanks and make the code work! - example_code: | - ``` - for _ in _ 10 to 1 - {print} i - {print} 'Happy New Year!' - ``` diff --git a/content/adventures/hi.yaml b/content/adventures/hi.yaml index 7a09e673241..de34397ef9a 100644 --- a/content/adventures/hi.yaml +++ b/content/adventures/hi.yaml @@ -253,440 +253,10 @@ adventures: 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. - 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_2: "```\nanimals {is} dog, cat, kangaroo\ndislike {is} {ask} What animal do you not like?\n{remove} dislike {from} animals\n{print} I choose animals {at} {random}\n```\n" - example_code: "```\nanimals {is} dog, cat, kangaroo\nlike {is} {ask} What is your favorite animal?\n{add} like {to_list} animals\n{print} I choose animals {at} {random}\n```\n" story_text_2: "## से हटाएँ\nयदि आप किसी सूची में आइटम जोड़ सकते हैं, तो निश्चित रूप से आप उन्हें हटा भी सकते हैं। यह `{remove} {from}` कमांड के साथ किया जाता है।\n" and_or_command: 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: "```\nname = {ask} 'what is your name?'\nage = {ask} 'what is your age?'\n{if} name {is} 'Hedy' {and} age {is} 2\n {print} 'You are the real Hedy!'\n```\n" default_save_name: और या - ask_command: - description: Introduction ask command - levels: - 1: - 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. - 2: - example_code_2: | - ``` - favorite_animal is ask What is your favorite animal? - print I like favorite_animal - ``` - name: '{ask}' - calculator: - levels: - 6: - story_text: | - Now that you can calculate, you can also create a program to practice maths calculations. You can make up the calculations yourself, for example: - example_code: | - ``` - correct_answer = 11 * 27 - answer = {ask} 'How much is 11 times 27?' - {if} answer {is} correct_answer {print} 'good job!' - {else} {print} 'Wrong! It was ' correct_answer - ``` - story_text_2: | - You can also let the computer do random calculations on its own using {random}. - example_code_2: | - ``` - tables = 4, 5, 6, 8 - numbers = 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 - table = tables {at} {random} - number = numbers {at} {random} - correct_answer = table * number - answer = {ask} 'how much is ' table ' times ' number '?' - {if} answer {is} correct_answer {print} 'okay' - {else} {print} 'mistake! it was ' correct_answer - ``` - 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`. - 11: - example_code: | - ``` - number = 10 - {for} i {in} {range} 1 to 10 - {print} i * number - ``` - 12: - story_text: | - Now you can make a calculator that works for decimal numbers. - example_code: | - ``` - number1 = {ask} 'What is the first number?' - number2 = {ask} 'What is the second number?' - answer = number1 + number2 - {print} number1 ' plus ' number2 ' is ' answer - 14: - 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 - clear_command: - description: clear command - debugging: - levels: - 3: - 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} - ``` - 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! - 8: - 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: - 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!' - {else} - 'I'm sorry we don't sell that' - topping {is} {ask} 'What kind of topping would you like?' - sauce {is} {ask} 'What kind of sauce would you like?' - {print} One chosen_bread with topping and sauce. - price = amount * 6 - {print} 'That will be 'price dollar' please' - ``` - - price = amount * 6 - {print} 'That will be 'price dollar' please' - 10: - example_code: | - **Warning! This code needs to be debugged!** - ``` - names = Muad Hasan Samira Noura - activities = fly a kite, go swimming, go hiking, catch tan in the sun - {for} name {is} names - {print} At the beach name loves to activity at random - ``` - 11: - story_text: |- - ### Exercise - Debug this calender program. The output of this program is supposed to look like a list of dates. - For example: - - ``` - Hedy calender - Here are all the days of November - November 1 - November 2 - November 3 - ``` - And so on. - - Mind that you have to test your code extra carefully for the month February, because the amount of days in this month changes in leap years। - example_code: | - **Warning! This code needs to be debugged!** - ``` - print 'Hedy calender' - months_with_31 days = January, March, May, July, September, October, December - months_with_30_days = April, June, August, November - month = ask 'Which month would you like to see?' - if month in months_with_31_days - days = 31 - if month in months_with30_days - days = 30 - if month = February - leap_years = 2020, 2024, 2028, 2036, 2040, 2044, 2028 - year = ask 'What year is it?' - if year in leap_years - days = 29 - else - days = 28 - - print 'Here are all the days of ' moth - for i in range 1 to days - print month i - ``` - 12: - example_code: | - **Warning! This code needs to be debugged!** - ``` - define greet - greetings = 'Hello', 'Hi there', 'Goodevening' - print greetings at random - - define take_order - food = ask 'What would you like to eat?' - print 'One food' - drink = 'What would you like to drink?' - print 'One ' drink - more = ask 'Would you like anything else?' - if more is 'no' - print 'Alright' - else - print 'And ' more - print 'Thank you' - - print 'Welcome to our restaurant' - people = ask 'How many people are in your party tonight?' - for i in range 0 to people - call greet_costumer - ``` - 13: - example_code: | - **Warning! This code needs to be debugged!** - ``` - defin movie_recommendation with name - action_movies == 'Die Hard', 'Fast and Furious', 'Inglorious Bastards' - romance_movies = 'Love Actually', 'The Notebook', 'Titanic' - comedy_movies = 'Mr Bean' 'Barbie''Deadpool' - kids_movies = 'Minions', 'Paddington', 'Encanto' - if name is 'Camila' or name is 'Manuel' - recommended_movie = kids_movie at random - if name is 'Pedro' or 'Gabriella' - mood = ask 'What you in the mood for?' - if mood is 'action' - recommended_movie = comedy_movies at random - if mood is 'romance' - recommended_movie = romance_movies - if mood is 'comedy' - recommended_movie = comedy_movies at random - - print 'I would recommend ' recommended_movie ' for ' name - - name = ask 'Who is watching?' - recommendation = ask 'Would you like a recommendation?' - if recommendaion is 'yes' - print movie_recommendation with name - else - print 'No problem!' - ``` - 14: - example_code: | - **Warning! This code needs to be debugged!** - ``` - define calculate_heartbeat - print 'Press your fingertips gently against the side of your neck' - print '(just under your jawline)' - print 'Count the number of beats you feel for 15 seconds' - beats == ask 'How many beats do you feel in 15 seconds?' - heartbeat = beats*4 - print 'Your heartbeat is ' heartbeat - if heartbeat >= 60 or heartbeat <= 100 - print 'Your heartbeat seems fine' - else - if heartbeat > 60 - print 'Your heartbeat seems to be too low' - if heartbeat < 100 - print 'Your heartbeat seems to be too high' - print 'You might want to contact a medical professional' - - measure_heartbeat = ask 'Would you like to measure your heartbeat?' - if measure_heartbeat = 'yes' - call measure_heartbeat - else - 'no problem' - ``` - - print '(just under your jawline)' - print 'Count the number of beats you feel for 15 seconds' - beats == ask 'How many beats do you feel in 15 seconds?' - heartbeat = beats*4 - print 'Your heartbeat is ' heartbeat - if heartbeat >= 60 or heartbeat <= 100 - print 'Your heartbeat seems fine' - else - if heartbeat > 60 - print 'Your heartbeat seems to be too low' - if heartbeat < 100 - print 'Your heartbeat seems to be too high' - print 'You might want to contact a medical professional' - - measure_heartbeat = ask 'Would you like to measure your heartbeat?' - if measure_heartbeat = 'yes' - call measure_heartbeat - else - 'no problem' - 15: - example_code: | - **Warning! This code needs to be debugged!** - ``` - names = 'Tanya', 'Romy', 'Kayla', 'Aldrin', 'Ali' - verbs='walking', 'skipping', 'cycling', 'driving', 'running' - locations = 'on a mountaintop', 'in the supermarket', 'to the swimming pool' - hiding_spots = 'behind a tree', under a table', in a box' - sounds = 'a trumpet', 'a car crash', 'thunder' - causes_of_noise = 'a television', 'a kid with firecrackers', 'a magic elephant', 'a dream' - - chosen_ name = names at random - chosen_verb = verbs at random - chosen_location = 'locations at random' - chosen_sounds = noises at random - chosen_spot = hiding_spots random - chosen_causes = causes_of_noise at random - - print chosen_name ' was ' chosen_verb ' ' chosen_location - print 'when they suddenly heard a sound like ' sounds at random - print chosen_name ' looked around, but they couldn't discover where the noise came from' - print chosen_name ' hid ' chosen_spot' - print 'They tried to look around, but couldn't see anything from there' - hidden = 'yes' - while hidden = 'yes' - print chosen_name 'still didn't see anything' - answer = ask 'does ' chosen_name ' move from their hiding spot?' - if answer = 'yes' - hidden == 'no' - print 'chosen_name moved from' chosen_spot - print 'And then they saw it was just' chosen_cause - print chosen_name 'laughed and went on with their day' - print The End - ``` - 16: - story_text: |- - ### Exercise - Debug this code. Good luck! - Tip: Make sure that you only see your score once in the end। - example_code: | - **Warning! This code needs to be debugged!** - ``` - country = ['The Netherlands', 'Poland', 'Turkey', 'Zimbabwe', 'Thailand', 'Brasil', 'Peru', 'Australia', 'India', 'Romania' ] - capitals = 'Amsterdam', 'Warshaw' 'Istanbul', 'Harare', 'Bangkok', 'Brasilia', 'Lima', 'Canberra', 'New Delhi', 'Bucharest' - score = 0 - for i in range 0 to 10 - answer = ask 'What's the capital of ' countries[i] - correct = capital[i] - if answer = correct - print 'Correct!' - score = score + 1 - else - print 'Wrong,' capitals[i] 'in the capital of' countries[i] - print 'You scored ' score ' out of 10' - - ``` - 17: - example_code: | - **Warning! This code needs to be debugged!** - ``` - define food_order - toppings = ask 'pepperoni, tuna, veggie or cheese?' - size = ask 'big, medium or small?' - number_of_pizza = ask 'How many these pizzas would you like?' - - print 'YOU ORDERED' - print number_of_pizzas ' size ' topping ' pizza' - - define drinks_order - drink = ask 'water, coke, icetea, lemonade or coffee?' - number_of_drinks = ask 'How many of these drinks would you like?' - - print 'YOU ORDERED' - print number_of_drinks ' ' drink - - 'Welcome to Hedy pizza' - more_food = ask 'Would you like to order a pizza?' - while more_food = 'yes' - return food_order - more_food = ask 'Would you like to order a pizza?' - more_drinks = ask 'Would you like to order some drinks?' - while more_drinks == 'yes' - call drink_order - more_drinks == ask 'Would you like to order more drinks?' - - - print 'Thanks for ordering!' - ``` - 18: - example_code: | - **Warning! This code needs to be debugged!** - ``` - animals = ['pig', 'dog', 'cow'] - sounds = ['oink', 'woof', 'moo'] - for i in range 1 to 3 - animal = animals[i] - sound = sounds[i] - print 'Old MacDonald had a farm' - print 'E I E I O!' - print 'and on that farm he had a ' animal - print 'E I E I O!' - print 'with a ' sound sound ' here' - print 'and a ' sound sound ' there' - print 'here a ' sound - print 'there a ' sound - print 'everywhere a ' sound sound - ``` default: description: स्तर स्पष्टीकरण levels: @@ -874,1373 +444,3 @@ adventures: इस स्तर में आप एक नई कमांड का भी उपयोग कर सकते हैं: `{elif}`। {elif}` `{else} {if}` के लिए आशुलिपि है और जब आप 3 (या अधिक!) विकल्प बनाना चाहते हैं तो आपको इसकी आवश्यकता होती है। इसकी जांच - पड़ताल करें! - 18: - story_text: |- - We arrived at real Python code! That means we need to use parentheses with {print} and {range} from now on. - {print}('My name is ', naam) - dice: - levels: - 3: - example_code: | - ``` - choices {is} 1, 2, 3, 4, 5, earthworm - {print} choices {at} {random} - ``` - 4: - story_text: | - In this level we can make sentences with the die value in the sentence, with quotes of course. - This time the sample code is not quite complete. Can you finish the code? - 5: - story_text: | - You can also make a die again in this level using the `{if}`. - Complete the sample code so that the code says "You can stop throwing" once you have thrown an earthworm. - - But maybe you want to recreate a die from a completely different game. That's fine too! Then make up your own reaction. Eg 'yes' for 6 and 'pity' for something {else}. - example_code: | - ``` - choices {is} 1, 2, 3, 4, 5, earthworm - throw {is} _ - {print} 'you have' _ 'thrown' - {if} _ {is} earthworm {print} 'You can stop throwing.' _ {print} 'You have to hear it again!' - ``` - 6: - story_text: | - You can also make an Earthworm die again in this, but now you can also calculate how many points have been rolled. - You may know that the worm counts 5 points for Earthworms. Now after a roll you can immediately calculate how many points you have thrown. - This is the code to calculate points for one die: - example_code: | - ``` - choices = 1, 2, 3, 4, 5, earthworm - points = 0 - throw = choices {at} {random} - {print} 'you threw' throw - {if} throw {is} earthworm points = points + 5 {else} points = points + throw - {print} 'those are' points ' point' - ``` - Can you make the code so that you get the total score for 8 dice? To do that, you have to cut and paste some lines of the code. - example_code_2: | - Did you manage to calculate the score for 8 dice? That required a lot of cutting and pasting, right? We are going to make that easier in level 7! - 7: - story_text: | - You can also make a die again in level 5. With the `{repeat}` code you can easily roll a whole hand of dice. - Try to finish the sample code! The dashes should contain multiple commands and characters. - - But maybe you want to make a completely different die. Of course you can! - example_code: | - ``` - choices = 1, 2, 3, 4, 5, earthworm - {repeat} _ _ {print} _ _ _ - ``` - 10: - story_text: | - Is everybody taking too long throwing the dice? In this level you can let Hedy throw all the dice at once! - example_code: | - ``` - players = Ann, John, Jesse - choices = 1, 2, 3, 4, 5, 6 - {for} player {in} players - {print} player ' throws ' choices {at} {random} - {sleep} - ``` - dishes: - description: Use the computer to see who does the dishes (Start at level 2) - levels: - 3: - story_text: | - Do you always disagree at home about who should wash the dishes or change the litter box today? - Then you can let the computer choose very fairly. You can program that in this level! - You first make a list of the members of your family. Then choose '{at} {random}' from the list. - example_code: | - ``` - people {is} mom, dad, Emma, Sophie - {print} people {at} {random} - ``` - Don't feel like doing the dishes yourself? Hack the program to remove your name from the list. - - ``` - people {is} mom, dad, Emma, Sophie - your_name {is} {ask} Who are you? - {remove} your_name {from} people - {print} people {at} {random} does the dishes - ``` - story_text_2: | - Don't feel like doing the dishes yourself? Hack the program to remove your name from the list. - 4: - story_text: | - With quotation marks you can make your dishwashing planning more beautiful. - This time the sample code is not quite complete. - - Can you complete the code by filling the blanks? Every blank must be replaced with one word of symbol. - - Tip: Don't forget the quotation marks! - 5: - story_text: | - With the `{if}` you can now have more fun with choice in the program. You can have your program respond to the choice that the computer has made. - - Can you finish the code so that it prints 'too bad' when it is your turn and otherwise 'yes!'? - Don't forget the quotes! - example_code: | - ``` - people {is} mom, dad, Emma, Sophie - dishwasher {is} people {at} {random} - {if} dishwasher {is} Sophie {print} _ too bad I have to do the dishes _ {else} {print} 'luckily no dishes because' _ 'is already washing up' - ``` - 6: - story_text_2: | - If you are extremely unlucky the previous program might choose you to to the dishes for the whole week! That's not fair! - To create a fairer system you can use the `{remove}` command to remove the chosen person from the list. This way you don't have to do the dishes again untill everybody has had a turn. - - Monday and tuesday are ready for you! Can you add the rest of the week? - And... can you come up with a solution for when your list is empty? - example_code_2: | - ``` - people = mom, dad, Emma, Sophie - dishwasher = people {at} {random} - {print} 'Monday the dishes are done by: ' dishwasher - {remove} dishwasher {from} people - dishwasher = people {at} {random} - {print} 'Tuesday the dishes are done by: ' dishwasher - {remove} dishwasher {from} people - dishwasher = people {at} {random} - ``` - 7: - story_text: | - With the `{repeat}` you can repeat pieces of code. You can use this to calculate who will be washing dishes for the entire week. - example_code: | - ``` - people = mom, dad, Emma, Sophie - {repeat} _ _ {print} 'the dishwasher is' _ - ``` - 10: - story_text: | - In this level you could make an even better dish washing shedule. - elif_command: - description: elif - levels: - 17: - example_code: | - ``` - prices = ['1 million dollars', 'an apple pie', 'nothing'] - your_price = prices[{random}] - {print} 'You win ' your_price - {if} your_price == '1 million dollars' : - {print} 'Yeah! You are rich!' - {elif} your_price == 'an apple pie' : - {print} 'Lovely, an apple pie!' - {else}: - {print} 'Better luck next time..' - ``` - for_command: - description: for command - levels: - 10: - story_text: |- - ## For - In this level we learn a new code called `{for}`. With `{for}` you can make a list and use all elements. - `{for}` creates a block, like `{repeat}` and `{if}` so all lines in the block need to start with 4 spaces। - 11: - story_text: |- - In this level, we add a new form of the `{for}`. In earlier levels, we used `{for}` with a list, but we can also use `{for}` with numbers. - We do that by adding a variable name, followed by `{in}` `{range}`. We then write the number to start at, `{to}` and the number to end at. - Try the example to see what happens! In this level again, you will need to use indentations in lines below the `{for}` statements. - fortune: - levels: - 1: - story_text: | - Have you ever been to a carnival and had your future predicted by a fortune teller? Or have you ever played with a magic eight ball? - Then you probably know that they can't really predict your future, but it's still fun to play! - - In the upcoming levels you can learn how to create your own fortune telling machine! - In level 1 you can start off easy by letting Hedy introduce herself as a fortune teller and let her {echo} the players' answers. - Like this: - example_code: | - ``` - {print} Hello, I'm Hedy the fortune teller! - {ask} Who are you? - {print} Let me take a look in my crystal ball - {print} I see... I see... - {echo} Your name is - ``` - - Hedy now only tells you your name. Can you expand the code so that Hedy can predict more things about you? - - Obviously, Hedy isn't a very good fortune teller yet, as she can only repeat the answers that were given by the players! - Take a look in level 2 to improve your fortune teller. - story_text_2: | - ### Exercise - Hedy now only tells you your name. Can you expand the code so that Hedy can predict more things about you? - Obviously, Hedy isn't a very good fortune teller yet, as she can only repeat the answers that were given by the players! - Take a look in level 2 to improve your fortune teller. - 3: - story_text: | - In the previous levels you've created your first fortune telling machine, but Hedy couldn't really predict anything, only {echo}. - In this level you can use a variable and the `{at} {random}` command to really let Hedy choose an answer for you. Check out this code for instance: - example_code: | - In this example the player can {ask} Hedy a yes-no question and Hedy will pick a random answer for you. - ``` - {print} I’m Hedy the fortune teller! - question {is} {ask} What do you want to know? - {print} This is what you want to know: question - answers {is} yes, no, maybe - {print} My crystal ball says... - {sleep} 2 - {print} answers {at} {random} - ``` - - Now, Hedy can only answer yes, no or maybe. Can you give Hedy more answer options, like 'definitely' or '{ask} again'. - story_text_2: | - ### Exercises - Now, Hedy can only answer yes, no or maybe. Can you give Hedy more answer options, like 'definitely' or '{ask} again'. - 4: - example_code: | - ``` - {print} 'Im Hedy the fortune teller!' - question {is} {ask} 'What do you want to know?' - {print} 'This is your question: ' question - answers {is} yes, no, maybe - {print} 'My crystal ball says...' - {sleep} 2 - {print} answers {at} {random} - ``` - 5: - story_text: | - In this level you'll learn to (secretly) tip the odds in your favor, when using the fortune teller! - By using `{if}` and `{else}` you can make sure that you will always get a good fotune, while other people might not. - Check out this example to find out how. - example_code: | - ``` - {print} 'Im Hedy the fortune teller!' - {print} 'I can predict {if} youll win the lottery tomorrow!' - person {is} {ask} 'Who are you?' - {if} person {is} Hedy {print} 'You will definitely win!🤩' {else} {print} 'Bad luck! Someone {else} will win!😭' - ``` - 6: - story_text: | - In this level you can use math in your predictions as a fortune teller. This allows you to make up (silly) formulas to calculate the future. - For example you could calculate how rich you'll get or how many kids you will have when you grow up. - example_code: | - ``` - {print} 'I am Hedy the fortune teller!' - {print} 'I can predict how many kids youll get when you grow up!' - age = {ask} 'How old are you?' - siblings = {ask} 'How many siblings do you have?' - length = {ask} 'How tall are you in centimetres?' - kids = length / age - kids = kids - siblings - {print} 'You will get ...' - {sleep} - {print} kids ' kids!' - ``` - - If the previous example wasn't silly enough for you, take a look at this one! - - ``` - {print} 'Im Hedy the silly fortune teller!' - {print} 'I will predict how smart you are!' - football = {ask} 'On a scale 1-10 how much do you love football?' - bananas = {ask} 'How many bananas did you eat this week?' - hygiene = {ask} 'How many times did you wash your hands today?' - result = bananas + hygiene - result = result * football - {print} 'You are ' result ' percent smart.' - ``` - 7: - story_text: | - In this level you can use the `{repeat}` command to make your machine tell multiple fortunes at once. - example_code: | - ``` - {print} 'Im Hedy the fortune teller!' - {print} 'You can {ask} 3 questions!' - {repeat} 3 {times} question = {ask} 'What do you want to know?' - answer = yes, no, maybe - {repeat} 3 {times} {print} 'My crystal ball says... ' answer {at} {random} - ``` - - As you can see, the questions aren't printed in this example. That's because the variable `question` was changed 3 times. - Every time the player fills in the new answer, Hedy overwrites the previous one, so the first answer the player gave is forgotten. - This means you can't print all the questions this way. - - By using 3 different variables instead of 1 (for example `question1` , `question2` and `question3`), you could solve the problem and print the questions. - This does mean that you can only use `{repeat}` for the answers, and you will have to ask and print all the questions separately. - Can you do it? - - In the upcoming levels the layout of {repeat} command will change, which enables you to repeat multiple lines at once. - 8: - story_text: | - In the previous levels you've learned how to use repeat to make the fortune teller answer 3 questions in a row, but we had a problem with printing the questions. - Now that problem is solved, because of the new way of using the repeat command. - In the next example you can have your fortune teller {ask} 3 questions and also print them! - example_code: | - ``` - {print} 'I am Hedy the fortune teller!' - {print} 'You can {ask} me 3 questions.' - answers = yes, no, maybe - {repeat} 3 {times} - question = {ask} 'What do you want to know?' - {print} question - {sleep} - {print} 'My crystal ball says...' answers {at} {random} - ``` - 10: - story_text: | - In this level you'll learn how to program the game MASH (mansion, apartement, shack, house). In this game you can predict for all the players at once, what their future will look like. - example_code: | - ``` - houses = mansion, apartment, shack, house - loves = nobody, a royal, their neighbour, their true love - pets = dog, cat, elephant - names = Jenna, Ryan, Jim - {for} name {in} names - {print} name ' lives in a ' houses {at} {random} - {print} name ' will marry ' loves {at} {random} - {print} name ' will get a ' pets {at} {random} ' as their pet.' - {sleep} - ``` - 12: - story_text: | - In this level you can make your fortunes multiple words. Like in this example below: - example_code: | - ``` - fortunes = 'you will be rich', 'you will fall in love', 'you will slip on a banana peel' - {print} 'I will take a look in my crystall ball for your future.' - {print} 'I see... I see...' - {sleep} - {print} fortunes {at} {random} - ``` - functions: - levels: - 12: - example_code: | - ``` - sides = 'left', 'right' - limbs = 'hand', 'foot' - colors = 'red', 'blue', 'green', 'yellow' - - {define} turn - chosen_side = sides {at} {random} - chosen_limb = limbs _ - chosen_color = colors _ - {print} chosen_side ' ' chosen_limb ' on ' chosen_color - - {print} 'Lets play a game of Twister!' - {for} i {in} {range} 1 to _ - {call} turn - {sleep} 2 - ``` - 13: - story_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. - - For example in this code we've programmed the first verse of the song 'My Bonnie is over the ocean'. - In this example code the argument `place` is used. Place is a variable that is only used in the function, so an argument. - To use `place` we have programmed the line `define song with place`. - When the function is called, computer will replace the argument `place`, with the piece of text after `call song with`. - - ### Exercise - The next verse of this song goes: - - Last night as I lay on my pillow - Last night as I lay on my bed - Last night as I lay on my pillow - I dreamed that my Bonnie is dead - - Can you program this verse in the same way as the example? - 14: - example_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?' - - new_price = _ calculate_new_price {with} old_price, _ - {print} 'The new price is ' new_price ' dollar' - ``` - haunted: - levels: - 1: - story_text: | - In this adventure you are working towards making a game in which you have to escape from a haunted house by picking the correct door. - If you pick the right door you'll survive, but {if} not a terrible monster might... - - In level 1 we start our haunted house game by making up a scary story and {ask} the player what monster they'll see in the haunted house. - story_text_2: | - Can you finish the scary story? Or make up your own haunted house story? - 2: - example_code: | - ``` - monster_1 {is} 👻 - monster_2 {is} 🤡 - monster_3 {is} 👶 - {print} You enter the haunted house. - {print} Suddenly you see a monster_1 - {print} You run into the other room, but a monster_2 is waiting there for you! - {print} Oh no! Quickly get to the kitchen. - {print} But as you enter monster_3 attacks you! - ``` - example_code_2: | - ``` - monster_1 {is} _ - monster_2 {is} _ - monster_3 {is} _ - {print} You enter the haunted house. - {print} Suddenly you see a monster_1 - {print} You run into the other room, but a monster_2 is waiting there for you! - {print} Oh no! Quickly get to the kitchen. - {print} But as you enter monster_3 attacks you! - ``` - 3: - story_text: | - In the previous levels you've made an introduction to your haunted house game, but as you might have noticed the story would always have a dreadful end. - In this level you can make your story more interactive by changing the outcome of the game; sometimes you'll get eaten, sometimes you'll escape! - Let Hedy decide randomly! - 4: - story_text: | - In this level you learn how to use quotation marks in your games. - Can you make your Haunted House level 4 proof? - example_code: | - ``` - {print} _Escape from the haunted house!_ - {print} _There are 3 doors in front of you..._ - choice {is} {ask} _Which door do you choose?_ - {print} _You picked door ..._ choice - monsters {is} a zombie, a vampire, NOTHING YOUVE ESCAPED - {print} _You see..._ - {sleep} - {print} monsters {at} {random} - ``` - 5: - story_text: | - Up until this level the haunted house game always asked the player to choose a door, but as you might have noticed, they didn't really have to answer correctly. - If the player filled in a completely random answer, the game would still work and the player might even win (despite not picking a door). - In this level you can only win the game by picking the same door Hedy picked randomly. - example_code: | - ``` - {print} 'Escape from the haunted house!' - {print} 'There are 3 doors in front of you...' - doors {is} 1, 2, 3 - monsters {is} werewolf, mummy, vampire, zombie - chosen_door {is} {ask} 'Which door do you choose?' - {print} 'You chose door...' chosen_door - {sleep} - correct_door {is} doors {at} {random} - {if} chosen_door {is} correct_door {print} 'Great! Youve escaped!' - {else} {print} 'Oh no! You are being eaten by a...' monsters {at} {random} - ``` - 9: - story_text: | - In this level you can use nesting, which allows you to make the haunted house even more interactive! - - Now it's very hard to win this game, can you make it easier to win? - For example by only having 1 wrong door and 2 correct doors instead of 1 correct door and 2 wrong ones? - 11: - story_text: | - In this level we've changed the repeat command and we've added a line to our haunted house that tells the player in which room they are. - example_code: | - ``` - {print} 'Escape from the Haunted House!' - player {is} alive - doors = 1, 2, 3 - monsters = zombie, vampire, giant spider - {for} i {in} {range} 1 {to} 3 - {if} player {is} alive - correct_door = doors {at} {random} - {print} 'Room ' i - {print} 'There are 3 doors in front of you...' - chosendoor = {ask} 'Which door do you choose?' - {if} chosendoor {is} correct_door - {print} 'No monsters here!' - {else} - {print} 'You are eaten by a ' monsters {at} {random} - player = dead - {else} - {print} 'GAME OVER' - {if} player {is} alive - {print} 'Great! You survived!' - ``` - if_command: - description: Introducing the if command - levels: - 9: - story_text: | - In this level you can also put an {if} command inside another {if} command. - in_command: - description: Introducing the in command - levels: - 5: - example_code_2: | - ``` - animals is dog, cow, sheep - answer is ask 'What is your favorite animal?' - _ answer _ animals _ 'Mine too!' - _ _ 'My favorite animals are dogs, cows and sheep' - ``` - is_command: - description: introducing is command - levels: - 2: - story_text_2: | - ### Exercise - Time to make your own variables! - In the example code we made an example of the variable `favorite_animal`. In line 1 the variable is set, and in line 2 we haved used the variable in a print command. - Firstly, finish our example by filling in your favorite animal on the blank. Then make at least 3 of these codes yourself. Pick a variable, and set the variable with the {is} command. Then use it with a {print} command, just like we did. - 14: - example_code: | - ``` - age = {ask} 'How old are you?' - {if} age > 12 - {print} 'You are older than I am!' - ``` - example_code_3: | - ``` - name = {ask} 'What is your name?' - {if} name != 'Hedy' - {print} 'You are not Hedy' - ``` - - {if} age < 13 - {print} 'You are younger than me!' - {else} - {print} 'You are older than me!' - language: - levels: - 5: - story_text: | - Make your own program to practice your vocabulary in a new language. - maths: - levels: - 6: - example_code: | - ``` - {print} '5 plus 5 is ' 5 + 5 - {print} '5 minus 5 is ' 5 - 5 - {print} '5 times 5 is ' 5 * 5 - ``` - 12: - story_text: |- - **Decimal numbers** - So far, Hedy did not allow for decimal numbers like 1.5, but now we do allow that. Note that computers use the `.` for decimal numbers। - example_code_2: | - ``` - a = 'Hello ' - b = 'world!' - {print} a + b - ``` - - {print} 2.5 + 2.5 - parrot: - name: तोता - default_save_name: तोता - description: अपना खुद का ऑनलाइन पालतू तोता बनाएं जो आपकी नकल करेगा! - levels: - 1: - story_text_2: | - ### Exercise - Can you make the parrot ask a different question? Fill in the blanks in the example! - 2: - story_text: | - Create your own online pet parrot that will copy you! - example_code: | - ``` - {print} Im Hedy the parrot - name {is} {ask} whats your name? - {print} name - {sleep} - {print} squawk - {sleep} - {print} name - ``` - story_text_2: | - ### Exercise - You can use variables to make the parrot say more than only your name. Can you complete this code? - 3: - story_text: | - Teach your parrot a new word with `{add}`. - example_code: | - ``` - words {is} squawk, Hedy - {print} Train your parrot! - new_word {is} {ask} Which word do you want to teach them? - {add} new_word {to_list} words - {print} 🧒 Say new_word , Hedy! - {print} 🦜 words {at} {random} - ``` - 4: - story_text: | - In this level we have to use quotation marks with the commands `{ask}` and `{print}`. - Can you complete the code by adding quotation marks? - 5: - story_text: | - Reward your parrot {if} it says the correct word! - example_code: | - ``` - words {is} squawk, Hedy - {print} 'Train your parrot!' - new_word {is} {ask} 'Which word do you want to teach them?' - {add} new_word {to_list} words - said_word {is} words {at} {random} - {print} '🧒 Say ' new_word ', Hedy!' - {print} '🦜 ' said_word - {if} said_word {is} new_word {print} '🧒 Great job, Hedy! 🍪' - {else} {print} '🧒 No, Hedy! Say ' new_word - ``` - piggybank: - levels: - 12: - story_text: | - In this adventure you learn how to make a digital piggy bank, to calculate how much money you have and how long you need to save up to buy what you want! - example_code: | - ``` - {print} 'The digital piggy bank' - wish = {ask} 'What would you like to buy?' - price = {ask} 'How much does that cost?' - saved = {ask} 'How much money have you saved already?' - allowance = {ask} 'How much pocket money do you get per week?' - to_save = price - saved - weeks = to_save / allowance - {print} 'You can buy a ' wish ' in ' weeks ' weeks.' - 14: - example_code: | - ``` - _ calculate_budget with wish, money, allowance - to_save = wish - money - weeks = to_save / allowance - {if} wish _ money - {print} 'You need to save up some more!' - {print} 'Youll need ' weeks ' more weeks.' - {else} - {print} 'Great! You have enough' - {print} 'Lets go shopping!' - - money = {ask} 'How much money have you saved?' - wish = {ask} 'How much money do you need?' - allowance = {ask} 'How much pocket money do you get each week?' - - {call} calculate_budget with _, _, _ - ``` - pressit: - levels: - 9: - story_text: | - Now that you know how to combine statements, you can create a touch type tool with `{pressed}`. - - ### Exercise - Finish the code. Each time a random letter should be chosen, which you have to press. You get a point for a correct press, and and two points deduction for a wrong press. - **(extra)** Clear the screen after each letter, and show the user how many points they have scored. - print_command: - levels: - 18: - story_text: |- - We arrived at real Python code! That means we need to use parentheses with `{print}` and `{range}` from now on. - It also means you can use Hedy code from this level in any Python environment as long as you use the English commands. If you haven't until now, you can switch the toggle in the commands menu to do so। - story_text_2: If you want to print more than one item, you need to separate them by commas। - example_code_2: | - ``` - temperature = 25 - {print}('It is ', temperature, ' degrees outside') - ``` - - {print}('My name is ', name) - random_command: - levels: - 16: - story_text: |- - We are going to make lists the Python way, with square brackets around the lists! We also keep the quotation marks around each item like we have learned in previous levels. - We use square brackets to point out a place in a list. The {at} {random} command can not be used anymore। - repeat_command: - description: repeat command - levels: - 7: - story_text: | - ## Repeat! Repeat! Repeat! - Level 7 adds the `{repeat}` command. `{repeat}` can be used to execute one line of code multiple times. Like this: - - ### Exercise - Play around with the repeat command. Can you make the happy birthday song in only 3 lines of code instead of 4 now? - 9: - story_text: | - Great job! You've reached another new level! In the previous level you've learned to use multiple lines of code in an {if} or {repeat} command. But you can't yet combine the two... - Good news! In this level you will be allowed to put an {if} inside an {if}, or inside a {repeat} command. Putting a block of code inside another block of code is called nesting. ``` Putting a block of code inside another block of code is called nesting. - example_code: | - ``` - answer = {ask} 'Are you ready to learn something new?' - {if} answer {is} yes - {print} 'Great! You can learn to use the repeat command in the if command!' - {print} 'Hooray!' - {print} 'Hooray!' - {print} 'Hooray!' - {else} - {print} 'Maybe you should practice some more in the previous level' - repeat_command_2: - description: repeat command 2 - levels: - 7: - story_text_2: | - Another interesting thing you can so with the `{repeat}` command is using variables to set the amount of times something should be repeated. In the example code you can see that we first ask the person how old they are. - Then, in line 3, the question is repeated 'age' times. So we have used the variable 'age' with the `{repeat}` command. - restaurant: - levels: - 1: - story_text_2: | - Can you think of more lines to add to your restaurant code? For example, can you {ask} the guests what they'd like to drink, tell them the price, or wish them a pleasant meal? - example_code_2: | - ``` - {print} Welcome to Hedy's restaurant 🍟 - {ask} What would you like to order? - {echo} So you would like to order - {print} Thanks you for your order! - {print} It's on its way! - ``` - 2: - story_text: | - In level 2 you could expand your restaurant by using variables. In level 1 Hedy could only {echo} the order once and only remember the last thing that was ordered. - Now you can use variables and Hedy can remember both the food and the drinks! - example_code: | - ``` - {print} Welcome to Hedy's restaurant! - {print} Today we're serving pizza or lasagna. - food {is} {ask} What would you like to eat? - {print} Great choice! The food is my favorite! - topping {is} {ask} Would you like meat or veggies on that? - {print} food with topping is on its way! - drinks {is} {ask} What would you like to drink with that? - {print} Thank you for your order. - {print} Your food and drinks will be right there! - ``` - story_text_2: | - ### Exercise - Can you make this code more elaborate? For example by adding drinks to the order? Or...? - 3: - example_code: | - ``` - {print} Welcome to Hedy's Random Restaurant! - {print} The only restaurant that will randomly choose your meal and its price for you! - starters {is} salad, soup, carpaccio - mains {is} pizza, brussels sprouts, spaghetti - desserts {is} brownies, ice cream, french cheeses - drinks {is} cola, beer, water - prices {is} 1 dollar, 10 dollars, 100 dollars - {print} You will start with: starters {at} {random} - {print} Then we'll serve: mains {at} {random} - {print} And as dessert: desserts {at} {random} - {print} You will get a drinks {at} {random} to drink - {print} That will be: prices {at} {random} - {print} Thank you and enjoy your meal! - ``` - story_text_2: | - Does your costumer have any allergies or do they dislike certain dishes? Then you can use the `{remove}`command to remove it from your menu. - example_code_2: | - ``` - {print} Mystery milkshake - flavors {is} strawberry, chocolate, vanilla - allergies {is} {ask} Are you allergic to any falvors? - {remove} allergies {from} flavors - {print} You get a flavors {at} {random} milkshake - ``` - 4: - story_text: | - ### Exercise - Add the quotation marks to this code to make it work! Be careful: variables should not be in quotation marks. - Then, use the `{clear}` command to only show one line at a time in your output screen. - - ### Exercise 2 - Go back to the previous level and copy your restaurant code. Make the code work in this level by adding quotation marks in the right spots and add some `{clear}` commands. - 5: - story_text: | - In this level the {if} command allows you to {ask} your customers questions and give different responses to the answers. - In the example below, you see that you can {ask} the customer {if} they want to hear the specials and Hedy can respond accordingly. - example_code: | - ``` - {print} 'Welcome to Hedys restaurant!' - special {is} {ask} 'Would you like to hear our specials today?' - {if} special {is} yes {print} 'Todays special is chicken piri piri and rice.' {else} {print} 'No problem.' - food {is} {ask} 'What would you like to eat?' - {print} 'One ' food ', coming right up!' - drink {is} {ask} 'What would you like to drink with that?' - {if} drink {is} cola {print} 'Im sorry, we are out of cola!' {else} {print} 'Great choice!' - anything {is} {ask} 'Would you like anything {else}?' - {print} 'Let me repeat your order...' - {print} 'One ' food - {if} drink {is} cola {print} 'and...' {else} {print} 'One ' drink - {if} anything {is} no {print} 'Thats it!' {else} {print} 'One ' anything - {print} 'Thank you for your order and enjoy your meal!' - ``` - 6: - story_text: | - In this level you can use maths to calculate the total price of your customer's order, which can make your virtual restaurant more realistic. - 7: - story_text: | - In this level you've learned how to use the {repeat} command to repeat a line of code a certain amount of times. - You can use that in your restaurant to {ask} multiple people what they'd like to eat. Like this: - example_code: | - ``` - {print} 'Welcome to Hedys restaurant!' - people = {ask} 'How many people are joining us today?' - {repeat} people times food = {ask} 'What would you like to eat?' - {print} 'Thanks for your order! Its coming right up!' - ``` - 9: - story_text: | - In this level you can use nesting to make your restaurant more realistic and more fun! - For example you would {ask} for sauce {if} somebody orders fries, but you wouldn't {if} someone orders pizza! - Check out the example, and try this at your own virtual restaurant! - example_code: | - ``` - {print} 'Welcome to Hedys restaurant!' - people = {ask} 'How many people will be joining us today?' - {print} 'Great!' - price = 0 - {repeat} people {times} - food = {ask} 'What would you like to order?' - {print} food - {if} food {is} fries - price = price + 3 - sauce = {ask} 'What kind of sauce would you like with your fries?' - {if} sauce {is} no - {print} 'no sauce' - {else} - price = price + 1 - {print} 'with ' sauce - {if} food {is} pizza - price = price + 4 - {print} 'That will be ' price ' dollar' - {print} 'Enjoy your meal!' - ``` - 10: - story_text: | - In this level you'll learn how to easily {ask} your guests' orders in a short code. - example_code: | - ``` - courses = appetizer, main course, dessert - {for} course {in} courses - food = {ask} 'What would you like to eat as your ' course '?' - {print} food ' will be your ' course - ``` - example_code_2: | - ``` - courses = appetizer, main course, dessert - names = Timon, Onno - {for} name {in} names - {for} course {in} courses - food = {ask} name ', what would you like to eat as your ' course '?' - {print} name ' orders ' food ' as their ' course - ``` - 11: - story_text: | - We can use the `{for} i {in} {range} 1 {to} 5` to {print} the orders from multiple customers in an orderly manner. - example_code: | - ``` - {print} 'Welcome to Restaurant Hedy!' - people = {ask} 'For how many people would you like to order?' - {for} i {in} {range} 1 {to} people - {print} 'Order number ' i - food = {ask} 'What would you like to eat?' - {print} food - {if} food {is} fries - sauce = {ask} 'What kind of sauce would you like with that?' - {print} sauce - drinks = {ask} 'What would you like to drink?' - {print} drinks - price = 4 * people - {print} 'That will be ' price ' dollars, please!' - ``` - 12: - story_text: | - From this level on you can use decimal numbers to make you menu more realistic. - example_code: | - ``` - price = 0 - food = {ask} 'What would you like to order?' - drink = {ask} 'What would you like to drink?' - {if} food {is} 'hamburger' - price = price + 6.50 - {if} food {is} 'pizza' - price = price + 5.75 - {if} drink {is} 'water' - price = price + 1.20 - {if} drink {is} 'soda' - price = price + 2.35 - {print} 'That will be ' price ' dollar, please' - ``` - 13: - story_text: | - In this level we can use the new commands to upgrade our restaurant. - We use `{and}` to see {if} two things are both the case. - example_code: | - ``` - price = 10 - food = {ask} 'What would you like to eat?' - drinks = {ask} 'What would you like to drink?' - {if} food {is} 'sandwich' {and} drinks {is} 'juice' - {print} 'Thats our discount menu' - price = price - 3 - {print} 'That will be ' price ' dollars' - ``` - rock: - default_save_name: Rock - levels: - 1: - example_code: | - ``` - {print} what do you choose? - {ask} choose {from} rock, paper or scissors - {echo} so your choice was: - ``` - Instead of using words, you could also use emojis of course: ✊✋✌ - 2: - story_text: | - In this level you can practise using the variables, so that you can make the rock, paper, scissors game in the next level! - example_code: | - ``` - choice {is} _ - {print} I choose choice - ``` - 3: - example_code: | - ``` - choices {is} rock, paper, scissors - {print} choices {at} {random} - ``` - story_text_2: | - ### Exercise - Now you only have one player, so can you add a second player? - You can even use variables to name player 1 and player 2. - example_code_2: | - ``` - choices {is} rock, paper, scissors - {print} player 1 chooses... choices {at} {random} - {print} player 2 _ - ``` - 5: - story_text: | - In this level we can determine who won. - For that you need the new `{if}` code. - - Save your choice with the name of choice and the choice of computer as computer choice. - Then you can use `{if}` to see {if} they are the same or different. - Will you finish the code? - example_code: | - ``` - options {is} rock, paper, scissors - computer_choice {is} _ - choice {is} {ask} What do you choose? - {print} 'you chose ' _ - {print} 'computer chose ' _ - {if} _ {is} _ {print} 'tie!' {else} {print} 'no tie' - ``` - - Fill in the correct code on the blanks to see {if} it is a draw. - 9: - story_text: | - In this level you can program the whole rock, paper, scissors game by nesting the {if}-commands. Can you finish the code? - example_code: | - ``` - choices = rock, paper, scissors - your_choice = {ask} 'What do you choose?' - {print} 'You choose ' your_choice - computer_choice = choices {at} {random} - {print} 'The computer chooses ' computer_choice - {if} computer_choice {is} your_choice - {print} 'Tie' - {if} computer_choice {is} rock - {if} your_choice {is} paper - {print} 'You win!' - {if} your_choice {is} scissors - {print} 'You lose!' - # finish this code - ``` - 10: - story_text: | - Feeling too lazy to play the game yourself? Let Hedy play it for you! - example_code: | - ``` - choices = rock, paper, scissors - players = Marleen, Michael - {for} player {in} players - {print} player ' chooses ' choices {at} {random} - ``` - 13: - story_text: | - With the `{and}` command you can shorten your rock, paper, scissors code! Check out the example code below and try to finish it. - example_code: | - ``` - options = 'rock', 'paper', 'scissors' - your_choice = {ask} 'What do you choose?' - computer_choice = options {at} {random} - {print} 'You choose ' your_choice - {print} 'The computer chooses ' computer_choice - {if} computer_choice {is} your_choice - {print} 'Tie' - {if} computer_choice {is} 'rock' {and} your_choice {is} 'paper' - {print} 'You win!' - {if} computer_choice {is} 'rock' {and} your_choice {is} 'scissors' - {print} 'The computer wins!' - ``` - 15: - example_code: | - ``` - won = 'no' - options = 'rock', 'paper', 'scissors' - {while} won == 'no' - your_choice = {ask} 'What do you choose?' - computer_choice = options {at} {random} - {print} 'you chose ' your_choice - {print} 'the computer chose ' computer_choice - {if} computer_choice == your_choice - {print} 'Tie!' - {if} computer_choice == 'rock' {and} your_choice == 'scissors' - {print} 'You lose!' - {if} computer_choice == 'rock' {and} your_choice == 'paper' - {print} 'You win!' - won = 'yes' - rock_2: - levels: - 2: - story_text: | - Now that you have learned how to use the `{ask} command, you can make your rock, paper, scissors code interavtive too! - - ### Exercise - Make the rock, paper, scissors code interactive by adding the `{ask}` command and a question to your rock, paper, scissors code. - example_code: | - ``` - choice is _ - {print} I choose choice - ``` - secret: - default_save_name: language - levels: - 12: - story_text: | - In this adventure you can create your own super spy code. Encode a message that only the right agent can decipher. - If the enemy tries to crack the code, they will get some false info to waste their time. - example_code: | - ``` - name {is} {ask} 'What is your name?' - {if} name {is} '_' - a {is} 'Go to the airport ' - {else} - a {is} 'Go to the trainstation ' - password {is} {ask} 'What is the password?' - {if} password {is} _ - b {is} 'tomorrow at 02.00' - {else} - b {is} 'today at 10.00' - {print} _ _ _ - ``` - 13: - story_text: | - The code you made in the previous level can be made a lot easier in this one with the `{and}` command. - sleep_command: - description: introducing sleep command - levels: - 2: - story_text: | - ## The sleep command - Another new command in this level is `{sleep}`, which pauses your program for a second. If you type a number behind the {sleep} command, the program pauses for that amount of seconds. - songs: - levels: - 6: - story_text: | - Songs often contain a lot of repetition. Sometimes the repetition is also based on counting. - For example, in the well-known song 'Bottles of beer'. You can program that song with a little math. - example_code: | - ``` - verse = 99 - {print} verse ' bottles of beer on the wall' - {print} verse ' bottles of beer' - {print} 'Take one down, pass it around' - verse = verse - 1 - {print} verse ' bottles of beer on the wall' - ``` - - You can now repeat lines 2 to 9 as many times as you want by copying the lines. - example_code_2: | - ``` - number = 6 - number = number - 1 - print number ' little monkeys jumping on the bed' - print 'One fell off and bumped his head' - print 'Mama called the doctor and the doctor said' - print 'NO MORE MONKEYS JUMPING ON THE BED!' - sleep - ``` - 7: - story_text: | - Songs often contain a lot of repetition. For example... Baby Shark! If you sing it, you keep singing the same thing: - - Baby Shark tututudutudu
- Baby Shark tututudutudu
- Baby Shark tututudutudu
- Baby Shark - - You can make this song much shorter with a `{repeat}`! Can you finish the code? - example_code: | - ``` - {repeat} _ _ {print} 'Baby Shark tututudutudu' - {print} 'Baby Shark' - ``` - - After Baby Shark you can of course also program other songs. There are many songs with repetition. - 8: - story_text: | - In a previous level you've programmed the song 'Bottles of beer'. You made one verse and then had to copy the verses 99 times. In level 7 you can repeat the song 99 times, just by adding one simple line! - example_code: | - ``` - verse = 99 - {repeat} 99 {times} - {print} verse ' bottles of beer on the wall' - {print} verse ' bottles of beer' - {print} 'Take one down, pass it around' - verse = verse - 1 - {print} verse ' bottles of beer on the wall' - ``` - 10: - story_text: | - In this level you can easily make the childrens' song 'Five little monkeys'. Can you make the last chorus? - You can also make the whole baby shark song (including all the other sharks in the family) in only 6 lines! - Or you can make Old MacDonald with all the different animals. - example_code: | - ``` - monkeys = 5, 4, 3, 2 - {for} monkey {in} monkeys - {print} monkey ' little monkeys jumping on the bed' - {print} 'One fell off and bumped his head' - {print} 'Mama called the doctor and the doctor said' - {print} 'NO MORE MONKEYS JUMPING ON THE BED!' - ``` - - ``` - sharks = baby, mommy, daddy, grandma, grandpa - {for} shark {in} sharks - {print} shark 'tututututudu' - {print} shark 'tututututudu' - {print} shark 'tututututudu' - {print} shark - ``` - ``` - animals = pig, dog, cow - {for} animal {in} animals - {if} animal {is} pig - sound = oink - {if} animal {is} dog - sound = woof - {if} animal {is} cow - sound = moo - {print} 'Old MacDonald had a farm' - {print} 'E I E I O!' - {print} 'and on that farm he had a ' animal - {print} 'E I E I O!' - {print} 'with a ' sound sound ' here' - {print} 'and a ' sound sound ' there' - {print} 'here a ' sound - {print} 'there a ' sound - {print} 'everywhere a ' sound sound - ``` - story_text_2: | - ### Exercise 2 - Print the song Five little moneys jumping on the bed. Look up the text if you don't remember. - - **(extra)** Print the song Old MacDonald had a farm, and make sure all animals make a different sound, using an `{if}`. - 11: - story_text: | - In this level you can use the `{for} i {in} {range}` command to make songs that use counting. - example_code: | - ``` - {for} i {in} {range} 5 {to} 1 - {print} i ' little monkeys jumping on the bed' - {print} 'One fell off and bumped his head' - {print} 'Mama called the doctor and the doctor said' - {if} i {is} 1 - {print} 'PUT THOSE MONKEYS RIGHT TO BED!' - {else} - {print} 'NO MORE MONKEYS JUMPING ON THE BED!' - ``` - songs_2: - levels: - 12: - example_code: | - ``` - {define} twinkle - {print} 'Twinkle' - {print} '...' - - {call} twinkle - {print} 'Up above the world so high' - {print} 'Like a diamond in the sky' - {call} _ - ``` - turtle: - default_save_name: turtle - levels: - 1: - story_text: | - In level 1 you can also use Hedy to draw. By combining turns and lines, you can make a square or a stair! - - Using `{forward}` you draw a line forwards. The number behind it determines how far the turtle will walk. `{turn} right` turns a quarter turn in clockwise direction, `{turn} left` turns counter clockwise. - 2: - story_text: | - In level 1 the turtle could only turn left or right. That is a bit boring! - In level 2 he can point his nose in all directions. - - Use 90 to turn a quarter. We call this degrees. A full turn is 360 degrees. - Can you make a figure with this code? Maybe a triangle or a circle? - example_code: | - ``` - {print} Drawing figures - angle {is} 90 - {turn} angle - {forward} 25 - {turn} angle - {forward} 25 - ``` - story_text_2: | - Also, in level 1 the turtle could only turn left or right. That is a bit boring! - In level 2 he can point his nose in all directions. - - Use 90 to turn a quarter. We call this degrees. A full turn is 360 degrees. - Can you make a figure with this code? Maybe a triangle or a circle? - example_code_2: | - ``` - {print} Drawing figures - angle {is} 90 - {turn} angle - {forward} 25 - {turn} angle - {forward} 25 - ``` - 3: - story_text: | - In this level you can use use `{random}` with the drawing turtle. A random choice makes the turtle walk a different path each time. - Use `{at} {random}` to choose a value from a list. You can copy and paste lines 2 and 3 to create a longer random path. - 4: - example_code: | - ``` - {print} 'Drawing figures' - angle {is} 90 - {turn} angle - {forward} 25 - {turn} angle - {forward} 25 - ``` - 5: - example_code_2: | - ``` - direction {is} {ask} 'Do you want to go left, right, or straight ahead?' - if direction is left turn _ - if direction is right turn _ - forward 100 - ``` - 8: - story_text: | - Now that we can repeat several lines, we can make figures more easily. - We only have to set the angle once and then use that variable in the `{repeat}`. - example_code: | - ``` - angle = 90 - {repeat} 10 {times} - {turn} angle - {forward} 50 - ``` - story_text_2: | - Also, we can now improve the program that draws different figures. - Can you figure out how far the turtle has to turn here? Finish the code and you can draw any polygon you'd like! - 9: - story_text: | - Now that we can use a `{repeat}` inside a `{repeat}`, we can create more complex figures. - - ### Exercise 1 - This code creates three black triangles, change that into five pink squares. - - **(extra)** Create a figure of your own choosing consisting of at least two different shapes types. - 10: - story_text: | - In this level you can make the turtle draw a figure. - The turtle will travel the distances in the list, one by one, making bigger and bigger steps. - ### Exercise 1 - Add a 90 degree turn in the loop, so that a spiral is drawn. - Add at least 5 numbers to the list, so the spiral grows larger. - **(extra)** can you change the spiral into another shape? Experiment with numbers for the turn! - ### Exercise 2 - The spiral is drawn outwards, make it go inwards? - turtle_draw_it: - levels: - 9: - example_code: | - Hint for the nested squares: - ``` - colors = red, blue, orange, yellow, pink, purple, green, brown, black - distance = 120 - repeat 5 times - _ - ``` - Hint for the flags: - ``` - country = ask 'which country would you like to see the flag of?' - if country is 'the Netherlands' - color_1 = red - color_2 = white - color_3 = blue - ``` - 10: - example_code: | - Hint Nested Hexagon: - ``` - distances = 100, 80, 60, 40, 20 - {for} distance {in} distances - _ - ``` - - Hint Traffic Lights: - ``` - colors = red, yellow, green - {for} chosen_color {in} colors - color _ - {repeat} _ - ``` - 12: - story_text: | - ### Exercise - Recreate the drawings with the turtle! - Hint: Bracelet designing program. Firstly, define a function **for each shape** you want to use on the bacelet. Then, add the shapes to the bacelet like this: - - Bracelet Designing program - example_code: | - ``` - {define} draw_a_square - _ - - {color} white - {turn} -90 - {forward} 300 - {turn} 180 - - {for} i {in} {range} 1 {to} 5 - {color} gray - {forward} 100 - shape = {ask} 'What kind of shape would you like next on the bracelet?' - chosen_color = {ask} 'In which color?' - {color} chosen_color - {if} shape = 'square' - {call} draw_a_square - ``` - while_command: - description: while - years: - description: Countdown to the new year! - levels: - 11: - story_text: | - In this level you can use the `{for} i {in} {range}` command to countdown to the New Year. - - ### Exercise - Fill in the blanks and make the code work! - example_code: | - ``` - for _ in _ 10 to 1 - {print} i - {print} 'Happy New Year!' - ``` diff --git a/content/adventures/hr.yaml b/content/adventures/hr.yaml index 682e6770bd8..0967ef424bc 100644 --- a/content/adventures/hr.yaml +++ b/content/adventures/hr.yaml @@ -1,12 +1 @@ -adventures: - rock: - levels: - 2: - story_text: "In this level you can practise using the variables, so that you can make the rock, paper, scissors game in the next level!\n### Exercise\nFinish the code by filling in the **variable** on the blanks.\nThis game is not very interactive, but no worries! In the next tab you'll learn how to use variables with the `{ask}` command to make your game interactive!\n" - turtle: - levels: - 2: - example_code: "```\nanswer {is} {ask} How many steps should the turtle make?\n{forward} answer\n```\n" - example_code_2: "```\n{print} Drawing figures\nangle {is} 90\n{turn} angle\n{forward} 25\n{turn} angle\n{forward} 25\n```\n" - story_text: "In this level you can use variables to make the turtle interactive. For example you can ask the player how many steps the turtle must make.\n" - story_text_2: "Also, in level 1 the turtle could only turn left or right. That is a bit boring!\nIn level 2 he can point his nose in all directions.\n\nUse 90 to turn a quarter. We call this degrees. A full turn is 360 degrees.\n\n### Exercise\nCan you make a figure with this code? Maybe a triangle or a circle?\n" +{} diff --git a/content/adventures/hu.yaml b/content/adventures/hu.yaml index ce52f648045..7cdfe7ec683 100644 --- a/content/adventures/hu.yaml +++ b/content/adventures/hu.yaml @@ -89,129 +89,6 @@ adventures: repeat 5 times print 'Segítség!' print 'Miért nem segít nekem senki?' ``` - 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! - 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. - 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: - 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!' - add_remove_command: - name: '{add} {to} & {remove} {from}' - 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. - 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. - and_or_command: - description: introducing and or - ask_command: - description: Introduction ask command - levels: - 1: - 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. calculator: name: Számológép default_save_name: Számológép @@ -270,359 +147,6 @@ adventures: pontszam = pontszam + 1 print 'Szép munka! A pontszámod... ' pontszam ' a 10-ből!' ``` - 11: - example_code: | - ``` - number = 10 - {for} i {in} {range} 1 to 10 - {print} i * number - ``` - 12: - story_text: | - Now you can make a calculator that works for decimal numbers. - example_code: | - ``` - number1 = {ask} 'What is the first number?' - number2 = {ask} 'What is the second number?' - answer = number1 + number2 - {print} number1 ' plus ' number2 ' is ' answer - 14: - 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 - clear_command: - description: clear command - debugging: - levels: - 3: - 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} - ``` - 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! - 8: - 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: - 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!' - {else} - 'I'm sorry we don't sell that' - topping {is} {ask} 'What kind of topping would you like?' - sauce {is} {ask} 'What kind of sauce would you like?' - {print} One chosen_bread with topping and sauce. - price = amount * 6 - {print} 'That will be 'price dollar' please' - ``` - - price = amount * 6 - {print} 'That will be 'price dollar' please' - 10: - example_code: | - **Warning! This code needs to be debugged!** - ``` - names = Muad Hasan Samira Noura - activities = fly a kite, go swimming, go hiking, catch tan in the sun - {for} name {is} names - {print} At the beach name loves to activity at random - ``` - 11: - story_text: |- - ### Exercise - Debug this calender program. The output of this program is supposed to look like a list of dates. - For example: - - ``` - Hedy calender - Here are all the days of November - November 1 - November 2 - November 3 - ``` - And so on. - - Mind that you have to test your code extra carefully for the month February, because the amount of days in this month changes in leap years. - example_code: | - **Warning! This code needs to be debugged!** - ``` - print 'Hedy calender' - months_with_31 days = January, March, May, July, September, October, December - months_with_30_days = April, June, August, November - month = ask 'Which month would you like to see?' - if month in months_with_31_days - days = 31 - if month in months_with30_days - days = 30 - if month = February - leap_years = 2020, 2024, 2028, 2036, 2040, 2044, 2028 - year = ask 'What year is it?' - if year in leap_years - days = 29 - else - days = 28 - - print 'Here are all the days of ' moth - for i in range 1 to days - print month i - ``` - 12: - example_code: | - **Warning! This code needs to be debugged!** - ``` - define greet - greetings = 'Hello', 'Hi there', 'Goodevening' - print greetings at random - - define take_order - food = ask 'What would you like to eat?' - print 'One food' - drink = 'What would you like to drink?' - print 'One ' drink - more = ask 'Would you like anything else?' - if more is 'no' - print 'Alright' - else - print 'And ' more - print 'Thank you' - - print 'Welcome to our restaurant' - people = ask 'How many people are in your party tonight?' - for i in range 0 to people - call greet_costumer - ``` - 13: - example_code: | - **Warning! This code needs to be debugged!** - ``` - defin movie_recommendation with name - action_movies == 'Die Hard', 'Fast and Furious', 'Inglorious Bastards' - romance_movies = 'Love Actually', 'The Notebook', 'Titanic' - comedy_movies = 'Mr Bean' 'Barbie''Deadpool' - kids_movies = 'Minions', 'Paddington', 'Encanto' - if name is 'Camila' or name is 'Manuel' - recommended_movie = kids_movie at random - if name is 'Pedro' or 'Gabriella' - mood = ask 'What you in the mood for?' - if mood is 'action' - recommended_movie = comedy_movies at random - if mood is 'romance' - recommended_movie = romance_movies - if mood is 'comedy' - recommended_movie = comedy_movies at random - - print 'I would recommend ' recommended_movie ' for ' name - - name = ask 'Who is watching?' - recommendation = ask 'Would you like a recommendation?' - if recommendaion is 'yes' - print movie_recommendation with name - else - print 'No problem!' - ``` - 14: - example_code: | - **Warning! This code needs to be debugged!** - ``` - define calculate_heartbeat - print 'Press your fingertips gently against the side of your neck' - print '(just under your jawline)' - print 'Count the number of beats you feel for 15 seconds' - beats == ask 'How many beats do you feel in 15 seconds?' - heartbeat = beats*4 - print 'Your heartbeat is ' heartbeat - if heartbeat >= 60 or heartbeat <= 100 - print 'Your heartbeat seems fine' - else - if heartbeat > 60 - print 'Your heartbeat seems to be too low' - if heartbeat < 100 - print 'Your heartbeat seems to be too high' - print 'You might want to contact a medical professional' - - measure_heartbeat = ask 'Would you like to measure your heartbeat?' - if measure_heartbeat = 'yes' - call measure_heartbeat - else - 'no problem' - ``` - - print '(just under your jawline)' - print 'Count the number of beats you feel for 15 seconds' - beats == ask 'How many beats do you feel in 15 seconds?' - heartbeat = beats*4 - print 'Your heartbeat is ' heartbeat - if heartbeat >= 60 or heartbeat <= 100 - print 'Your heartbeat seems fine' - else - if heartbeat > 60 - print 'Your heartbeat seems to be too low' - if heartbeat < 100 - print 'Your heartbeat seems to be too high' - print 'You might want to contact a medical professional' - - measure_heartbeat = ask 'Would you like to measure your heartbeat?' - if measure_heartbeat = 'yes' - call measure_heartbeat - else - 'no problem' - 15: - example_code: | - **Warning! This code needs to be debugged!** - ``` - names = 'Tanya', 'Romy', 'Kayla', 'Aldrin', 'Ali' - verbs='walking', 'skipping', 'cycling', 'driving', 'running' - locations = 'on a mountaintop', 'in the supermarket', 'to the swimming pool' - hiding_spots = 'behind a tree', under a table', in a box' - sounds = 'a trumpet', 'a car crash', 'thunder' - causes_of_noise = 'a television', 'a kid with firecrackers', 'a magic elephant', 'a dream' - - chosen_ name = names at random - chosen_verb = verbs at random - chosen_location = 'locations at random' - chosen_sounds = noises at random - chosen_spot = hiding_spots random - chosen_causes = causes_of_noise at random - - print chosen_name ' was ' chosen_verb ' ' chosen_location - print 'when they suddenly heard a sound like ' sounds at random - print chosen_name ' looked around, but they couldn't discover where the noise came from' - print chosen_name ' hid ' chosen_spot' - print 'They tried to look around, but couldn't see anything from there' - hidden = 'yes' - while hidden = 'yes' - print chosen_name 'still didn't see anything' - answer = ask 'does ' chosen_name ' move from their hiding spot?' - if answer = 'yes' - hidden == 'no' - print 'chosen_name moved from' chosen_spot - print 'And then they saw it was just' chosen_cause - print chosen_name 'laughed and went on with their day' - print The End - ``` - 16: - example_code: | - **Warning! This code needs to be debugged!** - ``` - country = ['The Netherlands', 'Poland', 'Turkey', 'Zimbabwe', 'Thailand', 'Brasil', 'Peru', 'Australia', 'India', 'Romania' ] - capitals = 'Amsterdam', 'Warshaw' 'Istanbul', 'Harare', 'Bangkok', 'Brasilia', 'Lima', 'Canberra', 'New Delhi', 'Bucharest' - score = 0 - for i in range 0 to 10 - answer = ask 'What's the capital of ' countries[i] - correct = capital[i] - if answer = correct - print 'Correct!' - score = score + 1 - else - print 'Wrong,' capitals[i] 'in the capital of' countries[i] - print 'You scored ' score ' out of 10' - - ``` - 17: - example_code: | - **Warning! This code needs to be debugged!** - ``` - define food_order - toppings = ask 'pepperoni, tuna, veggie or cheese?' - size = ask 'big, medium or small?' - number_of_pizza = ask 'How many these pizzas would you like?' - - print 'YOU ORDERED' - print number_of_pizzas ' size ' topping ' pizza' - - define drinks_order - drink = ask 'water, coke, icetea, lemonade or coffee?' - number_of_drinks = ask 'How many of these drinks would you like?' - - print 'YOU ORDERED' - print number_of_drinks ' ' drink - - 'Welcome to Hedy pizza' - more_food = ask 'Would you like to order a pizza?' - while more_food = 'yes' - return food_order - more_food = ask 'Would you like to order a pizza?' - more_drinks = ask 'Would you like to order some drinks?' - while more_drinks == 'yes' - call drink_order - more_drinks == ask 'Would you like to order more drinks?' - - - print 'Thanks for ordering!' - ``` - 18: - example_code: | - **Warning! This code needs to be debugged!** - ``` - animals = ['pig', 'dog', 'cow'] - sounds = ['oink', 'woof', 'moo'] - for i in range 1 to 3 - animal = animals[i] - sound = sounds[i] - print 'Old MacDonald had a farm' - print 'E I E I O!' - print 'and on that farm he had a ' animal - print 'E I E I O!' - print 'with a ' sound sound ' here' - print 'and a ' sound sound ' there' - print 'here a ' sound - print 'there a ' sound - print 'everywhere a ' sound sound - ``` default: name: Bevezető description: Szint magyarázat @@ -913,8 +437,6 @@ adventures: emberek is anya, apa, Edit, Gizi print emberek at random ``` - story_text_2: | - Don't feel like doing the dishes yourself? Hack the program to remove your name from the list. 4: story_text: | Az idézőjelek segítségével szebbé teheted a mosogatás tervezését. @@ -960,23 +482,6 @@ adventures: if mosogato is Edit edit_mosogat = edit_mosogat + 1 print 'Edit ezen a héten' edit_mosogat 'alkalommal mosogatott' ``` - story_text_2: | - If you are extremely unlucky the previous program might choose you to to the dishes for the whole week! That's not fair! - To create a fairer system you can use the `{remove}` command to remove the chosen person from the list. This way you don't have to do the dishes again untill everybody has had a turn. - - Monday and tuesday are ready for you! Can you add the rest of the week? - And... can you come up with a solution for when your list is empty? - example_code_2: | - ``` - people = mom, dad, Emma, Sophie - dishwasher = people {at} {random} - {print} 'Monday the dishes are done by: ' dishwasher - {remove} dishwasher {from} people - dishwasher = people {at} {random} - {print} 'Tuesday the dishes are done by: ' dishwasher - {remove} dishwasher {from} people - dishwasher = people {at} {random} - ``` 7: story_text: |- Az `repeat` segítségével megismételheted a kódrészleteket. Ennek segítségével @@ -986,33 +491,6 @@ adventures: emberek is anya, apa, Edit, Gizi repeat _ _ print 'a mosogató:' _ ``` - 10: - story_text: | - In this level you could make an even better dish washing shedule. - elif_command: - description: elif - levels: - 17: - example_code: | - ``` - prices = ['1 million dollars', 'an apple pie', 'nothing'] - your_price = prices[{random}] - {print} 'You win ' your_price - {if} your_price == '1 million dollars' : - {print} 'Yeah! You are rich!' - {elif} your_price == 'an apple pie' : - {print} 'Lovely, an apple pie!' - {else}: - {print} 'Better luck next time..' - ``` - for_command: - description: for command - levels: - 11: - story_text: |- - In this level, we add a new form of the `{for}`. In earlier levels, we used `{for}` with a list, but we can also use `{for}` with numbers. - We do that by adding a variable name, followed by `{in}` `{range}`. We then write the number to start at, `{to}` and the number to end at. - Try the example to see what happens! In this level again, you will need to use indentations in lines below the `{for}` statements. fortune: name: Jósnő default_save_name: Jósnő @@ -1147,85 +625,6 @@ adventures: print kerdes print 'A kristálygömböm azt mondja...' valasz at random ``` - 10: - story_text: | - In this level you'll learn how to program the game MASH (mansion, apartement, shack, house). In this game you can predict for all the players at once, what their future will look like. - example_code: | - ``` - houses = mansion, apartment, shack, house - loves = nobody, a royal, their neighbour, their true love - pets = dog, cat, elephant - names = Jenna, Ryan, Jim - {for} name {in} names - {print} name ' lives in a ' houses {at} {random} - {print} name ' will marry ' loves {at} {random} - {print} name ' will get a ' pets {at} {random} ' as their pet.' - {sleep} - ``` - 12: - story_text: | - In this level you can make your fortunes multiple words. Like in this example below: - example_code: | - ``` - fortunes = 'you will be rich', 'you will fall in love', 'you will slip on a banana peel' - {print} 'I will take a look in my crystall ball for your future.' - {print} 'I see... I see...' - {sleep} - {print} fortunes {at} {random} - ``` - functions: - levels: - 12: - example_code: | - ``` - sides = 'left', 'right' - limbs = 'hand', 'foot' - colors = 'red', 'blue', 'green', 'yellow' - - {define} turn - chosen_side = sides {at} {random} - chosen_limb = limbs _ - chosen_color = colors _ - {print} chosen_side ' ' chosen_limb ' on ' chosen_color - - {print} 'Lets play a game of Twister!' - {for} i {in} {range} 1 to _ - {call} turn - {sleep} 2 - ``` - 13: - story_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. - - For example in this code we've programmed the first verse of the song 'My Bonnie is over the ocean'. - In this example code the argument `place` is used. Place is a variable that is only used in the function, so an argument. - To use `place` we have programmed the line `define song with place`. - When the function is called, computer will replace the argument `place`, with the piece of text after `call song with`. - - ### Exercise - The next verse of this song goes: - - Last night as I lay on my pillow - Last night as I lay on my bed - Last night as I lay on my pillow - I dreamed that my Bonnie is dead - - Can you program this verse in the same way as the example? - 14: - example_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?' - - new_price = _ calculate_new_price {with} old_price, _ - {print} 'The new price is ' new_price ' dollar' - ``` haunted: name: Kísértetház default_save_name: Kísértetház @@ -1253,32 +652,6 @@ adventures: print ...? ``` Be tudod fejezni az ijesztő történetet? Vagy kitalálsz egy saját kísértetáz történetet? - story_text_2: | - ### Exercise - Can you finish the scary story? Or make up your own haunted house story? - 2: - example_code: | - ``` - monster_1 {is} 👻 - monster_2 {is} 🤡 - monster_3 {is} 👶 - {print} You enter the haunted house. - {print} Suddenly you see a monster_1 - {print} You run into the other room, but a monster_2 is waiting there for you! - {print} Oh no! Quickly get to the kitchen. - {print} But as you enter monster_3 attacks you! - ``` - example_code_2: | - ``` - monster_1 {is} _ - monster_2 {is} _ - monster_3 {is} _ - {print} You enter the haunted house. - {print} Suddenly you see a monster_1 - {print} You run into the other room, but a monster_2 is waiting there for you! - {print} Oh no! Quickly get to the kitchen. - {print} But as you enter monster_3 attacks you! - ``` 3: story_text: |- Az 1. szinten bemutatkoztál a kísértetház játékodnak, de ahogy észrevetted, a történetnek mindig rettenetes vége lesz. @@ -1295,17 +668,6 @@ adventures: story_text: |- A 3. szinten megtanulod használni az idézőjeleket a játékaidban. Át tudod alakítani a kisértetház játékot úgy, hogy megfeleljen a 3. szintnek? - example_code: | - ``` - {print} _Escape from the haunted house!_ - {print} _There are 3 doors in front of you..._ - choice {is} {ask} _Which door do you choose?_ - {print} _You picked door ..._ choice - monsters {is} a zombie, a vampire, NOTHING YOUVE ESCAPED - {print} _You see..._ - {sleep} - {print} monsters {at} {random} - ``` 5: story_text: |- Eddig a szintig a kísértetjárta ház játék mindig arra kérte a játékost, hogy válasszon egy ajtót, de ahogy észrevettétek, nem igazán kellett helyesen válaszolniuk. @@ -1323,33 +685,6 @@ adventures: if valasztottajto is helyesajto print 'Nagyszerű! Kiszabadultál!' else print 'Jaj ne! Megevett a ...' szornyek at random ``` - 9: - story_text: | - In this level you can use nesting, which allows you to make the haunted house even more interactive! - example_code: | - ``` - {print} 'Escape from the Haunted House!' - player = alive - doors = 1, 2, 3 - monsters = zombie, vampire, giant spider - {repeat} 3 {times} - {if} player {is} alive - correct_door {is} doors {at} {random} - {print} 'There are 3 doors in front of you...' - chosen_door = {ask} 'Which door do you choose?' - {if} chosen_door {is} correct_door - {print} 'No monsters here!' - {else} - {print} 'You are eaten by a ' monsters {at} {random} - player = dead - {else} - {print} 'GAME OVER' - {if} player {is} alive - {print} 'Great! You survived!' - ``` - ### Exercise - Now it's very hard to win this game, can you make it easier to win? - For example by only having 1 wrong door and 2 correct doors instead of 1 correct door en 2 wrong ones? 11: story_text: A 8. szinten megváltoztattuk az ismétlés parancsot, és hozzáadtunk egy sort a kísértetjárta házunkhoz, amely megmondja a játékosnak, hogy melyik szobában vannak. example_code: | @@ -1373,220 +708,6 @@ adventures: if jatekos is elo print 'Nagyszerű! Túlélted!' ``` - if_command: - description: Introducing the if command - levels: - 9: - story_text: | - In this level you can also put an {if} command inside another {if} command. - in_command: - description: Introducing the in command - levels: - 5: - example_code_2: | - ``` - animals is dog, cow, sheep - answer is ask 'What is your favorite animal?' - _ answer _ animals _ 'Mine too!' - _ _ 'My favorite animals are dogs, cows and sheep' - ``` - is_command: - description: introducing is command - levels: - 2: - story_text_2: | - ### Exercise - Time to make your own variables! - In the example code we made an example of the variable `favorite_animal`. In line 1 the variable is set, and in line 2 we haved used the variable in a print command. - Firstly, finish our example by filling in your favorite animal on the blank. Then make at least 3 of these codes yourself. Pick a variable, and set the variable with the {is} command. Then use it with a {print} command, just like we did. - 14: - example_code: | - ``` - age = {ask} 'How old are you?' - {if} age > 12 - {print} 'You are older than I am!' - ``` - example_code_3: | - ``` - name = {ask} 'What is your name?' - {if} name != 'Hedy' - {print} 'You are not Hedy' - ``` - - {if} age < 13 - {print} 'You are younger than me!' - {else} - {print} 'You are older than me!' - language: - levels: - 5: - story_text: | - Make your own program to practice your vocabulary in a new language. - maths: - levels: - 6: - example_code: | - ``` - {print} '5 plus 5 is ' 5 + 5 - {print} '5 minus 5 is ' 5 - 5 - {print} '5 times 5 is ' 5 * 5 - ``` - 12: - example_code_2: | - ``` - a = 'Hello ' - b = 'world!' - {print} a + b - ``` - - {print} 2.5 + 2.5 - music: - levels: - 6: - story_text: "Instead of playing notes, you can also play numbers now. Simply type `{play} 1` for the lowest note, `{play} 70` for the highest note, or anything in between.\n\n### Exercise\n This calls for musical maths! Try out the example code a couple of times with different starting numbers. \nThen, see if you can compose a song using the numbers.\n" - parrot: - levels: - 1: - story_text_2: | - ### Exercise - Can you make the parrot ask a different question? Fill in the blanks in the example! - 2: - story_text: | - Create your own online pet parrot that will copy you! - example_code: | - ``` - {print} Im Hedy the parrot - name {is} {ask} whats your name? - {print} name - {sleep} - {print} squawk - {sleep} - {print} name - ``` - story_text_2: | - ### Exercise - You can use variables to make the parrot say more than only your name. Can you complete this code? - 3: - story_text: | - Teach your parrot a new word with `{add}`. - example_code: | - ``` - words {is} squawk, Hedy - {print} Train your parrot! - new_word {is} {ask} Which word do you want to teach them? - {add} new_word {to_list} words - {print} 🧒 Say new_word , Hedy! - {print} 🦜 words {at} {random} - ``` - 4: - story_text: | - In this level we have to use quotation marks with the commands `{ask}` and `{print}`. - Can you complete the code by adding quotation marks? - 5: - story_text: | - Reward your parrot {if} it says the correct word! - example_code: | - ``` - words {is} squawk, Hedy - {print} 'Train your parrot!' - new_word {is} {ask} 'Which word do you want to teach them?' - {add} new_word {to_list} words - said_word {is} words {at} {random} - {print} '🧒 Say ' new_word ', Hedy!' - {print} '🦜 ' said_word - {if} said_word {is} new_word {print} '🧒 Great job, Hedy! 🍪' - {else} {print} '🧒 No, Hedy! Say ' new_word - ``` - piggybank: - levels: - 12: - story_text: | - In this adventure you learn how to make a digital piggy bank, to calculate how much money you have and how long you need to save up to buy what you want! - example_code: | - ``` - {print} 'The digital piggy bank' - wish = {ask} 'What would you like to buy?' - price = {ask} 'How much does that cost?' - saved = {ask} 'How much money have you saved already?' - allowance = {ask} 'How much pocket money do you get per week?' - to_save = price - saved - weeks = to_save / allowance - {print} 'You can buy a ' wish ' in ' weeks ' weeks.' - 14: - example_code: | - ``` - _ calculate_budget with wish, money, allowance - to_save = wish - money - weeks = to_save / allowance - {if} wish _ money - {print} 'You need to save up some more!' - {print} 'Youll need ' weeks ' more weeks.' - {else} - {print} 'Great! You have enough' - {print} 'Lets go shopping!' - - money = {ask} 'How much money have you saved?' - wish = {ask} 'How much money do you need?' - allowance = {ask} 'How much pocket money do you get each week?' - - {call} calculate_budget with _, _, _ - ``` - pressit: - levels: - 9: - story_text: | - Now that you know how to combine statements, you can create a touch type tool with `{pressed}`. - - ### Exercise - Finish the code. Each time a random letter should be chosen, which you have to press. You get a point for a correct press, and and two points deduction for a wrong press. - **(extra)** Clear the screen after each letter, and show the user how many points they have scored. - print_command: - levels: - 18: - example_code_2: | - ``` - temperature = 25 - {print}('It is ', temperature, ' degrees outside') - ``` - - {print}('My name is ', name) - random_command: - levels: - 16: - story_text: |- - We are going to make lists the Python way, with square brackets around the lists! We also keep the quotation marks around each item like we have learned in previous levels. - We use square brackets to point out a place in a list. For example: `friends[1]` is the first name on the list of friends, as you can see in the first part of the example code. The second part of the example code shows you that we can also match 2 lists using the variable i. - repeat_command: - description: repeat command - levels: - 7: - story_text: | - ## Repeat! Repeat! Repeat! - Level 7 adds the `{repeat}` command. `{repeat}` can be used to execute one line of code multiple times. Like this: - - ### Exercise - Play around with the repeat command. Can you make the happy birthday song in only 3 lines of code instead of 4 now? - 9: - story_text: | - Great job! You've reached another new level! In the previous level you've learned to use multiple lines of code in an {if} or {repeat} command. But you can't yet combine the two... - Good news! In this level you will be allowed to put an {if} inside an {if}, or inside a {repeat} command. Putting a block of code inside another block of code is called nesting. ``` Putting a block of code inside another block of code is called nesting. - example_code: | - ``` - answer = {ask} 'Are you ready to learn something new?' - {if} answer {is} yes - {print} 'Great! You can learn to use the repeat command in the if command!' - {print} 'Hooray!' - {print} 'Hooray!' - {print} 'Hooray!' - {else} - {print} 'Maybe you should practice some more in the previous level' - repeat_command_2: - description: repeat command 2 - levels: - 7: - story_text_2: | - Another interesting thing you can so with the `{repeat}` command is using variables to set the amount of times something should be repeated. In the example code you can see that we first ask the person how old they are. - Then, in line 3, the question is repeated 'age' times. So we have used the variable 'age' with the `{repeat}` command. restaurant: name: Étterem default_save_name: Étterem @@ -1624,9 +745,6 @@ adventures: print Köszönjük a rendelésedet. print A etel és ital mindjárt itt lesz! ``` - story_text_2: | - ### Exercise - Can you make this code more elaborate? For example by adding drinks to the order? Or...? 3: story_text: |- Nehezen tudod eldönteni, mit szeretnél vacsorázni? Engedheted, hogy Hedy válasszon neked! @@ -1648,24 +766,7 @@ adventures: print Ez lesz: arak at random print Köszönöm és élvezze az étkezést! ``` - story_text_2: | - Does your costumer have any allergies or do they dislike certain dishes? Then you can use the `{remove}`command to remove it from your menu. - example_code_2: | - ``` - {print} Mystery milkshake - flavors {is} strawberry, chocolate, vanilla - allergies {is} {ask} Are you allergic to any falvors? - {remove} allergies {from} flavors - {print} You get a flavors {at} {random} milkshake - ``` 4: - story_text: | - ### Exercise - Add the quotation marks to this code to make it work! Be careful: variables should not be in quotation marks. - Then, use the `{clear}` command to only show one line at a time in your output screen. - - ### Exercise 2 - Go back to the previous level and copy your restaurant code. Make the code work in this level by adding quotation marks in the right spots and add some `{clear}` commands. example_code: |- ``` _ Add the quotation marks to this code _ @@ -1769,27 +870,6 @@ adventures: print 'Ez ' ar ' forint lesz' print 'Köszönöm, jó étvágyat!!' ``` - 10: - story_text: | - In this level you'll learn how to easily {ask} your guests' orders in a short code. - example_code: | - ``` - courses = appetizer, main course, dessert - {for} course {in} courses - food = {ask} 'What would you like to eat as your ' course '?' - {print} food ' will be your ' course - ``` - story_text_2: | - Of course, you could also order for multiple people! - example_code_2: | - ``` - courses = appetizer, main course, dessert - names = Timon, Onno - {for} name {in} names - {for} course {in} courses - food = {ask} name ', what would you like to eat as your ' course '?' - {print} name ' orders ' food ' as their ' course - ``` 11: story_text: Az "for i in 1 in 5" tartományban használhatjuk a több vásárló megrendeléseinek rendezett kiíratására. example_code: | @@ -1808,38 +888,6 @@ adventures: ar is 400 * emberek print 'Ez ' ar ' forint lesz, kérem' ``` - 12: - story_text: | - From this level on you can use decimal numbers to make you menu more realistic. - example_code: | - ``` - price = 0 - food = {ask} 'What would you like to order?' - drink = {ask} 'What would you like to drink?' - {if} food {is} 'hamburger' - price = price + 6.50 - {if} food {is} 'pizza' - price = price + 5.75 - {if} drink {is} 'water' - price = price + 1.20 - {if} drink {is} 'soda' - price = price + 2.35 - {print} 'That will be ' price ' dollar, please' - ``` - 13: - story_text: | - In this level we can use the new commands to upgrade our restaurant. - We use `{and}` to see {if} two things are both the case. - example_code: | - ``` - price = 10 - food = {ask} 'What would you like to eat?' - drinks = {ask} 'What would you like to drink?' - {if} food {is} 'sandwich' {and} drinks {is} 'juice' - {print} 'Thats our discount menu' - price = price - 3 - {print} 'That will be ' price ' dollars' - ``` rock: name: Kő, papír, olló default_save_name: Kő @@ -1858,14 +906,6 @@ adventures: ask Válassz kő, papír és olló közül echo ez volt a választásod: ``` - 2: - story_text: | - In this level you can practise using the variables, so that you can make the rock, paper, scissors game in the next level! - example_code: | - ``` - choice {is} _ - {print} I choose choice - ``` 3: story_text: | A 2. szinten listákat írhatunk be, és választhatunk belőlük dolgokat. @@ -1886,16 +926,6 @@ adventures: valasztas is kő, papír, olló print valasztas at random ``` - story_text_2: | - ### Exercise - Now you only have one player, so can you add a second player? - You can even use variables to name player 1 and player 2. - example_code_2: | - ``` - choices {is} rock, paper, scissors - {print} player 1 chooses... choices {at} {random} - {print} player 2 _ - ``` 5: story_text: |- A 4. szinten meghatározhatjuk, hogy ki nyert. @@ -1916,113 +946,6 @@ adventures: if _ is _ print 'döntetlen!' else print 'nem döntetlen' if valaszt is kő and szamitogepe is papír print 'számítógép nyert' ``` - 9: - story_text: | - In this level you can program the whole rock, paper, scissors game by nesting the {if}-commands. Can you finish the code? - example_code: | - ``` - choices = rock, paper, scissors - your_choice = {ask} 'What do you choose?' - {print} 'You choose ' your_choice - computer_choice = choices {at} {random} - {print} 'The computer chooses ' computer_choice - {if} computer_choice {is} your_choice - {print} 'Tie' - {if} computer_choice {is} rock - {if} your_choice {is} paper - {print} 'You win!' - {if} your_choice {is} scissors - {print} 'You lose!' - # finish this code - ``` - 10: - story_text: | - Feeling too lazy to play the game yourself? Let Hedy play it for you! - example_code: | - ``` - choices = rock, paper, scissors - players = Marleen, Michael - {for} player {in} players - {print} player ' chooses ' choices {at} {random} - ``` - 13: - story_text: | - With the `{and}` command you can shorten your rock, paper, scissors code! Check out the example code below and try to finish it. - example_code: | - ``` - options = 'rock', 'paper', 'scissors' - your_choice = {ask} 'What do you choose?' - computer_choice = options {at} {random} - {print} 'You choose ' your_choice - {print} 'The computer chooses ' computer_choice - {if} computer_choice {is} your_choice - {print} 'Tie' - {if} computer_choice {is} 'rock' {and} your_choice {is} 'paper' - {print} 'You win!' - {if} computer_choice {is} 'rock' {and} your_choice {is} 'scissors' - {print} 'The computer wins!' - ``` - 15: - example_code: | - ``` - won = 'no' - options = 'rock', 'paper', 'scissors' - {while} won == 'no' - your_choice = {ask} 'What do you choose?' - computer_choice = options {at} {random} - {print} 'you chose ' your_choice - {print} 'the computer chose ' computer_choice - {if} computer_choice == your_choice - {print} 'Tie!' - {if} computer_choice == 'rock' {and} your_choice == 'scissors' - {print} 'You lose!' - {if} computer_choice == 'rock' {and} your_choice == 'paper' - {print} 'You win!' - won = 'yes' - rock_2: - levels: - 2: - story_text: | - Now that you have learned how to use the `{ask} command, you can make your rock, paper, scissors code interavtive too! - - ### Exercise - Make the rock, paper, scissors code interactive by adding the `{ask}` command and a question to your rock, paper, scissors code. - example_code: | - ``` - choice is _ - {print} I choose choice - ``` - secret: - default_save_name: language - levels: - 12: - story_text: | - In this adventure you can create your own super spy code. Encode a message that only the right agent can decipher. - If the enemy tries to crack the code, they will get some false info to waste their time. - example_code: | - ``` - name {is} {ask} 'What is your name?' - {if} name {is} '_' - a {is} 'Go to the airport ' - {else} - a {is} 'Go to the trainstation ' - password {is} {ask} 'What is the password?' - {if} password {is} _ - b {is} 'tomorrow at 02.00' - {else} - b {is} 'today at 10.00' - {print} _ _ _ - ``` - 13: - story_text: | - The code you made in the previous level can be made a lot easier in this one with the `{and}` command. - sleep_command: - description: introducing sleep command - levels: - 2: - story_text: | - ## The sleep command - Another new command in this level is `{sleep}`, which pauses your program for a second. If you type a number behind the {sleep} command, the program pauses for that amount of seconds. songs: name: Énekelj egy dalt! default_save_name: Dal @@ -2050,16 +973,6 @@ adventures: verssor = verssor - 1 print verssor ' üveg sör a falon' ``` - example_code_2: | - ``` - number = 6 - number = number - 1 - print number ' little monkeys jumping on the bed' - print 'One fell off and bumped his head' - print 'Mama called the doctor and the doctor said' - print 'NO MORE MONKEYS JUMPING ON THE BED!' - sleep - ``` 7: story_text: |- A dalok gyakran sok ismétlést tartalmaznak. Például... Baby Shark! Ha elénekled, ugyanazt énekled folyamatosan: @@ -2072,11 +985,6 @@ adventures: ezt a dalt sokkal rövidebbé teheted egy `repeat` utasítással! Be tudod fejezni a kódot? A Baby Shark után természetesen más dalokat is programozhat. Sok dal van ismétléssel. - example_code: |- - ``` - repeat _ _ print 'Baby Shark tututudutudu' - print 'Baby Shark' - ``` 8: story_text: A 6. szinten a "Üveg sör" dalt programoztad. Egy verset alkottál, majd 99 -szer kellett lemásolnod a verssorokat. A 7. szinten 99 alkalommal ismételheted meg a dalt, csak egy egyszerű sor hozzáadásával! example_code: | @@ -2088,95 +996,6 @@ adventures: verssor = verssor - 1 print verssor 'üveg sör a falon' ``` - 10: - story_text: | - In this level you can easily make the childrens' song 'Five little monkeys'. Can you make the last chorus? - You can also make the whole baby shark song (including all the other sharks in the family) in only 6 lines! - Or you can make Old MacDonald with all the different animals. - example_code: | - ``` - monkeys = 5, 4, 3, 2 - {for} monkey {in} monkeys - {print} monkey ' little monkeys jumping on the bed' - {print} 'One fell off and bumped his head' - {print} 'Mama called the doctor and the doctor said' - {print} 'NO MORE MONKEYS JUMPING ON THE BED!' - ``` - - ``` - sharks = baby, mommy, daddy, grandma, grandpa - {for} shark {in} sharks - {print} shark 'tututututudu' - {print} shark 'tututututudu' - {print} shark 'tututututudu' - {print} shark - ``` - ``` - animals = pig, dog, cow - {for} animal {in} animals - {if} animal {is} pig - sound = oink - {if} animal {is} dog - sound = woof - {if} animal {is} cow - sound = moo - {print} 'Old MacDonald had a farm' - {print} 'E I E I O!' - {print} 'and on that farm he had a ' animal - {print} 'E I E I O!' - {print} 'with a ' sound sound ' here' - {print} 'and a ' sound sound ' there' - {print} 'here a ' sound - {print} 'there a ' sound - {print} 'everywhere a ' sound sound - ``` - story_text_2: | - ### Exercise 2 - Print the song Five little moneys jumping on the bed. Look up the text if you don't remember. - - **(extra)** Print the song Old MacDonald had a farm, and make sure all animals make a different sound, using an `{if}`. - 11: - story_text: | - In this level you can use the `{for} i {in} {range}` command to make songs that use counting. - example_code: | - ``` - {for} i {in} {range} 5 {to} 1 - {print} i ' little monkeys jumping on the bed' - {print} 'One fell off and bumped his head' - {print} 'Mama called the doctor and the doctor said' - {if} i {is} 1 - {print} 'PUT THOSE MONKEYS RIGHT TO BED!' - {else} - {print} 'NO MORE MONKEYS JUMPING ON THE BED!' - ``` - 12: - story_text: | - In this song we can make it even easier to program '{if} you're happy and you know it, clap your hands'. Because we can put all of the actions in a variable, check it out: - example_code: | - ``` - actions = 'clap your hands', 'stomp your feet', 'shout Hurray!' - {for} action {in} actions - {for} i {in} {range} 1 {to} 2 - {print} '{if} youre happy and you know it' - {print} action - {print} '{if} youre happy and you know it and you really want to show it' - {print} '{if} youre happy and you know it' - {print} action - ``` - songs_2: - levels: - 12: - example_code: | - ``` - {define} twinkle - {print} 'Twinkle' - {print} '...' - - {call} twinkle - {print} 'Up above the world so high' - {print} 'Like a diamond in the sky' - {call} _ - ``` turtle: name: Teknős default_save_name: teknős @@ -2302,103 +1121,4 @@ adventures: turn szog forward 50 ``` - story_text_2: | - Also, we can now improve the program that draws different figures. - Can you figure out how far the turtle has to turn here? Finish the code and you can draw any polygon you'd like! example_code_2: "```\nszogek = {ask} 'How many angles should I draw?'\nszog = 360 / szogek \n{repeat} szogek {times}\n {turn} _\n {forward} _\n```\n" - 9: - story_text: | - Now that we can use a `{repeat}` inside a `{repeat}`, we can create more complex figures. - - ### Exercise 1 - This code creates three black triangles, change that into five pink squares. - - **(extra)** Create a figure of your own choosing consisting of at least two different shapes types. - 10: - story_text: | - In this level you can make the turtle draw a figure. - The turtle will travel the distances in the list, one by one, making bigger and bigger steps. - ### Exercise 1 - Add a 90 degree turn in the loop, so that a spiral is drawn. - Add at least 5 numbers to the list, so the spiral grows larger. - **(extra)** can you change the spiral into another shape? Experiment with numbers for the turn! - ### Exercise 2 - The spiral is drawn outwards, make it go inwards? - turtle_draw_it: - levels: - 9: - example_code: | - Hint for the nested squares: - ``` - colors = red, blue, orange, yellow, pink, purple, green, brown, black - distance = 120 - repeat 5 times - _ - ``` - Hint for the flags: - ``` - country = ask 'which country would you like to see the flag of?' - if country is 'the Netherlands' - color_1 = red - color_2 = white - color_3 = blue - ``` - 10: - example_code: | - Hint Nested Hexagon: - ``` - distances = 100, 80, 60, 40, 20 - {for} distance {in} distances - _ - ``` - - Hint Traffic Lights: - ``` - colors = red, yellow, green - {for} chosen_color {in} colors - color _ - {repeat} _ - ``` - 12: - story_text: | - ### Exercise - Recreate the drawings with the turtle! - Hint: Bracelet designing program. Firstly, define a function **for each shape** you want to use on the bacelet. Then, add the shapes to the bacelet like this: - - Bracelet Designing program - example_code: | - ``` - {define} draw_a_square - _ - - {color} white - {turn} -90 - {forward} 300 - {turn} 180 - - {for} i {in} {range} 1 {to} 5 - {color} gray - {forward} 100 - shape = {ask} 'What kind of shape would you like next on the bracelet?' - chosen_color = {ask} 'In which color?' - {color} chosen_color - {if} shape = 'square' - {call} draw_a_square - ``` - while_command: - description: while - years: - description: Countdown to the new year! - levels: - 11: - story_text: | - In this level you can use the `{for} i {in} {range}` command to countdown to the New Year. - - ### Exercise - Fill in the blanks and make the code work! - example_code: | - ``` - for _ in _ 10 to 1 - {print} i - {print} 'Happy New Year!' - ``` diff --git a/content/adventures/ia.yaml b/content/adventures/ia.yaml index 5d144a49130..0967ef424bc 100644 --- a/content/adventures/ia.yaml +++ b/content/adventures/ia.yaml @@ -1,319 +1 @@ -adventures: - story: - levels: - 12: - example_code: | - ``` - name = 'The Queen of England' - {print} name ' was eating a piece of cake, when suddenly...' - ``` - calculator: - levels: - 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`. - 14: - 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 - default: - levels: - 6: - story_text: | - In the previous level you have practiced with `{ask}` and `{if}`. For example you can ask guests what they would like to eat. - What you can't yet do though, is calculate the price for everyone's dinner. - - In the previous level you have practiced with `{ask}` and `{if}`. For example you can ask guests what they would like to eat. - What you can't yet do though, is calculate the price for everyone's dinner. - - This level makes it possible to use addition, subtraction and multiplication in your programs. This way you can calculate the prices in your restaurant, but you could also add a secret code to give your friends and family a discount. - Another option in this level is programming your own maths game, for your little brother or sister to practice their multiplications. - Go see for yourself! - 9: - story_text: | - Great job! You've reached another new level! In the previous level you've learned to use multiple lines of code in an {if} or {repeat} command. But you can't yet combine the two... - Good news! In this level you will be allowed to put an {if} inside an {if}, or inside a {repeat} command. Putting a block of code inside another block of code is called nesting. ``` - 17: - story_text: | - Now we are going to change indentation a little bit. Every time that we need an indentation, we need `:` at the line before the indentation. - - In this level you can also use a new command: `{elif}`. `{elif}` is short for `{else} {if}` and you need it when you want to make 3 (or more!) options. - Check it out! - functions: - levels: - 12: - example_code: | - ``` - sides = 'left', 'right' - limbs = 'hand', 'foot' - colors = 'red', 'blue', 'green', 'yellow' - - {define} turn - chosen_side = sides {at} {random} - chosen_limb = limbs _ - chosen_color = colors _ - {print} chosen_side ' ' chosen_limb ' on ' chosen_color - - {print} 'Lets play a game of Twister!' - {for} i {in} {range} 1 to _ - {call} turn - {sleep} 2 - ``` - 13: - story_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. - - For example in this code we've programmed the first verse of the song 'My Bonnie is over the ocean'. - In this example code the argument `place` is used. Place is a variable that is only used in the function, so an argument. - To use `place` we have programmed the line `define song with place`. - When the function is called, computer will replace the argument `place`, with the piece of text after `call song with`. - - ### Exercise - The next verse of this song goes: - - Last night as I lay on my pillow - Last night as I lay on my bed - Last night as I lay on my pillow - I dreamed that my Bonnie is dead - - Can you program this verse in the same way as the example? - 14: - example_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?' - - new_price = _ calculate_new_price {with} old_price, _ - {print} 'The new price is ' new_price ' dollar' - ``` - is_command: - levels: - 14: - example_code: | - ``` - age = {ask} 'How old are you?' - {if} age > 12 - {print} 'You are older than I am!' - ``` - example_code_3: | - ``` - name = {ask} 'What is your name?' - {if} name != 'Hedy' - {print} 'You are not Hedy' - ``` - - {if} age < 13 - {print} 'You are younger than me!' - {else} - {print} 'You are older than me!' - maths: - levels: - 12: - example_code_2: | - ``` - a = 'Hello ' - b = 'world!' - {print} a + b - ``` - - {print} 2.5 + 2.5 - music: - levels: - 6: - story_text: "Instead of playing notes, you can also play numbers now. Simply type `{play} 1` for the lowest note, `{play} 70` for the highest note, or anything in between.\n\n### Exercise\n This calls for musical maths! Try out the example code a couple of times with different starting numbers. \nThen, see if you can compose a song using the numbers.\n" - print_command: - levels: - 18: - example_code_2: | - ``` - temperature = 25 - {print}('It is ', temperature, ' degrees outside') - ``` - - {print}('My name is ', name) - repeat_command: - levels: - 7: - story_text: | - ## Repeat! Repeat! Repeat! - Level 7 adds the `{repeat}` command. `{repeat}` can be used to execute one line of code multiple times. Like this: - - ### Exercise - Play around with the repeat command. Can you make the happy birthday song in only 3 lines of code instead of 4 now? - 9: - story_text: | - Great job! You've reached another new level! In the previous level you've learned to use multiple lines of code in an {if} or {repeat} command. But you can't yet combine the two... - Good news! In this level you will be allowed to put an {if} inside an {if}, or inside a {repeat} command. Putting a block of code inside another block of code is called nesting. ``` Putting a block of code inside another block of code is called nesting. - example_code: | - ``` - answer = {ask} 'Are you ready to learn something new?' - {if} answer {is} yes - {print} 'Great! You can learn to use the repeat command in the if command!' - {print} 'Hooray!' - {print} 'Hooray!' - {print} 'Hooray!' - {else} - {print} 'Maybe you should practice some more in the previous level' - restaurant: - levels: - 4: - story_text: | - ### Exercise - Add the quotation marks to this code to make it work! Be careful: variables should not be in quotation marks. - Then, use the `{clear}` command to only show one line at a time in your output screen. - - ### Exercise 2 - Go back to the previous level and copy your restaurant code. Make the code work in this level by adding quotation marks in the right spots and add some `{clear}` commands. - 12: - story_text: | - From this level on you can use decimal numbers to make you menu more realistic. - - ### Exercise - Can you think of a code to give your friends and family a 15% discount? - rock: - levels: - 2: - story_text: | - In this level you can practise using the variables, so that you can make the rock, paper, scissors game in the next level! - ### Exercise - Finish the code by filling in the **variable** on the blanks. - This game is not very interactive, but no worries! In the next tab you'll learn how to use variables with the `{ask}` command to make your game interactive! - secret: - levels: - 12: - example_code: | - ``` - name = {ask} 'What is your name?' - {if} name {is} '_' - a = 'Go to the airport ' - {else} - a = 'Go to the trainstation ' - password = {ask} 'What is the password?' - {if} password {is} _ - b = 'tomorrow at 02.00' - {else} - b = 'today at 10.00' - {print} _ _ _ - ``` - 13: - story_text: | - We can simplify the superspy code with `{and}`, such that we only need one `{if}`. - - ### Exercise 1 - Complete the code by filling the right command on the blank. Tip: The superspy has to answer BOTH questions correctly, before they get the confidential information! - - ### Exercise 2 - We want confuse the enemy even more! Create a list with fake answers and select one at random when a wrong answer is given. - songs_2: - levels: - 12: - example_code: | - ``` - {define} twinkle - {print} 'Twinkle' - {print} '...' - - {call} twinkle - {print} 'Up above the world so high' - {print} 'Like a diamond in the sky' - {call} _ - ``` - turtle: - levels: - 2: - story_text: | - In this level you can use variables to make the turtle interactive. For example you can ask the player how many steps the turtle must make. - example_code: | - ``` - answer {is} {ask} How many steps should the turtle make? - {forward} answer - ``` - story_text_2: | - Also, in level 1 the turtle could only turn left or right. That is a bit boring! - In level 2 he can point his nose in all directions. - - Use 90 to turn a quarter. We call this degrees. A full turn is 360 degrees. - - ### Exercise - Can you make a figure with this code? Maybe a triangle or a circle? - example_code_2: | - ``` - {print} Drawing figures - angle {is} 90 - {turn} angle - {forward} 25 - {turn} angle - {forward} 25 - ``` - turtle_draw_it: - levels: - 9: - example_code: | - Hint for the nested squares: - ``` - colors = red, blue, orange, yellow, pink, purple, green, brown, black - distance = 120 - repeat 5 times - _ - ``` - Hint for the flags: - ``` - country = ask 'which country would you like to see the flag of?' - if country is 'the Netherlands' - color_1 = red - color_2 = white - color_3 = blue - ``` - 12: - story_text: | - ### Exercise - Recreate the drawings with the turtle! - Hint: Bracelet designing program. Firstly, define a function **for each shape** you want to use on the bacelet. Then, add the shapes to the bacelet like this: - - Bracelet Designing program - example_code: | - ``` - {define} draw_a_square - _ - - {color} white - {turn} -90 - {forward} 300 - {turn} 180 - - {for} i {in} {range} 1 {to} 5 - {color} gray - {forward} 100 - shape = {ask} 'What kind of shape would you like next on the bracelet?' - chosen_color = {ask} 'In which color?' - {color} chosen_color - {if} shape = 'square' - {call} draw_a_square - ``` +{} diff --git a/content/adventures/iba.yaml b/content/adventures/iba.yaml index 66188941007..0967ef424bc 100644 --- a/content/adventures/iba.yaml +++ b/content/adventures/iba.yaml @@ -1,42 +1 @@ -adventures: - calculator: - levels: - 14: - example_code: "```\n{define} calculate_mean_grade\n total = 0\n {for} i {in} {range} 1 {to} 4\n grade = {ask} _\n total = total + _\n return _ / 4\n\nmean_grade = {call} _\n{print} 'Your mean grade is ' mean_grade\n```\n\n total = total + _\n return _ / 4\n\nmean_grade = {call} _\n{print} 'Your mean grade is ' mean_grade\n" - 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.\n\n### Exercise 1\nCan you finish line 10 to get the code to work?\n\n### Exercise 2\nGive the player feedback when they enter an answer, like `{print} 'Correct!'` or `{print} 'Wrong! The correct answer is ' correct_answer`.\n" - functions: - levels: - 12: - example_code: "```\nsides = 'left', 'right'\nlimbs = 'hand', 'foot'\ncolors = 'red', 'blue', 'green', 'yellow'\n\n{define} turn\n chosen_side = sides {at} {random}\n chosen_limb = limbs _\n chosen_color = colors _\n {print} chosen_side ' ' chosen_limb ' on ' chosen_color\n\n{print} 'Lets play a game of Twister!'\n{for} i {in} {range} 1 to _\n {call} turn\n {sleep} 2\n```\n" - 14: - example_code: "```\n{define} calculate_new_price {with} amount, percentage\n percentage = percentage / 100\n discount_amount = amount * percentage\n return amount - discount_amount\n\nold_price = {ask} 'How much is on the price tag?'\ndiscount = {ask} 'What percentage is the discount?'\n\nnew_price = _ calculate_new_price {with} old_price, _\n{print} 'The new price is ' new_price ' dollar'\n```\n" - 13: - story_text: "Now that you've learned how to use functions, you'll learn how to use a function with an argument.\nAn **argument** is a variable that is used within a function. It is not used outside the function.\n\nFor example in this code we've programmed the first verse of the song 'My Bonnie is over the ocean'.\nIn this example code the argument 'place' is used. Place is a variable that is only used in the function, so an argument.\nTo use 'place' we have placed `{with} place` after `{define} song` .\nWhen the function is called, computer will replace the argument 'place', with the piece of text after `{call} song {with}`.\n\n### Exercise\nThe next verse of this song goes:\n\n```not_hedy_code\nLast night as I lay on my pillow\nLast night as I lay on my bed\nLast night as I lay on my pillow\nI dreamed that my Bonnie is dead\n```\n\nCan you program this verse in the same way as the example?\n" - music: - levels: - 6: - story_text: "Instead of playing notes, you can also play numbers now. Simply type `{play} 1` for the lowest note, `{play} 70` for the highest note, or anything in between.\n\n### Exercise\n This calls for musical maths! Try out the example code a couple of times with different starting numbers. \nThen, see if you can compose a song using the numbers.\n" - rock: - levels: - 2: - story_text: "In this level you can practise using the variables, so that you can make the rock, paper, scissors game in the next level!\n### Exercise\nFinish the code by filling in the **variable** on the blanks.\nThis game is not very interactive, but no worries! In the next tab you'll learn how to use variables with the `{ask}` command to make your game interactive!\n" - turtle: - levels: - 2: - example_code: "```\nanswer {is} {ask} How many steps should the turtle make?\n{forward} answer\n```\n" - example_code_2: "```\n{print} Drawing figures\nangle {is} 90\n{turn} angle\n{forward} 25\n{turn} angle\n{forward} 25\n```\n" - story_text: "In this level you can use variables to make the turtle interactive. For example you can ask the player how many steps the turtle must make.\n" - story_text_2: "Also, in level 1 the turtle could only turn left or right. That is a bit boring!\nIn level 2 he can point his nose in all directions.\n\nUse 90 to turn a quarter. We call this degrees. A full turn is 360 degrees.\n\n### Exercise\nCan you make a figure with this code? Maybe a triangle or a circle?\n" - turtle_draw_it: - levels: - 9: - example_code: "Hint for the nested squares:\n```\ncolors = red, blue, orange, yellow, pink, purple, green, brown, black\ndistance = 120\nrepeat 5 times\n_\n```\nHint for the flags:\n```\ncountry = ask 'which country would you like to see the flag of?'\nif country is 'the Netherlands'\n color_1 = red\n color_2 = white\n color_3 = blue\n```\n" - tic: - levels: - 17: - example_code: "```\nsign = 'x'\nopen_spots = [1, 2, 3, 4, 5, 6, 7, 8, 9]\ngame = 'on'\nspot_1 = '.'\nspot_2 = '.'\nspot_3 = '.'\nspot_4 = '.'\nspot_5 = '.'\nspot_6 = '.'\nspot_7 = '.'\nspot_8 = '.'\nspot_9 = '.'\n{print} 'TIC TAC TOE!'\n{print} spot_1 spot_2 spot_3\n{print} spot_4 spot_5 spot_6\n{print} spot_7 spot_8 spot_9\n{print} ' '\n{while} game != 'over':\n choice = {ask} 'Player ' sign ', which spot?'\n {if} choice {in} open_spots:\n {remove} choice {from} open_spots\n {if} choice == 1:\n spot_1 = sign\n {if} choice == 2:\n spot_2 = sign\n {if} choice == 3:\n spot_3 = sign\n {if} choice == 4:\n spot_4 = sign\n {if} choice == 5:\n spot_5 = sign\n {if} choice == 6:\n spot_6 = sign\n {if} choice == 7:\n spot_7 = sign\n {if} choice == 8:\n spot_8 = sign\n {if} choice == 9:\n spot_9 = sign\n {else}:\n\ - \ {print} 'That spot was already taken'\n {print} spot_1 spot_2 spot_3\n {print} spot_4 spot_5 spot_6\n {print} spot_7 spot_8 spot_9\n {print} ' '\n {if} spot_1 == spot_2 {and} spot_2 == spot_3 {and} spot_1 != '.':\n {print} 'Player ' sign ' wins!'\n game = 'over'\n {elif} spot_4 == spot_5 {and} spot_5 == spot_6 {and} spot_4 != '.':\n {print} 'Player ' sign ' wins!'\n game = 'over'\n {elif} spot_7 == spot_8 {and} spot_8 == spot_9 {and} spot_7 != '.':\n {print} 'Player ' sign ' wins!'\n game = 'over'\n {elif} spot_1 == spot_4 {and} spot_4 == spot_7 {and} spot_1 != '.':\n {print} 'Player ' sign ' wins!'\n game = 'over'\n {elif} spot_2 == spot_5 {and} spot_5 == spot_8 {and} spot_2 != '.':\n {print} 'Player ' sign ' wins!'\n game = 'over'\n {elif} spot_3 == spot_6 {and} spot_6 == spot_9 {and} spot_3 != '.':\n {print} 'Player ' sign ' wins!'\n game = 'over'\n\ - \ {elif} spot_1 == spot_5 {and} spot_5 == spot_9 {and} spot_1 != '.':\n {print} 'Player ' sign ' wins!'\n game = 'over'\n {elif} spot_3 == spot_5 {and} spot_5 == spot_7 {and} spot_3 != '.':\n {print} 'Player ' sign ' wins!'\n game = 'over'\n {else}:\n {if} sign == 'x':\n sign = 'o'\n {else}:\n sign = 'x'\n```\n" - story_text: "In the previous levels the tic tac toe game had an annoying feature. After every move, you had to fill in yourself if you had won or not.\nThis made the game playable, but also quite slow. In this level we have learned the `{elif}` command, that could solve that problem.\nTo use the `{elif}` to let Hedy check whether or not a player has won is fun, but it also requires a fair amount of extra lines.\n\nIn the example code you see that we added the requirements to win (3 spots in a row horizontally, vertically or diagonally).\nYou can find them in line 46 to 69. You can see that each time the requirement is met (so if a player has won) the variable game is set to 'over'.\nThis means that the `{while}` loop will be stopped and the game ends.\n" - name: Tic Tac Toe +{} diff --git a/content/adventures/id.yaml b/content/adventures/id.yaml index 2c035c455ab..a141b875cec 100644 --- a/content/adventures/id.yaml +++ b/content/adventures/id.yaml @@ -432,25 +432,7 @@ adventures: {if} _ _ _ _ _ _ _ {print} _ ``` - 14: - 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 clear_command: default_save_name: perintah_jelas description: perintah yang jelas @@ -738,184 +720,6 @@ adventures: untuk saya dalam rentang 0 hingga orang hubungi salam_pelanggan ``` - 13: - example_code: | - **Warning! This code needs to be debugged!** - ``` - defin movie_recommendation with name - action_movies == 'Die Hard', 'Fast and Furious', 'Inglorious Bastards' - romance_movies = 'Love Actually', 'The Notebook', 'Titanic' - comedy_movies = 'Mr Bean' 'Barbie''Deadpool' - kids_movies = 'Minions', 'Paddington', 'Encanto' - if name is 'Camila' or name is 'Manuel' - recommended_movie = kids_movie at random - if name is 'Pedro' or 'Gabriella' - mood = ask 'What you in the mood for?' - if mood is 'action' - recommended_movie = comedy_movies at random - if mood is 'romance' - recommended_movie = romance_movies - if mood is 'comedy' - recommended_movie = comedy_movies at random - - print 'I would recommend ' recommended_movie ' for ' name - - name = ask 'Who is watching?' - recommendation = ask 'Would you like a recommendation?' - if recommendaion is 'yes' - print movie_recommendation with name - else - print 'No problem!' - ``` - 14: - example_code: | - **Warning! This code needs to be debugged!** - ``` - define calculate_heartbeat - print 'Press your fingertips gently against the side of your neck' - print '(just under your jawline)' - print 'Count the number of beats you feel for 15 seconds' - beats == ask 'How many beats do you feel in 15 seconds?' - heartbeat = beats*4 - print 'Your heartbeat is ' heartbeat - if heartbeat >= 60 or heartbeat <= 100 - print 'Your heartbeat seems fine' - else - if heartbeat > 60 - print 'Your heartbeat seems to be too low' - if heartbeat < 100 - print 'Your heartbeat seems to be too high' - print 'You might want to contact a medical professional' - - measure_heartbeat = ask 'Would you like to measure your heartbeat?' - if measure_heartbeat = 'yes' - call measure_heartbeat - else - 'no problem' - ``` - - print '(just under your jawline)' - print 'Count the number of beats you feel for 15 seconds' - beats == ask 'How many beats do you feel in 15 seconds?' - heartbeat = beats*4 - print 'Your heartbeat is ' heartbeat - if heartbeat >= 60 or heartbeat <= 100 - print 'Your heartbeat seems fine' - else - if heartbeat > 60 - print 'Your heartbeat seems to be too low' - if heartbeat < 100 - print 'Your heartbeat seems to be too high' - print 'You might want to contact a medical professional' - - measure_heartbeat = ask 'Would you like to measure your heartbeat?' - if measure_heartbeat = 'yes' - call measure_heartbeat - else - 'no problem' - 15: - example_code: | - **Warning! This code needs to be debugged!** - ``` - names = 'Tanya', 'Romy', 'Kayla', 'Aldrin', 'Ali' - verbs='walking', 'skipping', 'cycling', 'driving', 'running' - locations = 'on a mountaintop', 'in the supermarket', 'to the swimming pool' - hiding_spots = 'behind a tree', under a table', in a box' - sounds = 'a trumpet', 'a car crash', 'thunder' - causes_of_noise = 'a television', 'a kid with firecrackers', 'a magic elephant', 'a dream' - - chosen_ name = names at random - chosen_verb = verbs at random - chosen_location = 'locations at random' - chosen_sounds = noises at random - chosen_spot = hiding_spots random - chosen_causes = causes_of_noise at random - - print chosen_name ' was ' chosen_verb ' ' chosen_location - print 'when they suddenly heard a sound like ' sounds at random - print chosen_name ' looked around, but they couldn't discover where the noise came from' - print chosen_name ' hid ' chosen_spot' - print 'They tried to look around, but couldn't see anything from there' - hidden = 'yes' - while hidden = 'yes' - print chosen_name 'still didn't see anything' - answer = ask 'does ' chosen_name ' move from their hiding spot?' - if answer = 'yes' - hidden == 'no' - print 'chosen_name moved from' chosen_spot - print 'And then they saw it was just' chosen_cause - print chosen_name 'laughed and went on with their day' - print The End - ``` - 16: - example_code: | - **Warning! This code needs to be debugged!** - ``` - country = ['The Netherlands', 'Poland', 'Turkey', 'Zimbabwe', 'Thailand', 'Brasil', 'Peru', 'Australia', 'India', 'Romania' ] - capitals = 'Amsterdam', 'Warshaw' 'Istanbul', 'Harare', 'Bangkok', 'Brasilia', 'Lima', 'Canberra', 'New Delhi', 'Bucharest' - score = 0 - for i in range 0 to 10 - answer = ask 'What's the capital of ' countries[i] - correct = capital[i] - if answer = correct - print 'Correct!' - score = score + 1 - else - print 'Wrong,' capitals[i] 'in the capital of' countries[i] - print 'You scored ' score ' out of 10' - - ``` - 17: - example_code: | - **Warning! This code needs to be debugged!** - ``` - define food_order - toppings = ask 'pepperoni, tuna, veggie or cheese?' - size = ask 'big, medium or small?' - number_of_pizza = ask 'How many these pizzas would you like?' - - print 'YOU ORDERED' - print number_of_pizzas ' size ' topping ' pizza' - - define drinks_order - drink = ask 'water, coke, icetea, lemonade or coffee?' - number_of_drinks = ask 'How many of these drinks would you like?' - - print 'YOU ORDERED' - print number_of_drinks ' ' drink - - 'Welcome to Hedy pizza' - more_food = ask 'Would you like to order a pizza?' - while more_food = 'yes' - return food_order - more_food = ask 'Would you like to order a pizza?' - more_drinks = ask 'Would you like to order some drinks?' - while more_drinks == 'yes' - call drink_order - more_drinks == ask 'Would you like to order more drinks?' - - - print 'Thanks for ordering!' - ``` - 18: - example_code: | - **Warning! This code needs to be debugged!** - ``` - animals = ['pig', 'dog', 'cow'] - sounds = ['oink', 'woof', 'moo'] - for i in range 1 to 3 - animal = animals[i] - sound = sounds[i] - print 'Old MacDonald had a farm' - print 'E I E I O!' - print 'and on that farm he had a ' animal - print 'E I E I O!' - print 'with a ' sound sound ' here' - print 'and a ' sound sound ' there' - print 'here a ' sound - print 'there a ' sound - print 'everywhere a ' sound sound - ``` default: name: Pengantar description: Penjelasan level @@ -1013,7 +817,7 @@ adventures: Pada level ini kamu tidak hanya bisa menggunakan beberapa baris baru untuk `if` and `repeat`, namun juga dapat menggabungkan mereka! Pada contoh kamu lihat sebuah perintah `if` didalam perintah `repeat`. Kamu juga dimungkinkan untuk melakukan sebaliknya, dan `if` juga boleh didalam `if` dan `repeat` didalam `repeat`. Cobalah! - + example_code: | ``` repeat 3 times makanan = ask 'Apa yang kamu mau?' @@ -1022,31 +826,16 @@ adventures: else print 'pizza lebih enak' ``` - example_code: | - ``` - {repeat} 3 {times} - food = {ask} 'What do you want?' - {if} food {is} pizza - {print} 'nice!' - else - {print} 'pizza is better' - ``` 10: story_text: | Pada level ini kita akan belajar perintah `for`. Dengan `for` kamu dapat membuat sebuah daftar dan mengakses semua isinya. `for` membentuk sebuah blok seperti `repeat` dan `if` jadi semua baris untuk aksi harus diawali dengan beberapa spasi. - + example_code: | ``` hewanhewan is anjing, kucing, ikan for hewan in hewanhewan print 'Aku suka ' hewan ``` - example_code: | - ``` - animals {is} dog, cat, blobfish - {for} animal {in} animals - {print} 'I love ' animal - ``` 12: story_text: |- **Angka Desimal** @@ -1074,43 +863,18 @@ adventures: story_text: 'Kita akan mulai belajar untuk menggunakan banyak hal baru! Kamu mungkin sudah tahu hal-hal ini dari matematika: simbol `<` dan `>`. Simbol `<` mengecek apakah angka pertama lebih kecil daripada angka kedua, seperti `4 < 5`. Simbol `>` mengecek apakah angka pertama lebih besar daripada angka kedua, seperti `6 > 5`.' example_code: | ``` - age = {ask} 'How old are you?' - {if} age > 12 - {print} 'You are older than I am!' - ``` - if umur < 13 print 'Kamu lebih muda daripada aku!' else print 'Kamu lebih tua daripada aku!' + ``` 15: story_text: Kita akan belajar tentang jenis pengulangan baru, pengulangan `while`! Kita akan melakukan pengulangan tersebut terus-menerus selama kondisinya dipenuhi. Jadi di contoh tersebut, kita terus melakukan pengulangan hingga jawaban benar telah diberikan. Jika jawaban benar tidak diberikan, pengulangan tidak akan pernah berakhir! - example_code: | - ``` - answer = 0 - while answer != 25 - answer = ask 'What is 5 times 5?' - print 'A correct answer has been given' - ``` 16: story_text: Kita akan menggunakan kurung siku untuk membungkus nilai-nilai didalam list! Kita juga akan membutuhkan tanda kutip satu (') untuk membungkus setiap nilai didalam list. - example_code: | - ``` - friends = ['Ahmed', 'Ben', 'Cayden'] - {print} friends[1] ' is the first friend on the list.' - {print} friends[2] ' is the second friend on the list.' - {print} friends[3] ' is the third friend on the list.' - #now we will match 2 lists using the variable i - lucky_numbers = [15, 18, 6] - {for} i {in} {range} 1 {to} 3 - {print} friends[i] 's lucky number is ' lucky_numbers[i] - ``` + 17: story_text: Kali ini kita akan mengganti proses indentasi sedikit. Setiap kali kita membutuhkan indentasi, kita perlu menambahkan `:` pada akhir baris sebelumnya - 18: - story_text: |- - We arrived at real Python code! That means we need to use parentheses with {print} and {range} from now on. - {print}('My name is ', naam) dice: name: Dadu default_save_name: dadu @@ -1183,17 +947,6 @@ adventures: pilihan is 1, 2, 3, 4, 5, cacing repeat _ _ print _ _ _ ``` - 10: - story_text: | - Is everybody taking too long throwing the dice? In this level you can let Hedy throw all the dice at once! - example_code: | - ``` - players = Ann, John, Jesse - choices = 1, 2, 3, 4, 5, 6 - {for} player {in} players - {print} player ' throws ' choices {at} {random} - {sleep} - ``` dishes: name: Cuci piring? default_save_name: Piring @@ -1248,17 +1001,6 @@ adventures: Senin dan Selasa siap untuk Anda! Bisakah Anda menambahkan sisa minggu ini? Dan… dapatkah Anda menemukan solusi ketika daftar Anda kosong? - example_code_2: | - ``` - people = mom, dad, Emma, Sophie - dishwasher = people {at} {random} - {print} 'Monday the dishes are done by: ' dishwasher - {remove} dishwasher {from} people - dishwasher = people {at} {random} - {print} 'Tuesday the dishes are done by: ' dishwasher - {remove} dishwasher {from} people - dishwasher = people {at} {random} - ``` 7: story_text: Seberapa sering semua orang mencuci piring? Apakah adil? Kamu harus menghitungnya di level 6. example_code: | @@ -1273,33 +1015,6 @@ adventures: Sekarang kamu dapat menyalin baris 3 ke 5 beberapa kali (misal 7 kali untuk seminggu penuh) untuk menghitung jumlah jatah cuci piring selama seminggu. Apakah kamu mau membuat kodenya untuk seminggu penuh? - 10: - story_text: | - In this level you could make an even better dish washing shedule. - elif_command: - description: elif - levels: - 17: - example_code: | - ``` - prices = ['1 million dollars', 'an apple pie', 'nothing'] - your_price = prices[{random}] - {print} 'You win ' your_price - {if} your_price == '1 million dollars' : - {print} 'Yeah! You are rich!' - {elif} your_price == 'an apple pie' : - {print} 'Lovely, an apple pie!' - {else}: - {print} 'Better luck next time..' - ``` - for_command: - description: for command - levels: - 11: - story_text: |- - In this level, we add a new form of the `{for}`. In earlier levels, we used `{for}` with a list, but we can also use `{for}` with numbers. - We do that by adding a variable name, followed by `{in}` `{range}`. We then write the number to start at, `{to}` and the number to end at. - Try the example to see what happens! In this level again, you will need to use indentations in lines below the `{for}` statements. fortune: name: Peramal default_save_name: peramal @@ -1397,85 +1112,6 @@ adventures: {print} pertanyaan {print} 'Bola kristal saya menyatakan...' jawaban {at} {random} ``` - 10: - story_text: | - In this level you'll learn how to program the game MASH (mansion, apartement, shack, house). In this game you can predict for all the players at once, what their future will look like. - example_code: | - ``` - houses = mansion, apartment, shack, house - loves = nobody, a royal, their neighbour, their true love - pets = dog, cat, elephant - names = Jenna, Ryan, Jim - {for} name {in} names - {print} name ' lives in a ' houses {at} {random} - {print} name ' will marry ' loves {at} {random} - {print} name ' will get a ' pets {at} {random} ' as their pet.' - {sleep} - ``` - 12: - story_text: | - In this level you can make your fortunes multiple words. Like in this example below: - example_code: | - ``` - fortunes = 'you will be rich', 'you will fall in love', 'you will slip on a banana peel' - {print} 'I will take a look in my crystall ball for your future.' - {print} 'I see... I see...' - {sleep} - {print} fortunes {at} {random} - ``` - functions: - levels: - 12: - example_code: | - ``` - sides = 'left', 'right' - limbs = 'hand', 'foot' - colors = 'red', 'blue', 'green', 'yellow' - - {define} turn - chosen_side = sides {at} {random} - chosen_limb = limbs _ - chosen_color = colors _ - {print} chosen_side ' ' chosen_limb ' on ' chosen_color - - {print} 'Lets play a game of Twister!' - {for} i {in} {range} 1 to _ - {call} turn - {sleep} 2 - ``` - 13: - story_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. - - For example in this code we've programmed the first verse of the song 'My Bonnie is over the ocean'. - In this example code the argument `place` is used. Place is a variable that is only used in the function, so an argument. - To use `place` we have programmed the line `define song with place`. - When the function is called, computer will replace the argument `place`, with the piece of text after `call song with`. - - ### Exercise - The next verse of this song goes: - - Last night as I lay on my pillow - Last night as I lay on my bed - Last night as I lay on my pillow - I dreamed that my Bonnie is dead - - Can you program this verse in the same way as the example? - 14: - example_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?' - - new_price = _ calculate_new_price {with} old_price, _ - {print} 'The new price is ' new_price ' dollar' - ``` haunted: name: Rumah berhantu default_save_name: rumahhantu @@ -1488,45 +1124,6 @@ adventures: Pada level 1 kita memulai permainan rumah berhantu dengan membuat cerita menyeramkan dan menanyakan monster apa yang pemain akan lihat di rumah berhantu. example_code: "```\nprint Kenapa aku ada disini?\nprint Aku ingat temanku menyarankan untuk tidak ke rumah besar tua itu...\nprint dan tiba-tiba semuanya menjadi gelap.\nprint Tapi bagaimana caranya aku tergeletak di lantai...?\nprint Kepalaku sakit seperti telah dipukul dengan tongkat pemukul basebal!\nprint Suara apa itu?\nprint Oh tidak! Aku merasa kalau aku tidak sendiri di rumah ini!\nprint Aku perlu keluar dari sini!\nprint Ada 3 pintu didepanku...\n{ask} Pintu mana yang harus kupilih?\necho Aku memilih pintu \nprint ...?\n ```\n\nDapatkah kamu menyelesaikan cerita menyeramkan ini dengan menanyakan monster apa yang akan muncul? Atau membuat cerita rumah berhantu milik kamu sendiri?\n" - story_text_2: | - ### Exercise - Can you finish the scary story? Or make up your own haunted house story? - 2: - story_text: | - In this haunted house you can choose your monsters with emojis. Of course you could also use words. - - ``` - monster1 {is} 👻 - monster2 {is} 🤡 - monster3 {is} 👶 - {print} You enter the haunted house. - {print} Suddenly you see a monster1 - {print} You run into the other room, but a monster2 is waiting there for you! - {print} Oh no! Quickly get to the kitchen. - {print} But as you enter monster3 attacks you! - ``` - example_code: | - ``` - monster_1 {is} 👻 - monster_2 {is} 🤡 - monster_3 {is} 👶 - {print} You enter the haunted house. - {print} Suddenly you see a monster_1 - {print} You run into the other room, but a monster_2 is waiting there for you! - {print} Oh no! Quickly get to the kitchen. - {print} But as you enter monster_3 attacks you! - ``` - example_code_2: | - ``` - monster_1 {is} _ - monster_2 {is} _ - monster_3 {is} _ - {print} You enter the haunted house. - {print} Suddenly you see a monster_1 - {print} You run into the other room, but a monster_2 is waiting there for you! - {print} Oh no! Quickly get to the kitchen. - {print} But as you enter monster_3 attacks you! - ``` 3: story_text: |- Pada level 1 kamu telah membuat pendahuluan tentang permainan rumah berhantu kamu, tapi seperti yang mungkin sudah kamu ketahui, ceritanya selalu memiliki akhir yang mengerikan. @@ -1536,17 +1133,6 @@ adventures: story_text: |- Pada level 3 kamu belajar bagaimana menggunakan tanda kutip satu di permainan kamu. Dapatkah kamu membuat permainan rumah berhantu kamu berjalan di level 3? - example_code: | - ``` - {print} _Escape from the haunted house!_ - {print} _There are 3 doors in front of you..._ - choice {is} {ask} _Which door do you choose?_ - {print} _You picked door ..._ choice - monsters {is} a zombie, a vampire, NOTHING YOUVE ESCAPED - {print} _You see..._ - {sleep} - {print} monsters {at} {random} - ``` 5: story_text: |- Sampai pada level ini permainan rumah berhantu kamu pasti menanyakan ke pemain tentang pintu mana yang akan dipilih, namun seperti yang mungkin kamu sadari, mereka tidak harus menjawab dengan benar. @@ -1587,7 +1173,6 @@ adventures: if pemain is hidup print 'Bagus! Kamu berhasil bertahan hidup!' ``` - Sekarang permainan ini jadi cukup sulit untuk dimenangkan. Dapatkah kamu membuat permainan ini lebih mudah? Sebagai contoh dengan hanya memiliki 1 pintu yang salah dan 2 pintu benar ketimbang 2 pintu salah dan 1 pintu benar? 11: @@ -1614,129 +1199,9 @@ adventures: if pemain is hidup print 'Bagus! Kamu berhasil bertahan hidup!' ``` - if_command: - description: Introducing the if command - levels: - 9: - story_text: | - In this level you can also put an {if} command inside another {if} command. - in_command: - description: Introducing the in command - levels: - 5: - example_code_2: | - ``` - animals is dog, cow, sheep - answer is ask 'What is your favorite animal?' - _ answer _ animals _ 'Mine too!' - _ _ 'My favorite animals are dogs, cows and sheep' - ``` - is_command: - description: introducing is command - levels: - 2: - story_text_2: | - ### Exercise - Time to make your own variables! - In the example code we made an example of the variable `favorite_animal`. In line 1 the variable is set, and in line 2 we haved used the variable in a print command. - Firstly, finish our example by filling in your favorite animal on the blank. Then make at least 3 of these codes yourself. Pick a variable, and set the variable with the {is} command. Then use it with a {print} command, just like we did. - 14: - example_code: | - ``` - age = {ask} 'How old are you?' - {if} age > 12 - {print} 'You are older than I am!' - ``` - example_code_3: | - ``` - name = {ask} 'What is your name?' - {if} name != 'Hedy' - {print} 'You are not Hedy' - ``` - - {if} age < 13 - {print} 'You are younger than me!' - {else} - {print} 'You are older than me!' - language: - default_save_name: language - levels: - 5: - story_text: | - Make your own program to practice your vocabulary in a new language. - - ``` - {print} 'Learn French!' - cat {is} {ask} '🐱' - {if} cat {is} chat {print} 'Terrific!' - {else} {print} 'No, cat is chat' - frog {is} {ask} '🐸' - {if} frog {is} grenouille {print} 'Super!' - {else} {print} 'No, frog is grenouille' - ``` - maths: - levels: - 6: - example_code: | - ``` - {print} '5 plus 5 is ' 5 + 5 - {print} '5 minus 5 is ' 5 - 5 - {print} '5 times 5 is ' 5 * 5 - ``` - 12: - example_code_2: | - ``` - a = 'Hello ' - b = 'world!' - {print} a + b - ``` - - {print} 2.5 + 2.5 - music: - levels: - 6: - story_text: "Instead of playing notes, you can also play numbers now. Simply type `{play} 1` for the lowest note, `{play} 70` for the highest note, or anything in between.\n\n### Exercise\n This calls for musical maths! Try out the example code a couple of times with different starting numbers. \nThen, see if you can compose a song using the numbers.\n" parrot: levels: - 1: - story_text_2: | - ### Exercise - Can you make the parrot ask a different question? Fill in the blanks in the example! - 2: - story_text: | - Create your own online pet parrot that will copy you! - example_code: | - ``` - {print} Im Hedy the parrot - name {is} {ask} whats your name? - {print} name - {sleep} - {print} squawk - {sleep} - {print} name - ``` - story_text_2: | - ### Exercise - You can use variables to make the parrot say more than only your name. Can you complete this code? - 3: - story_text: | - Teach your parrot a new word with `{add}`. - example_code: | - ``` - words {is} squawk, Hedy - {print} Train your parrot! - new_word {is} {ask} Which word do you want to teach them? - {add} new_word {to_list} words - {print} 🧒 Say new_word , Hedy! - {print} 🦜 words {at} {random} - ``` - 4: - story_text: | - In this level we have to use quotation marks with the commands `{ask}` and `{print}`. - Can you complete the code by adding quotation marks? 5: - story_text: | - Reward your parrot {if} it says the correct word! example_code: | ``` kata-kata {is} mengoceh, Hedy @@ -1751,19 +1216,6 @@ adventures: ``` piggybank: levels: - 12: - story_text: | - In this adventure you learn how to make a digital piggy bank, to calculate how much money you have and how long you need to save up to buy what you want! - example_code: | - ``` - {print} 'The digital piggy bank' - wish = {ask} 'What would you like to buy?' - price = {ask} 'How much does that cost?' - saved = {ask} 'How much money have you saved already?' - allowance = {ask} 'How much pocket money do you get per week?' - to_save = price - saved - weeks = to_save / allowance - {print} 'You can buy a ' wish ' in ' weeks ' weeks.' 14: example_code: | ``` @@ -1783,62 +1235,6 @@ adventures: {call} _ ``` - pressit: - levels: - 9: - story_text: | - Now that you know how to combine statements, you can create a touch type tool with `{pressed}`. - - ### Exercise - Finish the code. Each time a random letter should be chosen, which you have to press. You get a point for a correct press, and and two points deduction for a wrong press. - **(extra)** Clear the screen after each letter, and show the user how many points they have scored. - print_command: - levels: - 18: - example_code_2: | - ``` - temperature = 25 - {print}('It is ', temperature, ' degrees outside') - ``` - - {print}('My name is ', name) - random_command: - levels: - 16: - story_text: |- - We are going to make lists the Python way, with square brackets around the lists! We also keep the quotation marks around each item like we have learned in previous levels. - We use square brackets to point out a place in a list. For example: `friends[1]` is the first name on the list of friends, as you can see in the first part of the example code. The second part of the example code shows you that we can also match 2 lists using the variable i. - repeat_command: - description: repeat command - levels: - 7: - story_text: | - ## Repeat! Repeat! Repeat! - Level 7 adds the `{repeat}` command. `{repeat}` can be used to execute one line of code multiple times. Like this: - - ### Exercise - Play around with the repeat command. Can you make the happy birthday song in only 3 lines of code instead of 4 now? - 9: - story_text: | - Great job! You've reached another new level! In the previous level you've learned to use multiple lines of code in an {if} or {repeat} command. But you can't yet combine the two... - Good news! In this level you will be allowed to put an {if} inside an {if}, or inside a {repeat} command. Putting a block of code inside another block of code is called nesting. ``` Putting a block of code inside another block of code is called nesting. - example_code: | - ``` - answer = {ask} 'Are you ready to learn something new?' - {if} answer {is} yes - {print} 'Great! You can learn to use the repeat command in the if command!' - {print} 'Hooray!' - {print} 'Hooray!' - {print} 'Hooray!' - {else} - {print} 'Maybe you should practice some more in the previous level' - repeat_command_2: - description: repeat command 2 - levels: - 7: - story_text_2: | - Another interesting thing you can so with the `{repeat}` command is using variables to set the amount of times something should be repeated. In the example code you can see that we first ask the person how old they are. - Then, in line 3, the question is repeated 'age' times. So we have used the variable 'age' with the `{repeat}` command. restaurant: name: Rumah makan default_save_name: rumahmakan @@ -1875,9 +1271,6 @@ adventures: print Terima kasih atas pesanannya. print makanan dan minuman kamu akan segera tersedia! ``` - story_text_2: | - ### Exercise - Can you make this code more elaborate? For example by adding drinks to the order? Or...? 3: story_text: |- Punya masalah untuk menentukan apa yang akan kamu makan untuk malam? Kamu dapat meminta Hedy untuk memilihkannya untukmu! @@ -1901,24 +1294,7 @@ adventures: ``` Dapatkan kamu memikirkan hal apa yang bisa membuat kode rumah makan kamu semakin menarik? - story_text_2: | - Does your costumer have any allergies or do they dislike certain dishes? Then you can use the `{remove}`command to remove it from your menu. - example_code_2: | - ``` - {print} Mystery milkshake - flavors {is} strawberry, chocolate, vanilla - allergies {is} {ask} Are you allergic to any falvors? - {remove} allergies {from} flavors - {print} You get a flavors {at} {random} milkshake - ``` 4: - story_text: |- - ### Exercise - Add the quotation marks to this code to make it work! Be careful: variables should not be in quotation marks. - Then, use the `{clear}` command to only show one line at a time in your output screen. - - ### Exercise 2 - Go back to the previous level and copy your restaurant code. Make the code work in this level by adding quotation marks in the right spots and add some `{clear}` commands. example_code: | ``` _ Add the quotation marks to this code _ @@ -1975,27 +1351,16 @@ adventures: story_text: |- Pada level 5 kamu telah belajar bagaimana menggunakan perintah `repeat` untuk mengulang satu baris kode beberapa kali. Kamu dapat menggunakan itu di rumah makan kamu dengan cara menanyakan ke beberapa orang apa yang mau mereka makan, seperti ini: - + example_code: | ``` print 'Selamat datang di rumah makan Hedy!' orang is ask 'Berapa banyak orang yang akan datang hari ini?' repeat orang times makanan is ask 'Apa yang ingin kamu makan?' print 'Terima kasih atas pesanannya! Makanan akan segera datang!' ``` - - Pada level 5 kamu dapat menanyakan ke beberapa orang tentang apa yang mau dia makan namun kamu tidak bisa menampilkan pesanannya secara terpisah karena kamu hanya bisa mengulang satu baris kode. - Pada level 7 kamu akan bisa mengulang beberapa baris kode sekaligus, memungkinkan kamu untuk menanyakan beberapa pesanan dan menampilkannya juga. - example_code: | - ``` - {print} 'Welcome to Hedys restaurant!' - people = {ask} 'How many people are joining us today?' - {repeat} people times food = {ask} 'What would you like to eat?' - {print} 'Thanks for your order! Its coming right up!' - ``` 9: story_text: |- Pada level 7 kamu bisa membuat rumah makan virtual kamu lebih detil dengan mengulang beberapa baris kode. Seperti ini: - ``` print 'Selamat datang di rumah makan Hedy!' orang is ask 'Berapa banyak orang yang akan bergabung dengan kita?' @@ -2013,7 +1378,6 @@ adventures: print 'Harganya akan menjadi ' harga ' rupiah' print 'Selamat menikmati!' ``` - Tentu, kode kamu dapat diperdetil dengan penambahan jenis makanan dan minuman pada menu. Jadi, silakan menambahkan pilihan-pilihan tersebut sesuai dengan keinginanmu! example_code: | ``` @@ -2037,27 +1401,6 @@ adventures: {print} 'Itu akan menjadi ' harga ' dolar' {print} 'Selamat menikmati makananmu!' ``` - 10: - story_text: | - In this level you'll learn how to easily {ask} your guests' orders in a short code. - example_code: | - ``` - courses = appetizer, main course, dessert - {for} course {in} courses - food = {ask} 'What would you like to eat as your ' course '?' - {print} food ' will be your ' course - ``` - story_text_2: | - Of course, you could also order for multiple people! - example_code_2: | - ``` - courses = appetizer, main course, dessert - names = Timon, Onno - {for} name {in} names - {for} course {in} courses - food = {ask} name ', what would you like to eat as your ' course '?' - {print} name ' orders ' food ' as their ' course - ``` 11: example_code: | ``` @@ -2075,38 +1418,6 @@ adventures: harga is 40000 * orang print 'Harganya akan menjadi ' harga ' rupiah!' ``` - 12: - story_text: | - From this level on you can use decimal numbers to make you menu more realistic. - example_code: | - ``` - price = 0 - food = {ask} 'What would you like to order?' - drink = {ask} 'What would you like to drink?' - {if} food {is} 'hamburger' - price = price + 6.50 - {if} food {is} 'pizza' - price = price + 5.75 - {if} drink {is} 'water' - price = price + 1.20 - {if} drink {is} 'soda' - price = price + 2.35 - {print} 'That will be ' price ' dollar, please' - ``` - 13: - story_text: | - In this level we can use the new commands to upgrade our restaurant. - We use `{and}` to see {if} two things are both the case. - example_code: | - ``` - price = 10 - food = {ask} 'What would you like to eat?' - drinks = {ask} 'What would you like to drink?' - {if} food {is} 'sandwich' {and} drinks {is} 'juice' - {print} 'Thats our discount menu' - price = price - 3 - {print} 'That will be ' price ' dollars' - ``` rock: name: Batu, gunting, kertas default_save_name: Batu @@ -2153,113 +1464,6 @@ adventures: 5: story_text: "Pada level 4 kamu bisa menentukan siapa yang menang. \nUntuk hal itu, kamu memerlukan perintah `if`\n\nSimpan pilihan kamu dengan sebuah nama favoritmu dan pilihan komputer dengan nama pilihan komputer.\nLalu kamu bisa menggunakan `if` untuk melihat apakah kedua pilihan tersebut sama atau berbeda.\nDapatkah kamu menyelesaikan kode ini?" example_code: "```\npilihan is batu, gunting, kertas\npil_komputer is _\n pil_kamu is ask Apa yang kamu pilih?\nprint 'kamu memilih ' _\nprint 'komputer memilih ' _\nif _ is _ print 'seri' else print 'tidak seri'\nif pil_kamu is batu and pil_komputer is kertas print 'komputer menang'\n```\n\nPertama-tama, kamu perlu mengisi kotak kosong yang tersedia dengan kode yang benar untuk melihat apakah hasil permainan seri. \n" - 9: - story_text: | - In this level you can program the whole rock, paper, scissors game by nesting the {if}-commands. Can you finish the code? - example_code: | - ``` - choices = rock, paper, scissors - your_choice = {ask} 'What do you choose?' - {print} 'You choose ' your_choice - computer_choice = choices {at} {random} - {print} 'The computer chooses ' computer_choice - {if} computer_choice {is} your_choice - {print} 'Tie' - {if} computer_choice {is} rock - {if} your_choice {is} paper - {print} 'You win!' - {if} your_choice {is} scissors - {print} 'You lose!' - # finish this code - ``` - 10: - story_text: | - Feeling too lazy to play the game yourself? Let Hedy play it for you! - example_code: | - ``` - choices = rock, paper, scissors - players = Marleen, Michael - {for} player {in} players - {print} player ' chooses ' choices {at} {random} - ``` - 13: - story_text: | - With the `{and}` command you can shorten your rock, paper, scissors code! Check out the example code below and try to finish it. - example_code: | - ``` - options = 'rock', 'paper', 'scissors' - your_choice = {ask} 'What do you choose?' - computer_choice = options {at} {random} - {print} 'You choose ' your_choice - {print} 'The computer chooses ' computer_choice - {if} computer_choice {is} your_choice - {print} 'Tie' - {if} computer_choice {is} 'rock' {and} your_choice {is} 'paper' - {print} 'You win!' - {if} computer_choice {is} 'rock' {and} your_choice {is} 'scissors' - {print} 'The computer wins!' - ``` - 15: - example_code: | - ``` - won = 'no' - options = 'rock', 'paper', 'scissors' - {while} won == 'no' - your_choice = {ask} 'What do you choose?' - computer_choice = options {at} {random} - {print} 'you chose ' your_choice - {print} 'the computer chose ' computer_choice - {if} computer_choice == your_choice - {print} 'Tie!' - {if} computer_choice == 'rock' {and} your_choice == 'scissors' - {print} 'You lose!' - {if} computer_choice == 'rock' {and} your_choice == 'paper' - {print} 'You win!' - won = 'yes' - rock_2: - levels: - 2: - story_text: | - Now that you have learned how to use the `{ask} command, you can make your rock, paper, scissors code interavtive too! - - ### Exercise - Make the rock, paper, scissors code interactive by adding the `{ask}` command and a question to your rock, paper, scissors code. - example_code: | - ``` - choice is _ - {print} I choose choice - ``` - secret: - default_save_name: language - levels: - 12: - story_text: | - In this adventure you can create your own super spy code. Encode a message that only the right agent can decipher. - If the enemy tries to crack the code, they will get some false info to waste their time. - example_code: | - ``` - name {is} {ask} 'What is your name?' - {if} name {is} '_' - a {is} 'Go to the airport ' - {else} - a {is} 'Go to the trainstation ' - password {is} {ask} 'What is the password?' - {if} password {is} _ - b {is} 'tomorrow at 02.00' - {else} - b {is} 'today at 10.00' - {print} _ _ _ - ``` - 13: - story_text: | - The code you made in the previous level can be made a lot easier in this one with the `{and}` command. - sleep_command: - description: introducing sleep command - levels: - 2: - story_text: | - ## The sleep command - Another new command in this level is `{sleep}`, which pauses your program for a second. If you type a number behind the {sleep} command, the program pauses for that amount of seconds. songs: name: Nyanyikan sebuah lagu! default_save_name: Lagu @@ -2282,16 +1486,6 @@ adventures: ``` Setelah Baby Shark, kamu juga dapat membuat program untuk menyanyikan lagu lain. Ada banyak lagu yang mengulang-ulang kalimat. - example_code_2: | - ``` - number = 6 - number = number - 1 - print number ' little monkeys jumping on the bed' - print 'One fell off and bumped his head' - print 'Mama called the doctor and the doctor said' - print 'NO MORE MONKEYS JUMPING ON THE BED!' - sleep - ``` 7: story_text: Lagu-lagu sering memiliki banyak pengulangan. Terkadang pengulangannya didasarkan dari perhitungan. Misal, di sebuah lagu 'Botol'. Kamu dapat membuat program untuk menyanyikan lagu tersebut dengan sedikit matematika. example_code: | @@ -2325,49 +1519,12 @@ adventures: print reff ' botol di dinding' ``` 10: - story_text: | - In this level you can easily make the childrens' song 'Five little monkeys'. Can you make the last chorus? - You can also make the whole baby shark song (including all the other sharks in the family) in only 6 lines! - Or you can make Old MacDonald with all the different animals. example_code: | ``` keluarga = bayi, ibu, ayah, nenek, kakek _ _ _ _ {print} _ ``` - story_text_2: | - ### Exercise 2 - Print the song Five little moneys jumping on the bed. Look up the text if you don't remember. - - **(extra)** Print the song Old MacDonald had a farm, and make sure all animals make a different sound, using an `{if}`. - 11: - story_text: | - In this level you can use the `{for} i {in} {range}` command to make songs that use counting. - example_code: | - ``` - {for} i {in} {range} 5 {to} 1 - {print} i ' little monkeys jumping on the bed' - {print} 'One fell off and bumped his head' - {print} 'Mama called the doctor and the doctor said' - {if} i {is} 1 - {print} 'PUT THOSE MONKEYS RIGHT TO BED!' - {else} - {print} 'NO MORE MONKEYS JUMPING ON THE BED!' - ``` - 12: - story_text: | - In this song we can make it even easier to program '{if} you're happy and you know it, clap your hands'. Because we can put all of the actions in a variable, check it out: - example_code: | - ``` - actions = 'clap your hands', 'stomp your feet', 'shout Hurray!' - {for} action {in} actions - {for} i {in} {range} 1 {to} 2 - {print} '{if} youre happy and you know it' - {print} action - {print} '{if} youre happy and you know it and you really want to show it' - {print} '{if} youre happy and you know it' - {print} action - ``` 16: story_text: | Di level ini, Anda dapat memprogram lagu seperti OldMacDonald dengan lebih cepat. Anda dapat menghubungkan hewan yang tepat dengan suara yang tepat hanya dengan menempatkannya di tempat yang sama dalam daftar. @@ -2375,20 +1532,6 @@ adventures: ### Latihan Selesaikan lagu Old MacDonald dengan mengatur variabel `animal` menjadi `animals[i]` dan `sound` menjadi `sounds[i]`. - songs_2: - levels: - 12: - example_code: | - ``` - {define} twinkle - {print} 'Twinkle' - {print} '...' - - {call} twinkle - {print} 'Up above the world so high' - {print} 'Like a diamond in the sky' - {call} _ - ``` turtle: name: Kura-kura default_save_name: kurakura @@ -2417,21 +1560,6 @@ adventures: turn sudut forward 25 ``` - story_text_2: | - Also, in level 1 the turtle could only turn left or right. That is a bit boring! - In level 2 he can point his nose in all directions. - - Use 90 to turn a quarter. We call this degrees. A full turn is 360 degrees. - Can you make a figure with this code? Maybe a triangle or a circle? - example_code_2: | - ``` - {print} Drawing figures - angle {is} 90 - {turn} angle - {forward} 25 - {turn} angle - {forward} 25 - ``` 3: story_text: |- Kamu juga dapat menggunakan `random` ketika menggambar dengan kura-kura. Pergerakan acak akan membuat sang kura-kura bergerak dalam jalur tidak terduga untuk setiap eksekusi program. @@ -2468,13 +1596,6 @@ adventures: {forward} 25 {turn} sudut {forward} 25 - example_code_2: | - ``` - direction {is} {ask} 'Do you want to go left, right, or straight ahead?' - if direction is left turn _ - if direction is right turn _ - forward 100 - ``` 6: story_text: |- Pada level 6 kamu dapat menggunakan perhitungan untuk menggambar bentuk-bentuk yang berbeda. @@ -2511,99 +1632,3 @@ adventures: ``` story_text_2: Selain itu, kita juga bisa meningkatkan kemampuan program untuk menggambar banyak bentuk. Dapatkah kamu tebak seberapa jauh sang kura-kura perlu berbelok disini? Selesaikan kodenya dan kamu dapat menggambar bentuk poligon apapun yang kamu suka! example_code_2: "```\njumlahsudut = {ask} 'Berapa banyak sudut yang kamu mau?'\nsudut = 360 / jumlahsudut \n{repeat} jumlahsudut {times}\n {turn} _\n {forward} _\n```\n" - 9: - story_text: | - Now that we can use a `{repeat}` inside a `{repeat}`, we can create more complex figures. - - ### Exercise 1 - This code creates three black triangles, change that into five pink squares. - - **(extra)** Create a figure of your own choosing consisting of at least two different shapes types. - 10: - story_text: | - In this level you can make the turtle draw a figure. - The turtle will travel the distances in the list, one by one, making bigger and bigger steps. - ### Exercise 1 - Add a 90 degree turn in the loop, so that a spiral is drawn. - Add at least 5 numbers to the list, so the spiral grows larger. - **(extra)** can you change the spiral into another shape? Experiment with numbers for the turn! - ### Exercise 2 - The spiral is drawn outwards, make it go inwards? - turtle_draw_it: - levels: - 9: - example_code: | - Hint for the nested squares: - ``` - colors = red, blue, orange, yellow, pink, purple, green, brown, black - distance = 120 - repeat 5 times - _ - ``` - Hint for the flags: - ``` - country = ask 'which country would you like to see the flag of?' - if country is 'the Netherlands' - color_1 = red - color_2 = white - color_3 = blue - ``` - 10: - example_code: | - Hint Nested Hexagon: - ``` - distances = 100, 80, 60, 40, 20 - {for} distance {in} distances - _ - ``` - - Hint Traffic Lights: - ``` - colors = red, yellow, green - {for} chosen_color {in} colors - color _ - {repeat} _ - ``` - 12: - story_text: | - ### Exercise - Recreate the drawings with the turtle! - Hint: Bracelet designing program. Firstly, define a function **for each shape** you want to use on the bacelet. Then, add the shapes to the bacelet like this: - - Bracelet Designing program - example_code: | - ``` - {define} draw_a_square - _ - - {color} white - {turn} -90 - {forward} 300 - {turn} 180 - - {for} i {in} {range} 1 {to} 5 - {color} gray - {forward} 100 - shape = {ask} 'What kind of shape would you like next on the bracelet?' - chosen_color = {ask} 'In which color?' - {color} chosen_color - {if} shape = 'square' - {call} draw_a_square - ``` - while_command: - description: while - years: - description: Countdown to the new year! - levels: - 11: - story_text: | - In this level you can use the `{for} i {in} {range}` command to countdown to the New Year. - - ### Exercise - Fill in the blanks and make the code work! - example_code: | - ``` - for _ in _ 10 to 1 - {print} i - {print} 'Happy New Year!' - ``` diff --git a/content/adventures/it.yaml b/content/adventures/it.yaml index d66eb70784f..e4d61715e3a 100644 --- a/content/adventures/it.yaml +++ b/content/adventures/it.yaml @@ -479,290 +479,6 @@ adventures: {clear} {print} 'SORPRESA' ``` - debugging: - levels: - 3: - 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} - ``` - 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! - 9: - 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!' - {else} - 'I'm sorry we don't sell that' - topping {is} {ask} 'What kind of topping would you like?' - sauce {is} {ask} 'What kind of sauce would you like?' - {print} One chosen_bread with topping and sauce. - price = amount * 6 - {print} 'That will be 'price dollar' please' - ``` - price = amount * 6 - {print} 'That will be 'price dollar' please' - 11: - story_text: |- - ### Exercise - Debug this calender program. The output of this program is supposed to look like a list of dates. - For example: - - ``` - Hedy calender - Here are all the days of November - November 1 - November 2 - November 3 - ``` - And so on. - - Mind that you have to test your code extra carefully for the month February, because the amount of days in this month changes in leap years. - example_code: | - **Warning! This code needs to be debugged!** - ``` - print 'Hedy calender' - months_with_31 days = January, March, May, July, September, October, December - months_with_30_days = April, June, August, November - month = ask 'Which month would you like to see?' - if month in months_with_31_days - days = 31 - if month in months_with30_days - days = 30 - if month = February - leap_years = 2020, 2024, 2028, 2036, 2040, 2044, 2028 - year = ask 'What year is it?' - if year in leap_years - days = 29 - else - days = 28 - - print 'Here are all the days of ' moth - for i in range 1 to days - print month i - ``` - 12: - example_code: | - **Warning! This code needs to be debugged!** - ``` - define greet - greetings = 'Hello', 'Hi there', 'Goodevening' - print greetings at random - - define take_order - food = ask 'What would you like to eat?' - print 'One food' - drink = 'What would you like to drink?' - print 'One ' drink - more = ask 'Would you like anything else?' - if more is 'no' - print 'Alright' - else - print 'And ' more - print 'Thank you' - - print 'Welcome to our restaurant' - people = ask 'How many people are in your party tonight?' - for i in range 0 to people - call greet_costumer - ``` - 13: - example_code: | - **Warning! This code needs to be debugged!** - ``` - defin movie_recommendation with name - action_movies == 'Die Hard', 'Fast and Furious', 'Inglorious Bastards' - romance_movies = 'Love Actually', 'The Notebook', 'Titanic' - comedy_movies = 'Mr Bean' 'Barbie''Deadpool' - kids_movies = 'Minions', 'Paddington', 'Encanto' - if name is 'Camila' or name is 'Manuel' - recommended_movie = kids_movie at random - if name is 'Pedro' or 'Gabriella' - mood = ask 'What you in the mood for?' - if mood is 'action' - recommended_movie = comedy_movies at random - if mood is 'romance' - recommended_movie = romance_movies - if mood is 'comedy' - recommended_movie = comedy_movies at random - - print 'I would recommend ' recommended_movie ' for ' name - - name = ask 'Who is watching?' - recommendation = ask 'Would you like a recommendation?' - if recommendaion is 'yes' - print movie_recommendation with name - else - print 'No problem!' - ``` - 14: - example_code: | - **Warning! This code needs to be debugged!** - ``` - define calculate_heartbeat - print 'Press your fingertips gently against the side of your neck' - print '(just under your jawline)' - print 'Count the number of beats you feel for 15 seconds' - beats == ask 'How many beats do you feel in 15 seconds?' - heartbeat = beats*4 - print 'Your heartbeat is ' heartbeat - if heartbeat >= 60 or heartbeat <= 100 - print 'Your heartbeat seems fine' - else - if heartbeat > 60 - print 'Your heartbeat seems to be too low' - if heartbeat < 100 - print 'Your heartbeat seems to be too high' - print 'You might want to contact a medical professional' - - measure_heartbeat = ask 'Would you like to measure your heartbeat?' - if measure_heartbeat = 'yes' - call measure_heartbeat - else - 'no problem' - ``` - - print '(just under your jawline)' - print 'Count the number of beats you feel for 15 seconds' - beats == ask 'How many beats do you feel in 15 seconds?' - heartbeat = beats*4 - print 'Your heartbeat is ' heartbeat - if heartbeat >= 60 or heartbeat <= 100 - print 'Your heartbeat seems fine' - else - if heartbeat > 60 - print 'Your heartbeat seems to be too low' - if heartbeat < 100 - print 'Your heartbeat seems to be too high' - print 'You might want to contact a medical professional' - - measure_heartbeat = ask 'Would you like to measure your heartbeat?' - if measure_heartbeat = 'yes' - call measure_heartbeat - else - 'no problem' - 15: - example_code: | - **Warning! This code needs to be debugged!** - ``` - names = 'Tanya', 'Romy', 'Kayla', 'Aldrin', 'Ali' - verbs='walking', 'skipping', 'cycling', 'driving', 'running' - locations = 'on a mountaintop', 'in the supermarket', 'to the swimming pool' - hiding_spots = 'behind a tree', under a table', in a box' - sounds = 'a trumpet', 'a car crash', 'thunder' - causes_of_noise = 'a television', 'a kid with firecrackers', 'a magic elephant', 'a dream' - - chosen_ name = names at random - chosen_verb = verbs at random - chosen_location = 'locations at random' - chosen_sounds = noises at random - chosen_spot = hiding_spots random - chosen_causes = causes_of_noise at random - - print chosen_name ' was ' chosen_verb ' ' chosen_location - print 'when they suddenly heard a sound like ' sounds at random - print chosen_name ' looked around, but they couldn't discover where the noise came from' - print chosen_name ' hid ' chosen_spot' - print 'They tried to look around, but couldn't see anything from there' - hidden = 'yes' - while hidden = 'yes' - print chosen_name 'still didn't see anything' - answer = ask 'does ' chosen_name ' move from their hiding spot?' - if answer = 'yes' - hidden == 'no' - print 'chosen_name moved from' chosen_spot - print 'And then they saw it was just' chosen_cause - print chosen_name 'laughed and went on with their day' - print The End - ``` - 16: - example_code: | - **Warning! This code needs to be debugged!** - ``` - country = ['The Netherlands', 'Poland', 'Turkey', 'Zimbabwe', 'Thailand', 'Brasil', 'Peru', 'Australia', 'India', 'Romania' ] - capitals = 'Amsterdam', 'Warshaw' 'Istanbul', 'Harare', 'Bangkok', 'Brasilia', 'Lima', 'Canberra', 'New Delhi', 'Bucharest' - score = 0 - for i in range 0 to 10 - answer = ask 'What's the capital of ' countries[i] - correct = capital[i] - if answer = correct - print 'Correct!' - score = score + 1 - else - print 'Wrong,' capitals[i] 'in the capital of' countries[i] - print 'You scored ' score ' out of 10' - - ``` - 17: - example_code: | - **Warning! This code needs to be debugged!** - ``` - define food_order - toppings = ask 'pepperoni, tuna, veggie or cheese?' - size = ask 'big, medium or small?' - number_of_pizza = ask 'How many these pizzas would you like?' - - print 'YOU ORDERED' - print number_of_pizzas ' size ' topping ' pizza' - - define drinks_order - drink = ask 'water, coke, icetea, lemonade or coffee?' - number_of_drinks = ask 'How many of these drinks would you like?' - - print 'YOU ORDERED' - print number_of_drinks ' ' drink - - 'Welcome to Hedy pizza' - more_food = ask 'Would you like to order a pizza?' - while more_food = 'yes' - return food_order - more_food = ask 'Would you like to order a pizza?' - more_drinks = ask 'Would you like to order some drinks?' - while more_drinks == 'yes' - call drink_order - more_drinks == ask 'Would you like to order more drinks?' - - - print 'Thanks for ordering!' - ``` - 18: - example_code: | - **Warning! This code needs to be debugged!** - ``` - animals = ['pig', 'dog', 'cow'] - sounds = ['oink', 'woof', 'moo'] - for i in range 1 to 3 - animal = animals[i] - sound = sounds[i] - print 'Old MacDonald had a farm' - print 'E I E I O!' - print 'and on that farm he had a ' animal - print 'E I E I O!' - print 'with a ' sound sound ' here' - print 'and a ' sound sound ' there' - print 'here a ' sound - print 'there a ' sound - print 'everywhere a ' sound sound - ``` default: name: Introduzione description: Spiegazione del livello @@ -891,46 +607,10 @@ adventures: {print} 'INTRUSO!' {print} 'Non puoi usare questo computer!' ``` - 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 - ``` 12: story_text: | Forse hai provato a utilizzare i numeri decimali nella tua avventura al ristorante. Se lo hai fatto, probabilmente avrai notato che Hedy non li capiva ancora e completava sempre. Da questo livello in poi è possibile utilizzare i numeri decimali. - example_code: | - ``` - {print} 'Two and a half plus two and a half is...' - {print} 2.5 + 2.5 - ``` - - {print} 2.5 + 2.5 13: story_text: | Nei livelli precedenti hai imparato come inserire due comandi `{if}`uno dentro l'altro. Funziona bene, ma ti dà codici molto lunghi e scomodi come questo: @@ -938,13 +618,6 @@ adventures: In questo sistema devi fornire sia il nome utente corretto che la password corretta. In questo livello imparerai il comando `{and}` che renderà questo codice molto più breve e comprensibile! Controlla! - 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!' - ``` 14: story_text: | Ora impareremo come usare dei nuovi elementi. Potresti già conoscerli dalla matematica, il `<` e il `>`. @@ -953,30 +626,12 @@ adventures: Il `>` controlla se il primo numero è più grande del secondo, per esempio punteggio `>` 10 controlla se il punteggio è maggiore di 10. Se vuoi controllare se il primo numero è più grande o uguale al secondo, puoi usare il `>=`, per esempio punteggio `>=` 11. Questi confronti si usano dentro il comando `{if}`, in questo modo: - example_code: | - ``` - age = {ask} 'How old are you?' - {if} age > 12 - {print} 'You are older than I am!' - ``` - - {if} age < 13 - {print} 'You are younger than me!' - {else} - {print} 'You are older than me!' 15: story_text: | In questo gioco qui sotto è stato creato un codice per assicurarsi che il giocatore possa giocare per tutto il tempo che desidera... Ma il codice è inefficace e troppo lungo. Inoltre, cosa succede se il giocatore vuole giocare a 101 giochi invece di 100? Non puoi giocare all'infinito? In questo livello imparerai un comando che renderà tutto questo molto più semplice! - example_code: | - ``` - answer = 0 - {while} answer != 25 - answer = {ask} 'What is 5 times 5?' - {print} 'A correct answer has been given' - ``` 16: story_text: | In questo livello progrediremo un po' di più verso il vero codice Python. Imparerai anche come abbinare due elenchi insieme. @@ -1012,12 +667,6 @@ adventures: {print}('Mi chiamo ', nome) dice: levels: - 3: - example_code: | - ``` - choices {is} 1, 2, 3, 4, 5, earthworm - {print} choices {at} {random} - ``` 4: story_text: | In questo livello puoi anche creare dadi. Ma questa volta puoi provarlo tu stesso, senza un codice di esempio! @@ -1047,40 +696,6 @@ adventures: ### Esercizio Puoi creare il codice in modo da ottenere il punteggio totale per 8 dadi? Per fare ciò, devi tagliare e incollare alcune righe del codice. - example_code: | - ``` - choices = 1, 2, 3, 4, 5, earthworm - points = 0 - throw = choices {at} {random} - {print} 'you threw' throw - {if} throw {is} earthworm points = points + 5 {else} points = points + throw - {print} 'those are' points ' point' - ``` - Can you make the code so that you get the total score for 8 dice? To do that, you have to cut and paste some lines of the code. - example_code_2: | - Did you manage to calculate the score for 8 dice? That required a lot of cutting and pasting, right? We are going to make that easier in level 7! - 7: - story_text: | - You can also make a die again in level 5. With the `{repeat}` code you can easily roll a whole hand of dice. - Try to finish the sample code! The dashes should contain multiple commands and characters. - - But maybe you want to make a completely different die. Of course you can! - example_code: | - ``` - choices = 1, 2, 3, 4, 5, earthworm - {repeat} _ _ {print} _ _ _ - ``` - 10: - story_text: | - Is everybody taking too long throwing the dice? In this level you can let Hedy throw all the dice at once! - example_code: | - ``` - players = Ann, John, Jesse - choices = 1, 2, 3, 4, 5, 6 - {for} player {in} players - {print} player ' throws ' choices {at} {random} - {sleep} - ``` dishes: name: Piatti? default_save_name: Piatti @@ -1120,51 +735,6 @@ adventures: dishwasher {is} people {at} {random} {if} dishwasher {is} Sophie {print} _ too bad I have to do the dishes _ {else} {print} 'luckily no dishes because' _ 'is already washing up' ``` - 6: - story_text_2: | - If you are extremely unlucky the previous program might choose you to to the dishes for the whole week! That's not fair! - To create a fairer system you can use the `{remove}` command to remove the chosen person from the list. This way you don't have to do the dishes again untill everybody has had a turn. - - Monday and tuesday are ready for you! Can you add the rest of the week? - And... can you come up with a solution for when your list is empty? - example_code_2: | - ``` - people = mom, dad, Emma, Sophie - dishwasher = people {at} {random} - {print} 'Monday the dishes are done by: ' dishwasher - {remove} dishwasher {from} people - dishwasher = people {at} {random} - {print} 'Tuesday the dishes are done by: ' dishwasher - {remove} dishwasher {from} people - dishwasher = people {at} {random} - ``` - 7: - story_text: | - With the `{repeat}` you can repeat pieces of code. You can use this to calculate who will be washing dishes for the entire week. - example_code: | - ``` - people = mom, dad, Emma, Sophie - {repeat} _ _ {print} 'the dishwasher is' _ - ``` - 10: - story_text: | - In this level you could make an even better dish washing shedule. - elif_command: - description: elif - levels: - 17: - example_code: | - ``` - prices = ['1 million dollars', 'an apple pie', 'nothing'] - your_price = prices[{random}] - {print} 'You win ' your_price - {if} your_price == '1 million dollars' : - {print} 'Yeah! You are rich!' - {elif} your_price == 'an apple pie' : - {print} 'Lovely, an apple pie!' - {else}: - {print} 'Better luck next time..' - ``` for_command: description: for command levels: @@ -1185,119 +755,6 @@ adventures: Nei prossimi livelli potrai imparare a creare la tua macchina per predire il futuro! Nel livello 1 puoi iniziare in modo semplice lasciando che Hedy si presenti come un'indovino e lasci che `{echo}` le risposte dei giocatori. Come questo: - example_code: | - ``` - {print} Hello, I'm Hedy the fortune teller! - {ask} Who are you? - {print} Let me take a look in my crystal ball - {print} I see... I see... - {echo} Your name is - ``` - story_text_2: | - Hedy now only tells you your name. Can you expand the code so that Hedy can predict more things about you? - Obviously, Hedy isn't a very good fortune teller yet, as she can only repeat the answers that were given by the players! - Take a look in level 2 to improve your fortune teller. - 3: - story_text: | - In the previous levels you've created your first fortune telling machine, but Hedy couldn't really predict anything, only {echo}. - In this level you can use a variable and the `{at} {random}` command to really let Hedy choose an answer for you. Check out this code for instance: - story_text_2: | - Now, Hedy can only answer yes, no or maybe. Can you give Hedy more answer options, like 'definitely' or '{ask} again'. - 4: - example_code: | - ``` - {print} 'Im Hedy the fortune teller!' - question {is} {ask} 'What do you want to know?' - {print} 'This is your question: ' question - answers {is} yes, no, maybe - {print} 'My crystal ball says...' - {sleep} 2 - {print} answers {at} {random} - ``` - 5: - story_text: | - In this level you'll learn to (secretly) tip the odds in your favor, when using the fortune teller! - By using `{if}` and `{else}` you can make sure that you will always get a good fotune, while other people might not. - Check out this example to find out how. - example_code: | - ``` - {print} 'Im Hedy the fortune teller!' - {print} 'I can predict {if} youll win the lottery tomorrow!' - person {is} {ask} 'Who are you?' - {if} person {is} Hedy {print} 'You will definitely win!🤩' {else} {print} 'Bad luck! Someone {else} will win!😭' - ``` - 6: - story_text: | - In this level you can use math in your predictions as a fortune teller. This allows you to make up (silly) formulas to calculate the future. - For example you could calculate how rich you'll get or how many kids you will have when you grow up. - example_code: | - ``` - {print} 'I am Hedy the fortune teller!' - {print} 'I can predict how many kids youll get when you grow up!' - age = {ask} 'How old are you?' - siblings = {ask} 'How many siblings do you have?' - length = {ask} 'How tall are you in centimetres?' - kids = length / age - kids = kids - siblings - {print} 'You will get ...' - {sleep} - {print} kids ' kids!' - ``` - - If the previous example wasn't silly enough for you, take a look at this one! - - ``` - {print} 'Im Hedy the silly fortune teller!' - {print} 'I will predict how smart you are!' - football = {ask} 'On a scale 1-10 how much do you love football?' - bananas = {ask} 'How many bananas did you eat this week?' - hygiene = {ask} 'How many times did you wash your hands today?' - result = bananas + hygiene - result = result * football - {print} 'You are ' result ' percent smart.' - ``` - 7: - story_text: | - In this level you can use the `{repeat}` command to make your machine tell multiple fortunes at once. - example_code: | - ``` - {print} 'Im Hedy the fortune teller!' - {print} 'You can {ask} 3 questions!' - {repeat} 3 {times} question = {ask} 'What do you want to know?' - answer = yes, no, maybe - {repeat} 3 {times} {print} 'My crystal ball says... ' answer {at} {random} - ``` - 8: - story_text: | - In the previous levels you've learned how to use repeat to make the fortune teller answer 3 questions in a row, but we had a problem with printing the questions. - Now that problem is solved, because of the new way of using the repeat command. - In the next example you can have your fortune teller {ask} 3 questions and also print them! - example_code: | - ``` - {print} 'I am Hedy the fortune teller!' - {print} 'You can {ask} me 3 questions.' - answers = yes, no, maybe - {repeat} 3 {times} - question = {ask} 'What do you want to know?' - {print} question - {sleep} - {print} 'My crystal ball says...' answers {at} {random} - ``` - 10: - story_text: | - In this level you'll learn how to program the game MASH (mansion, apartement, shack, house). In this game you can predict for all the players at once, what their future will look like. - example_code: | - ``` - houses = mansion, apartment, shack, house - loves = nobody, a royal, their neighbour, their true love - pets = dog, cat, elephant - names = Jenna, Ryan, Jim - {for} name {in} names - {print} name ' lives in a ' houses {at} {random} - {print} name ' will marry ' loves {at} {random} - {print} name ' will get a ' pets {at} {random} ' as their pet.' - {sleep} - ``` 12: story_text: |- Dal livello 12 in poi, dovrai usare le virgolette anche negli elenchi, prima e dopo ogni elemento. @@ -1312,236 +769,12 @@ adventures: {sleep} {print} fortunes {at} {random} ``` - functions: - levels: - 12: - example_code: | - ``` - sides = 'left', 'right' - limbs = 'hand', 'foot' - colors = 'red', 'blue', 'green', 'yellow' - - {define} turn - chosen_side = sides {at} {random} - chosen_limb = limbs _ - chosen_color = colors _ - {print} chosen_side ' ' chosen_limb ' on ' chosen_color - - {print} 'Lets play a game of Twister!' - {for} i {in} {range} 1 to _ - {call} turn - {sleep} 2 - ``` - 13: - story_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. - - For example in this code we've programmed the first verse of the song 'My Bonnie is over the ocean'. - In this example code the argument `place` is used. Place is a variable that is only used in the function, so an argument. - To use `place` we have programmed the line `define song with place`. - When the function is called, computer will replace the argument `place`, with the piece of text after `call song with`. - - ### Exercise - The next verse of this song goes: - - Last night as I lay on my pillow - Last night as I lay on my bed - Last night as I lay on my pillow - I dreamed that my Bonnie is dead - - Can you program this verse in the same way as the example? - 14: - example_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?' - - new_price = _ calculate_new_price {with} old_price, _ - {print} 'The new price is ' new_price ' dollar' - ``` haunted: name: Casa stregata default_save_name: Casa stregata description: Scappa dalla casa stregata - levels: - 1: - story_text: | - In this adventure you are working towards making a game in which you have to escape from a haunted house by picking the correct door. - If you pick the right door you'll survive, but {if} not a terrible monster might... - - In level 1 we start our haunted house game by making up a scary story and {ask} the player what monster they'll see in the haunted house. - story_text_2: | - Can you finish the scary story? Or make up your own haunted house story? - 2: - example_code: | - ``` - monster_1 {is} 👻 - monster_2 {is} 🤡 - monster_3 {is} 👶 - {print} You enter the haunted house. - {print} Suddenly you see a monster_1 - {print} You run into the other room, but a monster_2 is waiting there for you! - {print} Oh no! Quickly get to the kitchen. - {print} But as you enter monster_3 attacks you! - ``` - example_code_2: | - ``` - monster_1 {is} _ - monster_2 {is} _ - monster_3 {is} _ - {print} You enter the haunted house. - {print} Suddenly you see a monster_1 - {print} You run into the other room, but a monster_2 is waiting there for you! - {print} Oh no! Quickly get to the kitchen. - {print} But as you enter monster_3 attacks you! - ``` - 3: - story_text: | - In the previous levels you've made an introduction to your haunted house game, but as you might have noticed the story would always have a dreadful end. - In this level you can make your story more interactive by changing the outcome of the game; sometimes you'll get eaten, sometimes you'll escape! - Let Hedy decide randomly! - 4: - story_text: | - In this level you learn how to use quotation marks in your games. - Can you make your Haunted House level 4 proof? - example_code: | - ``` - {print} _Escape from the haunted house!_ - {print} _There are 3 doors in front of you..._ - choice {is} {ask} _Which door do you choose?_ - {print} _You picked door ..._ choice - monsters {is} a zombie, a vampire, NOTHING YOUVE ESCAPED - {print} _You see..._ - {sleep} - {print} monsters {at} {random} - ``` - 5: - story_text: | - Up until this level the haunted house game always asked the player to choose a door, but as you might have noticed, they didn't really have to answer correctly. - If the player filled in a completely random answer, the game would still work and the player might even win (despite not picking a door). - In this level you can only win the game by picking the same door Hedy picked randomly. - example_code: | - ``` - {print} 'Escape from the haunted house!' - {print} 'There are 3 doors in front of you...' - doors {is} 1, 2, 3 - monsters {is} werewolf, mummy, vampire, zombie - chosen_door {is} {ask} 'Which door do you choose?' - {print} 'You chose door...' chosen_door - {sleep} - correct_door {is} doors {at} {random} - {if} chosen_door {is} correct_door {print} 'Great! Youve escaped!' - {else} {print} 'Oh no! You are being eaten by a...' monsters {at} {random} - ``` - 9: - story_text: | - In this level you can use nesting, which allows you to make the haunted house even more interactive! - - Now it's very hard to win this game, can you make it easier to win? - For example by only having 1 wrong door and 2 correct doors instead of 1 correct door and 2 wrong ones? - 11: - story_text: | - In this level we've changed the repeat command and we've added a line to our haunted house that tells the player in which room they are. - example_code: | - ``` - {print} 'Escape from the Haunted House!' - player {is} alive - doors = 1, 2, 3 - monsters = zombie, vampire, giant spider - {for} i {in} {range} 1 {to} 3 - {if} player {is} alive - correct_door = doors {at} {random} - {print} 'Room ' i - {print} 'There are 3 doors in front of you...' - chosendoor = {ask} 'Which door do you choose?' - {if} chosendoor {is} correct_door - {print} 'No monsters here!' - {else} - {print} 'You are eaten by a ' monsters {at} {random} - player = dead - {else} - {print} 'GAME OVER' - {if} player {is} alive - {print} 'Great! You survived!' - ``` - if_command: - description: Introducing the if command - levels: - 9: - story_text: | - In this level you can also put an {if} command inside another {if} command. - in_command: - description: Introducing the in command - levels: - 5: - example_code_2: | - ``` - animals is dog, cow, sheep - answer is ask 'What is your favorite animal?' - _ answer _ animals _ 'Mine too!' - _ _ 'My favorite animals are dogs, cows and sheep' - ``` - is_command: - description: introducing is command - levels: - 2: - story_text_2: | - ### Exercise - Time to make your own variables! - In the example code we made an example of the variable `favorite_animal`. In line 1 the variable is set, and in line 2 we haved used the variable in a print command. - Firstly, finish our example by filling in your favorite animal on the blank. Then make at least 3 of these codes yourself. Pick a variable, and set the variable with the {is} command. Then use it with a {print} command, just like we did. - 14: - example_code: | - ``` - age = {ask} 'How old are you?' - {if} age > 12 - {print} 'You are older than I am!' - ``` - example_code_3: | - ``` - name = {ask} 'What is your name?' - {if} name != 'Hedy' - {print} 'You are not Hedy' - ``` - - {if} age < 13 - {print} 'You are younger than me!' - {else} - {print} 'You are older than me!' language: name: Lingua - levels: - 5: - story_text: | - Make your own program to practice your vocabulary in a new language. - maths: - levels: - 6: - example_code: | - ``` - {print} '5 plus 5 is ' 5 + 5 - {print} '5 minus 5 is ' 5 - 5 - {print} '5 times 5 is ' 5 * 5 - ``` - 12: - example_code_2: | - ``` - a = 'Hello ' - b = 'world!' - {print} a + b - ``` - - {print} 2.5 + 2.5 - music: - levels: - 6: - story_text: "Instead of playing notes, you can also play numbers now. Simply type `{play} 1` for the lowest note, `{play} 70` for the highest note, or anything in between.\n\n### Exercise\n This calls for musical maths! Try out the example code a couple of times with different starting numbers. \nThen, see if you can compose a song using the numbers.\n" parrot: name: Pappagallo default_save_name: Pappagallo @@ -1581,9 +814,6 @@ adventures: {sleep} {print} nome ``` - story_text_2: | - ### Exercise - You can use variables to make the parrot say more than only your name. Can you complete this code? 3: story_text: | Insegna al tuo pappagallo una nuova parola con `{add}`. @@ -1596,10 +826,6 @@ adventures: {print} 🧒 Dii parola_nuova , Hedy! {print} 🦜 parole {at} {random} ``` - 4: - story_text: | - In this level we have to use quotation marks with the commands `{ask}` and `{print}`. - Can you complete the code by adding quotation marks? 5: story_text: | Premia il tuo pappagallo se ({if}) dice la parola giusta. @@ -1615,50 +841,6 @@ adventures: _ detto_parola {is} nuova_parola _ '🧒 Ottimo lavoro, Hedy! 🍪' _ _ '🧒 No, Hedy! Pronuncia "nuova_parola". ``` - piggybank: - levels: - 12: - story_text: | - In this adventure you learn how to make a digital piggy bank, to calculate how much money you have and how long you need to save up to buy what you want! - example_code: | - ``` - {print} 'The digital piggy bank' - wish = {ask} 'What would you like to buy?' - price = {ask} 'How much does that cost?' - saved = {ask} 'How much money have you saved already?' - allowance = {ask} 'How much pocket money do you get per week?' - to_save = price - saved - weeks = to_save / allowance - {print} 'You can buy a ' wish ' in ' weeks ' weeks.' - ``` - 14: - example_code: | - ``` - _ calculate_budget with wish, money, allowance - to_save = wish - money - weeks = to_save / allowance - {if} wish _ money - {print} 'You need to save up some more!' - {print} 'Youll need ' weeks ' more weeks.' - {else} - {print} 'Great! You have enough' - {print} 'Lets go shopping!' - - money = {ask} 'How much money have you saved?' - wish = {ask} 'How much money do you need?' - allowance = {ask} 'How much pocket money do you get each week?' - - {call} calculate_budget with _, _, _ - ``` - pressit: - levels: - 9: - story_text: | - Now that you know how to combine statements, you can create a touch type tool with `{pressed}`. - - ### Exercise - Finish the code. Each time a random letter should be chosen, which you have to press. You get a point for a correct press, and and two points deduction for a wrong press. - **(extra)** Clear the screen after each letter, and show the user how many points they have scored. print_command: levels: 1: @@ -1672,161 +854,13 @@ adventures: Riempi il comando `{print}` nello spazio bianco e aggiungi cinque linee di codice aggiuntive. Ogni linea di codice deve iniziare con un comando `{print}`. Buon divertimento! - 18: - example_code_2: | - ``` - temperature = 25 - {print}('It is ', temperature, ' degrees outside') - ``` - - {print}('My name is ', name) quizmaster: description: Crea il tuo quiz! - random_command: - levels: - 16: - story_text: |- - We are going to make lists the Python way, with square brackets around the lists! We also keep the quotation marks around each item like we have learned in previous levels. - We use square brackets to point out a place in a list. For example: `friends[1]` is the first name on the list of friends, as you can see in the first part of the example code. The second part of the example code shows you that we can also match 2 lists using the variable i. - repeat_command: - description: repeat command - levels: - 7: - story_text: | - ## Repeat! Repeat! Repeat! - Level 7 adds the `{repeat}` command. `{repeat}` can be used to execute one line of code multiple times. Like this: - - ### Exercise - Play around with the repeat command. Can you make the happy birthday song in only 3 lines of code instead of 4 now? - 9: - story_text: | - Great job! You've reached another new level! In the previous level you've learned to use multiple lines of code in an {if} or {repeat} command. But you can't yet combine the two... - Good news! In this level you will be allowed to put an {if} inside an {if}, or inside a {repeat} command. Putting a block of code inside another block of code is called nesting. ``` Putting a block of code inside another block of code is called nesting. - example_code: | - ``` - answer = {ask} 'Are you ready to learn something new?' - {if} answer {is} yes - {print} 'Great! You can learn to use the repeat command in the if command!' - {print} 'Hooray!' - {print} 'Hooray!' - {print} 'Hooray!' - {else} - {print} 'Maybe you should practice some more in the previous level' - repeat_command_2: - description: repeat command 2 - levels: - 7: - story_text_2: | - Another interesting thing you can so with the `{repeat}` command is using variables to set the amount of times something should be repeated. In the example code you can see that we first ask the person how old they are. - Then, in line 3, the question is repeated 'age' times. So we have used the variable 'age' with the `{repeat}` command. restaurant: default_save_name: Ristorante description: Crea il tuo ristorante virtuale levels: - 1: - story_text_2: | - Can you think of more lines to add to your restaurant code? For example, can you {ask} the guests what they'd like to drink, tell them the price, or wish them a pleasant meal? - example_code_2: | - ``` - {print} Welcome to Hedy's restaurant 🍟 - {ask} What would you like to order? - {echo} So you would like to order - {print} Thanks you for your order! - {print} It's on its way! - ``` - 2: - story_text: | - In level 2 you could expand your restaurant by using variables. In level 1 Hedy could only {echo} the order once and only remember the last thing that was ordered. - Now you can use variables and Hedy can remember both the food and the drinks! - example_code: | - ``` - {print} Welcome to Hedy's restaurant! - {print} Today we're serving pizza or lasagna. - food {is} {ask} What would you like to eat? - {print} Great choice! The food is my favorite! - topping {is} {ask} Would you like meat or veggies on that? - {print} food with topping is on its way! - drinks {is} {ask} What would you like to drink with that? - {print} Thank you for your order. - {print} Your food and drinks will be right there! - ``` - story_text_2: | - ### Exercise - Can you make this code more elaborate? For example by adding drinks to the order? Or...? - 3: - example_code: | - ``` - {print} Welcome to Hedy's Random Restaurant! - {print} The only restaurant that will randomly choose your meal and its price for you! - starters {is} salad, soup, carpaccio - mains {is} pizza, brussels sprouts, spaghetti - desserts {is} brownies, ice cream, french cheeses - drinks {is} cola, beer, water - prices {is} 1 dollar, 10 dollars, 100 dollars - {print} You will start with: starters {at} {random} - {print} Then we'll serve: mains {at} {random} - {print} And as dessert: desserts {at} {random} - {print} You will get a drinks {at} {random} to drink - {print} That will be: prices {at} {random} - {print} Thank you and enjoy your meal! - ``` - story_text_2: | - Does your costumer have any allergies or do they dislike certain dishes? Then you can use the `{remove}`command to remove it from your menu. - example_code_2: | - ``` - {print} Mystery milkshake - flavors {is} strawberry, chocolate, vanilla - allergies {is} {ask} Are you allergic to any falvors? - {remove} allergies {from} flavors - {print} You get a flavors {at} {random} milkshake - ``` - 4: - story_text: | - ### Exercise - Add the quotation marks to this code to make it work! Be careful: variables should not be in quotation marks. - Then, use the `{clear}` command to only show one line at a time in your output screen. - - ### Exercise 2 - Go back to the previous level and copy your restaurant code. Make the code work in this level by adding quotation marks in the right spots and add some `{clear}` commands. - 5: - story_text: | - In this level the {if} command allows you to {ask} your customers questions and give different responses to the answers. - In the example below, you see that you can {ask} the customer {if} they want to hear the specials and Hedy can respond accordingly. - example_code: | - ``` - {print} 'Welcome to Hedys restaurant!' - special {is} {ask} 'Would you like to hear our specials today?' - {if} special {is} yes {print} 'Todays special is chicken piri piri and rice.' {else} {print} 'No problem.' - food {is} {ask} 'What would you like to eat?' - {print} 'One ' food ', coming right up!' - drink {is} {ask} 'What would you like to drink with that?' - {if} drink {is} cola {print} 'Im sorry, we are out of cola!' {else} {print} 'Great choice!' - anything {is} {ask} 'Would you like anything {else}?' - {print} 'Let me repeat your order...' - {print} 'One ' food - {if} drink {is} cola {print} 'and...' {else} {print} 'One ' drink - {if} anything {is} no {print} 'Thats it!' {else} {print} 'One ' anything - {print} 'Thank you for your order and enjoy your meal!' - ``` - 6: - story_text: | - In this level you can use maths to calculate the total price of your customer's order, which can make your virtual restaurant more realistic. - 7: - story_text: | - In this level you've learned how to use the {repeat} command to repeat a line of code a certain amount of times. - You can use that in your restaurant to {ask} multiple people what they'd like to eat. Like this: - example_code: | - ``` - {print} 'Welcome to Hedys restaurant!' - people = {ask} 'How many people are joining us today?' - {repeat} people times food = {ask} 'What would you like to eat?' - {print} 'Thanks for your order! Its coming right up!' - ``` 9: - story_text: | - In this level you can use nesting to make your restaurant more realistic and more fun! - For example you would {ask} for sauce {if} somebody orders fries, but you wouldn't {if} someone orders pizza! - Check out the example, and try this at your own virtual restaurant! example_code: | ``` {print} 'Benvenuti al Ristorante Chez Hedy!' @@ -1849,28 +883,7 @@ adventures: {print} 'Sarà il 'prezzo' in dollari' {print} 'Buon appetito!' ``` - 10: - story_text: | - In this level you'll learn how to easily {ask} your guests' orders in a short code. - example_code: | - ``` - courses = appetizer, main course, dessert - {for} course {in} courses - food = {ask} 'What would you like to eat as your ' course '?' - {print} food ' will be your ' course - ``` - example_code_2: | - ``` - courses = appetizer, main course, dessert - names = Timon, Onno - {for} name {in} names - {for} course {in} courses - food = {ask} name ', what would you like to eat as your ' course '?' - {print} name ' orders ' food ' as their ' course - ``` 11: - story_text: | - We can use the `{for} i {in} {range} 1 {to} 5` to {print} the orders from multiple customers in an orderly manner. example_code: | ``` {print} 'Benvenuti al Ristorante Hedy!' @@ -1881,245 +894,21 @@ adventures: 12: story_text: | Da questo livello in poi puoi usare i numeri decimali per rendere il tuo menu più realistico. - example_code: | - ``` - price = 0 - food = {ask} 'What would you like to order?' - drink = {ask} 'What would you like to drink?' - {if} food {is} 'hamburger' - price = price + 6.50 - {if} food {is} 'pizza' - price = price + 5.75 - {if} drink {is} 'water' - price = price + 1.20 - {if} drink {is} 'soda' - price = price + 2.35 - {print} 'That will be ' price ' dollar, please' - ``` - 13: - story_text: | - In this level we can use the new commands to upgrade our restaurant. - We use `{and}` to see {if} two things are both the case. - example_code: | - ``` - price = 10 - food = {ask} 'What would you like to eat?' - drinks = {ask} 'What would you like to drink?' - {if} food {is} 'sandwich' {and} drinks {is} 'juice' - {print} 'Thats our discount menu' - price = price - 3 - {print} 'That will be ' price ' dollars' - ``` rock: name: Sasso, carta, forbice default_save_name: Rock levels: - 1: - example_code: | - ``` - {print} what do you choose? - {ask} choose from rock, paper or scissors - {echo} so your choice was: - ``` - Instead of using words, you could also use emojis of course: ✊✋✌ + 2: - story_text: | - In this level you can practise using the variables, so that you can make the rock, paper, scissors game in the next level! example_code: |- ``` la scelta {is} rock {print} Scelgo _ ``` - 3: - example_code: | - ``` - choices {is} rock, paper, scissors - {print} choices {at} {random} - ``` - story_text_2: | - ### Exercise - Now you only have one player, so can you add a second player? - You can even use variables to name player 1 and player 2. - example_code_2: | - ``` - choices {is} rock, paper, scissors - {print} player 1 chooses... choices {at} {random} - {print} player 2 _ - ``` - 5: - story_text: | - In this level we can determine who won. - For that you need the new `{if}` code. - - Save your choice with the name of choice and the choice of computer as computer choice. - Then you can use `{if}` to see {if} they are the same or different. - Will you finish the code? - example_code: | - ``` - options {is} rock, paper, scissors - computer_choice {is} _ - choice {is} {ask} 'What do you choose?' - {print} 'you chose ' _ - {print} 'computer chose ' _ - {if} _ {is} _ {print} 'tie!' {else} {print} 'no tie' - ``` - - Fill in the correct code on the blanks to see {if} it is a draw. - 9: - story_text: | - In this level you can program the whole rock, paper, scissors game by nesting the {if}-commands. Can you finish the code? - example_code: | - ``` - choices = rock, paper, scissors - your_choice = {ask} 'What do you choose?' - {print} 'You choose ' your_choice - computer_choice = choices {at} {random} - {print} 'The computer chooses ' computer_choice - {if} computer_choice {is} your_choice - {print} 'Tie' - {if} computer_choice {is} rock - {if} your_choice {is} paper - {print} 'You win!' - {if} your_choice {is} scissors - {print} 'You lose!' - # finish this code - ``` - 10: - story_text: | - Feeling too lazy to play the game yourself? Let Hedy play it for you! - example_code: | - ``` - choices = rock, paper, scissors - players = Marleen, Michael - {for} player {in} players - {print} player ' chooses ' choices {at} {random} - ``` - 13: - story_text: | - With the `{and}` command you can shorten your rock, paper, scissors code! Check out the example code below and try to finish it. - example_code: | - ``` - options = 'rock', 'paper', 'scissors' - your_choice = {ask} 'What do you choose?' - computer_choice = options {at} {random} - {print} 'You choose ' your_choice - {print} 'The computer chooses ' computer_choice - {if} computer_choice {is} your_choice - {print} 'Tie' - {if} computer_choice {is} 'rock' {and} your_choice {is} 'paper' - {print} 'You win!' - {if} computer_choice {is} 'rock' {and} your_choice {is} 'scissors' - {print} 'The computer wins!' - ``` - 15: - example_code: | - ``` - won = 'no' - options = 'rock', 'paper', 'scissors' - {while} won == 'no' - your_choice = {ask} 'What do you choose?' - computer_choice = options {at} {random} - {print} 'you chose ' your_choice - {print} 'the computer chose ' computer_choice - {if} computer_choice == your_choice - {print} 'Tie!' - {if} computer_choice == 'rock' {and} your_choice == 'scissors' - {print} 'You lose!' - {if} computer_choice == 'rock' {and} your_choice == 'paper' - {print} 'You win!' - won = 'yes' - ``` - rock_2: - levels: - 2: - story_text: | - Now that you have learned how to use the `{ask} command, you can make your rock, paper, scissors code interavtive too! - - ### Exercise - Make the rock, paper, scissors code interactive by adding the `{ask}` command and a question to your rock, paper, scissors code. - example_code: | - ``` - choice is _ - {print} I choose choice - ``` - secret: - levels: - 12: - story_text: | - In this adventure you can create your own super spy code. Encode a message that only the right agent can decipher. - If the enemy tries to crack the code, they will get some false info to waste their time. - example_code: | - ``` - name {is} {ask} 'What is your name?' - {if} name {is} '_' - a {is} 'Go to the airport ' - {else} - a {is} 'Go to the trainstation ' - password {is} {ask} 'What is the password?' - {if} password {is} _ - b {is} 'tomorrow at 02.00' - {else} - b {is} 'today at 10.00' - {print} _ _ _ - ``` - 13: - story_text: | - The code you made in the previous level can be made a lot easier in this one with the `{and}` command. - sleep_command: - description: introducing sleep command - levels: - 2: - story_text: | - ## The sleep command - Another new command in this level is `{sleep}`, which pauses your program for a second. If you type a number behind the {sleep} command, the program pauses for that amount of seconds. songs: name: Canta una canzone! levels: - 6: - story_text: | - Songs often contain a lot of repetition. Sometimes the repetition is also based on counting. - For example, in the well-known song 'Bottles of beer'. You can program that song with a little math. - example_code: | - ``` - verse = 99 - {print} verse ' bottles of beer on the wall' - {print} verse ' bottles of beer' - {print} 'Take one down, pass it around' - verse = verse - 1 - {print} verse ' bottles of beer on the wall' - ``` - - You can now repeat lines 2 to 9 as many times as you want by copying the lines. - example_code_2: | - ``` - number = 6 - number = number - 1 - print number ' little monkeys jumping on the bed' - print 'One fell off and bumped his head' - print 'Mama called the doctor and the doctor said' - print 'NO MORE MONKEYS JUMPING ON THE BED!' - sleep - ``` - 7: - story_text: | - Songs often contain a lot of repetition. For example... Baby Shark! If you sing it, you keep singing the same thing: - - Baby Shark tututudutudu
- Baby Shark tututudutudu
- Baby Shark tututudutudu
- Baby Shark - - You can make this song much shorter with a `{repeat}`! Can you finish the code? - example_code: | - ``` - {repeat} _ _ {print} 'Baby Shark tututudutudu' - {print} 'Baby Shark' - ``` - - After Baby Shark you can of course also program other songs. There are many songs with repetition. 8: - story_text: | - In a previous level you've programmed the song 'Bottles of beer'. You made one verse and then had to copy the verses 99 times. In level 7 you can repeat the song 99 times, just by adding one simple line! example_code: | ``` verso = 99 @@ -2131,175 +920,21 @@ adventures: {print} versetto 'bottiglie di birra sul muro' ``` 10: - story_text: | - In this level you can easily make the childrens' song 'Five little monkeys'. Can you make the last chorus? - You can also make the whole baby shark song (including all the other sharks in the family) in only 6 lines! - Or you can make Old MacDonald with all the different animals. example_code: | ``` famiglia = bambino, mamma, papà, nonna, nonno _ _ _ _ {print}_ ``` - story_text_2: | - ### Exercise 2 - Print the song Five little moneys jumping on the bed. Look up the text if you don't remember. - - **(extra)** Print the song Old MacDonald had a farm, and make sure all animals make a different sound, using an `{if}`. - 11: - story_text: | - In this level you can use the `{for} i {in} {range}` command to make songs that use counting. - example_code: | - ``` - {for} i {in} {range} 5 {to} 1 - {print} i ' little monkeys jumping on the bed' - {print} 'One fell off and bumped his head' - {print} 'Mama called the doctor and the doctor said' - {if} i {is} 1 - {print} 'PUT THOSE MONKEYS RIGHT TO BED!' - {else} - {print} 'NO MORE MONKEYS JUMPING ON THE BED!' - ``` - songs_2: - levels: - 12: - example_code: | - ``` - {define} twinkle - {print} 'Twinkle' - {print} '...' - - {call} twinkle - {print} 'Up above the world so high' - {print} 'Like a diamond in the sky' - {call} _ - ``` turtle: default_save_name: Tartaruga levels: - 1: - story_text: | - You can also use Hedy to draw. By combining turns and lines, you can make a square or stairs! - - Using `{forward}` you draw a line forwards. The number behind it determines how far the turtle will walk. `{turn} {right}` turns a quarter turn in clockwise direction, `{turn} {left}` turns counter clockwise. - If you want to go backwards, you use the `{forward}` command but with a negative number. So for example `{forward} -100` 3: story_text: | In questo livello puoi usare `{at} {random}` con la tartaruga che disegna. Una scelta casuale fa sì che la tartaruga percorra ogni volta un percorso diverso. Utilizza `{at} {random}` per scegliere un valore da un elenco. ### Esercizio Puoi copiare e incollare le righe 2 e 3 per creare un percorso casuale più lungo? - 4: - example_code: | - ``` - {print} 'Drawing figures' - angle {is} 90 - {turn} angle - {forward} 25 - {turn} angle - {forward} 25 - ``` - 5: - example_code_2: | - ``` - direction {is} {ask} 'Do you want to go left, right, or straight ahead?' - if direction is left turn _ - if direction is right turn _ - forward 100 - ``` - 8: - story_text: | - Now that we can repeat several lines, we can make figures more easily. - We only have to set the angle once and then use that variable in the `{repeat}`. - example_code: | - ``` - angle = 90 - {repeat} 10 {times} - {turn} angle - {forward} 50 - ``` - story_text_2: | - Also, we can now improve the program that draws different figures. - Can you figure out how far the turtle has to turn here? Finish the code and you can draw any polygon you'd like! - 9: - story_text: | - Now that we can use a `{repeat}` inside a `{repeat}`, we can create more complex figures. - - ### Exercise 1 - This code creates three black triangles, change that into five pink squares. - - **(extra)** Create a figure of your own choosing consisting of at least two different shapes types. - 10: - story_text: | - In this level you can make the turtle draw a figure. - The turtle will travel the distances in the list, one by one, making bigger and bigger steps. - ### Exercise 1 - Add a 90 degree turn in the loop, so that a spiral is drawn. - Add at least 5 numbers to the list, so the spiral grows larger. - **(extra)** can you change the spiral into another shape? Experiment with numbers for the turn! - ### Exercise 2 - The spiral is drawn outwards, make it go inwards? - turtle_draw_it: - levels: - 9: - example_code: | - Hint for the nested squares: - ``` - colors = red, blue, orange, yellow, pink, purple, green, brown, black - distance = 120 - repeat 5 times - _ - ``` - Hint for the flags: - ``` - country = ask 'which country would you like to see the flag of?' - if country is 'the Netherlands' - color_1 = red - color_2 = white - color_3 = blue - ``` - 10: - example_code: | - Hint Nested Hexagon: - ``` - distances = 100, 80, 60, 40, 20 - {for} distance {in} distances - _ - ``` - - Hint Traffic Lights: - ``` - colors = red, yellow, green - {for} chosen_color {in} colors - color _ - {repeat} _ - ``` - 12: - story_text: | - ### Exercise - Recreate the drawings with the turtle! - Hint: Bracelet designing program. Firstly, define a function **for each shape** you want to use on the bacelet. Then, add the shapes to the bacelet like this: - - Bracelet Designing program - example_code: | - ``` - {define} draw_a_square - _ - - {color} white - {turn} -90 - {forward} 300 - {turn} 180 - - {for} i {in} {range} 1 {to} 5 - {color} gray - {forward} 100 - shape = {ask} 'What kind of shape would you like next on the bracelet?' - chosen_color = {ask} 'In which color?' - {color} chosen_color - {if} shape = 'square' - {call} draw_a_square - ``` while_command: description: while levels: @@ -2316,16 +951,3 @@ adventures: name: Anno nuovo default_save_name: Conto alla rovescia per il nuovo anno description: Conto alla rovescia per il nuovo anno! - levels: - 11: - story_text: | - In this level you can use the `{for} i {in} {range}` command to countdown to the New Year. - - ### Exercise - Fill in the blanks and make the code work! - example_code: | - ``` - for _ in _ 10 to 1 - {print} i - {print} 'Happy New Year!' - ``` diff --git a/content/adventures/ja.yaml b/content/adventures/ja.yaml index 083601c436f..0adf0d3157b 100644 --- a/content/adventures/ja.yaml +++ b/content/adventures/ja.yaml @@ -3,2021 +3,6 @@ adventures: name: 物語 default_save_name: 物語 description: 物語 - levels: - 1: - story_text_2: | - ### Exercise - Can you make your own story in Hedy now by using `{print}` , `{ask}` and `{echo}`? - 2: - 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: - example_code_2: | - ``` - {print} He hears a sound - animals {is} 🐿, 🦔, 🦇, 🦉 - animal {is} {ask} What do you think it is? - {add} animal {to_list} animals - {print} it was a animals {at} {random} - ``` - story_text_3: | - This is an example of the `{remove}` command in your story - 5: - story_text: | - In this level you can program different endings, which will make your story even more fun. - - 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 'encounter 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}`. - 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! - 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. - 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' - ``` - add_remove_command: - name: '{add} {to} & {remove} {from}' - 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. - 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. - and_or_command: - description: introducing and or - ask_command: - description: Introduction ask command - levels: - 1: - 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. - calculator: - levels: - 6: - story_text: | - Now that you can calculate, you can also create a program to practice maths calculations. You can make up the calculations yourself, for example: - example_code: | - ``` - correct_answer = 11 * 27 - answer = {ask} 'How much is 11 times 27?' - {if} answer {is} correct_answer {print} 'good job!' - {else} {print} 'Wrong! It was ' correct_answer - ``` - story_text_2: | - You can also let the computer do random calculations on its own using {random}. - example_code_2: | - ``` - tables = 4, 5, 6, 8 - numbers = 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 - table = tables {at} {random} - number = numbers {at} {random} - correct_answer = table * number - answer = {ask} 'how much is ' table ' times ' number '?' - {if} answer {is} correct_answer {print} 'okay' - {else} {print} 'mistake! it was ' correct_answer - ``` - 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`. - 11: - example_code: | - ``` - number = 10 - {for} i {in} {range} 1 to 10 - {print} i * number - ``` - 12: - story_text: | - Now you can make a calculator that works for decimal numbers. - example_code: | - ``` - number1 = {ask} 'What is the first number?' - number2 = {ask} 'What is the second number?' - answer = number1 + number2 - {print} number1 ' plus ' number2 ' is ' answer - ``` - 14: - 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 - clear_command: - description: clear command - debugging: - levels: - 3: - 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} - ``` - 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! - 8: - 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: - 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!' - {else} - 'I'm sorry we don't sell that' - topping {is} {ask} 'What kind of topping would you like?' - sauce {is} {ask} 'What kind of sauce would you like?' - {print} One chosen_bread with topping and sauce. - price = amount * 6 - {print} 'That will be 'price dollar' please' - ``` - - price = amount * 6 - {print} 'That will be 'price dollar' please' - 10: - example_code: | - **Warning! This code needs to be debugged!** - ``` - names = Muad Hasan Samira Noura - activities = fly a kite, go swimming, go hiking, catch tan in the sun - {for} name {is} names - {print} At the beach name loves to activity at random - ``` - 11: - story_text: |- - ### Exercise - Debug this calender program. The output of this program is supposed to look like a list of dates. - For example: - - ``` - Hedy calender - Here are all the days of November - November 1 - November 2 - November 3 - ``` - And so on. - - Mind that you have to test your code extra carefully for the month February, because the amount of days in this month changes in leap years. - example_code: | - **Warning! This code needs to be debugged!** - ``` - print 'Hedy calender' - months_with_31 days = January, March, May, July, September, October, December - months_with_30_days = April, June, August, November - month = ask 'Which month would you like to see?' - if month in months_with_31_days - days = 31 - if month in months_with30_days - days = 30 - if month = February - leap_years = 2020, 2024, 2028, 2036, 2040, 2044, 2028 - year = ask 'What year is it?' - if year in leap_years - days = 29 - else - days = 28 - - print 'Here are all the days of ' moth - for i in range 1 to days - print month i - ``` - 12: - example_code: | - **Warning! This code needs to be debugged!** - ``` - define greet - greetings = 'Hello', 'Hi there', 'Goodevening' - print greetings at random - - define take_order - food = ask 'What would you like to eat?' - print 'One food' - drink = 'What would you like to drink?' - print 'One ' drink - more = ask 'Would you like anything else?' - if more is 'no' - print 'Alright' - else - print 'And ' more - print 'Thank you' - - print 'Welcome to our restaurant' - people = ask 'How many people are in your party tonight?' - for i in range 0 to people - call greet_costumer - ``` - 13: - example_code: | - **Warning! This code needs to be debugged!** - ``` - defin movie_recommendation with name - action_movies == 'Die Hard', 'Fast and Furious', 'Inglorious Bastards' - romance_movies = 'Love Actually', 'The Notebook', 'Titanic' - comedy_movies = 'Mr Bean' 'Barbie''Deadpool' - kids_movies = 'Minions', 'Paddington', 'Encanto' - if name is 'Camila' or name is 'Manuel' - recommended_movie = kids_movie at random - if name is 'Pedro' or 'Gabriella' - mood = ask 'What you in the mood for?' - if mood is 'action' - recommended_movie = comedy_movies at random - if mood is 'romance' - recommended_movie = romance_movies - if mood is 'comedy' - recommended_movie = comedy_movies at random - - print 'I would recommend ' recommended_movie ' for ' name - - name = ask 'Who is watching?' - recommendation = ask 'Would you like a recommendation?' - if recommendaion is 'yes' - print movie_recommendation with name - else - print 'No problem!' - ``` - 14: - example_code: | - **Warning! This code needs to be debugged!** - ``` - define calculate_heartbeat - print 'Press your fingertips gently against the side of your neck' - print '(just under your jawline)' - print 'Count the number of beats you feel for 15 seconds' - beats == ask 'How many beats do you feel in 15 seconds?' - heartbeat = beats*4 - print 'Your heartbeat is ' heartbeat - if heartbeat >= 60 or heartbeat <= 100 - print 'Your heartbeat seems fine' - else - if heartbeat > 60 - print 'Your heartbeat seems to be too low' - if heartbeat < 100 - print 'Your heartbeat seems to be too high' - print 'You might want to contact a medical professional' - - measure_heartbeat = ask 'Would you like to measure your heartbeat?' - if measure_heartbeat = 'yes' - call measure_heartbeat - else - 'no problem' - ``` - - print '(just under your jawline)' - print 'Count the number of beats you feel for 15 seconds' - beats == ask 'How many beats do you feel in 15 seconds?' - heartbeat = beats*4 - print 'Your heartbeat is ' heartbeat - if heartbeat >= 60 or heartbeat <= 100 - print 'Your heartbeat seems fine' - else - if heartbeat > 60 - print 'Your heartbeat seems to be too low' - if heartbeat < 100 - print 'Your heartbeat seems to be too high' - print 'You might want to contact a medical professional' - - measure_heartbeat = ask 'Would you like to measure your heartbeat?' - if measure_heartbeat = 'yes' - call measure_heartbeat - else - 'no problem' - 15: - example_code: | - **Warning! This code needs to be debugged!** - ``` - names = 'Tanya', 'Romy', 'Kayla', 'Aldrin', 'Ali' - verbs='walking', 'skipping', 'cycling', 'driving', 'running' - locations = 'on a mountaintop', 'in the supermarket', 'to the swimming pool' - hiding_spots = 'behind a tree', under a table', in a box' - sounds = 'a trumpet', 'a car crash', 'thunder' - causes_of_noise = 'a television', 'a kid with firecrackers', 'a magic elephant', 'a dream' - - chosen_ name = names at random - chosen_verb = verbs at random - chosen_location = 'locations at random' - chosen_sounds = noises at random - chosen_spot = hiding_spots random - chosen_causes = causes_of_noise at random - - print chosen_name ' was ' chosen_verb ' ' chosen_location - print 'when they suddenly heard a sound like ' sounds at random - print chosen_name ' looked around, but they couldn't discover where the noise came from' - print chosen_name ' hid ' chosen_spot' - print 'They tried to look around, but couldn't see anything from there' - hidden = 'yes' - while hidden = 'yes' - print chosen_name 'still didn't see anything' - answer = ask 'does ' chosen_name ' move from their hiding spot?' - if answer = 'yes' - hidden == 'no' - print 'chosen_name moved from' chosen_spot - print 'And then they saw it was just' chosen_cause - print chosen_name 'laughed and went on with their day' - print The End - ``` - 16: - example_code: | - **Warning! This code needs to be debugged!** - ``` - country = ['The Netherlands', 'Poland', 'Turkey', 'Zimbabwe', 'Thailand', 'Brasil', 'Peru', 'Australia', 'India', 'Romania' ] - capitals = 'Amsterdam', 'Warshaw' 'Istanbul', 'Harare', 'Bangkok', 'Brasilia', 'Lima', 'Canberra', 'New Delhi', 'Bucharest' - score = 0 - for i in range 0 to 10 - answer = ask 'What's the capital of ' countries[i] - correct = capital[i] - if answer = correct - print 'Correct!' - score = score + 1 - else - print 'Wrong,' capitals[i] 'in the capital of' countries[i] - print 'You scored ' score ' out of 10' - - ``` - 17: - example_code: | - **Warning! This code needs to be debugged!** - ``` - define food_order - toppings = ask 'pepperoni, tuna, veggie or cheese?' - size = ask 'big, medium or small?' - number_of_pizza = ask 'How many these pizzas would you like?' - - print 'YOU ORDERED' - print number_of_pizzas ' size ' topping ' pizza' - - define drinks_order - drink = ask 'water, coke, icetea, lemonade or coffee?' - number_of_drinks = ask 'How many of these drinks would you like?' - - print 'YOU ORDERED' - print number_of_drinks ' ' drink - - 'Welcome to Hedy pizza' - more_food = ask 'Would you like to order a pizza?' - while more_food = 'yes' - return food_order - more_food = ask 'Would you like to order a pizza?' - more_drinks = ask 'Would you like to order some drinks?' - while more_drinks == 'yes' - call drink_order - more_drinks == ask 'Would you like to order more drinks?' - - - print 'Thanks for ordering!' - ``` - 18: - example_code: | - **Warning! This code needs to be debugged!** - ``` - animals = ['pig', 'dog', 'cow'] - sounds = ['oink', 'woof', 'moo'] - for i in range 1 to 3 - animal = animals[i] - sound = sounds[i] - print 'Old MacDonald had a farm' - print 'E I E I O!' - print 'and on that farm he had a ' animal - print 'E I E I O!' - print 'with a ' sound sound ' here' - print 'and a ' sound sound ' there' - print 'here a ' sound - print 'there a ' sound - print 'everywhere a ' sound sound - ``` default: name: はじめに description: レベルの説明 - levels: - 1: - story_text: | - In Level 1 you can use the commands `{print}`, `{ask}` and `{echo}`. - Type your code in the programming field. Or press the green button in the example code block, and the code will be typed for you! - Try the code yourself with the green 'Run code' button under the programming field. - - You can print text to the screen using the `{print}` command. - 3: - story_text: | - In level 3 you can make a list. You can let the computer choose something random from the list. You do that with `{at} {random}`. - 4: - story_text: | - In level 4 `{ask}` and `{print}` have changed. - - You must put text that you want to print between quotation marks. - - This is useful, because now you can print all the words you want. Also the words you used to store something with `{is}`. - - Most programming languages also use quotation marks when printing, so we are also getting a step closer to real programming! - example_code: | - ``` - {print} 'You need to use quotation marks from now on!' - answer {is} {ask} 'What do we need to use from now on?' - {print} 'We need to use ' answer - ``` - 5: - story_text: | - In level 5 there is something new, the `{if}`! With the `{if}` you can choose between two different options. - This code prints nice if you enter Hedy as a name, and boo! if you enter something else. - `{ask}` and `{print}` still work like they did in level 4. - example_code: | - ``` - name {is} {ask} 'what is your name?' - {if} name {is} Hedy {print} 'nice' {else} {print} 'boo!' - ``` - 6: - story_text: | - In the previous level you have practiced with `{ask}` and `{if}`. For example you can ask guests what they would like to eat. - What you can't yet do though, is calculate the price for everyone's dinner. - - In the previous level you have practiced with `{ask}` and `{if}`. For example you can ask guests what they would like to eat. - What you can't yet do though, is calculate the price for everyone's dinner. - - This level makes it possible to use addition, subtraction and multiplication in your programs. This way you can calculate the prices in your restaurant, but you could also add a secret code to give your friends and family a discount. - Another option in this level is programming your own maths game, for your little brother or sister to practice their multiplications. - Go see for yourself! - example_code: | - ``` - {print} '5 plus 5 is ' 5 + 5 - {print} '5 minus 5 is ' 5 - 5 - {print} '5 times 5 is ' 5 * 5 - ``` - 7: - story_text: | - Level 7 adds the `{repeat}` command. `{repeat}` can be used to execute one line of code multiple times. - example_code: | - ``` - {repeat} 3 {times} {print} 'Hedy is fun!' - ``` - 8: - story_text: | - `{ask}` and `{print}` still work as you know them. But `{if}` and `{repeat}` have changed! - You can now execute groups of code together, but you will have to *indent* the code. - That means putting four spaces at the beginning of the line. You will also have to indent when you just want to create a block of one line. - example_code: | - ``` - {repeat} 5 {times} - {print} 'Hello everyone' - {print} 'This is all repeated 5 times' - ``` - 10: - story_text: |- - In this level we learn a new code called `{for}`. With `{for}` you can make a list and use all elements. - `{for}` creates a block, like `{repeat}` and `{if}` so all lines in the block need to start with spaces. - example_code: | - ``` - animals {is} dog, cat, blobfish - {for} animal {in} animals - {print} 'I love ' animal - ``` - 12: - story_text: |- - **Decimal numbers** - So far, Hedy did not allow for decimal numbers like 1.5, but now we do allow that. Note that computers use the `.` for decimal numbers. - example_code: | - ``` - {print} 'Two and a half plus two and a half is...' - {print} 2.5 + 2.5 - ``` - - {print} 2.5 + 2.5 - 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!' - ``` - 14: - story_text: | - We are going to learn more new items. You might know them already from mathematics, the `<` and `>`. - The `<` checks if the first number is smaller than the second, for example `age < 12` checks if `age` {is} smaller than 12. - If you want to check if the first number is smaller or equal to the second, you can use `<=`, for example `age <= 11`. - The `>` checks if the first number is bigger than the second, for example `points > 10` checks if `points` is larger than 10. - If you want to check if the first number is bigger or equal to the second, you can use `>=`, for example `points >= 11`. - You use these comparisons in an `{if}`, like this: - example_code: | - ``` - age = {ask} 'How old are you?' - {if} age > 12 - {print} 'You are older than I am!' - ``` - - {if} age < 13 - {print} 'You are younger than me!' - {else} - {print} 'You are older than me!' - 15: - story_text: |- - We are going to learn a new loop, the `{while}` loop! We continue the loop as long as the statement is true. - So don't forget to change the value in the loop. - - In the example code, we continue until a correct answer has been given. - If the correct answer is never given, the loop never ends! - example_code: | - ``` - answer = 0 - {while} answer != 25 - answer = {ask} 'What is 5 times 5?' - {print} 'A correct answer has been given' - ``` - 16: - story_text: |- - We are going to make lists the Python way, with square brackets around the lists! We also keep the quotation marks around each item like we have learned in previous levels. - You can use the square brackets as well to point out a place in the lists. - example_code: | - ``` - friends = ['Ahmed', 'Ben', 'Cayden'] - {print} friends[1] ' is the first friend on the list.' - {print} friends[2] ' is the second friend on the list.' - {print} friends[3] ' is the third friend on the list.' - #now we will match 2 lists using the variable i - lucky_numbers = [15, 18, 6] - {for} i {in} {range} 1 {to} 3 - {print} friends[i] 's lucky number is ' lucky_numbers[i] - ``` - 17: - story_text: |- - Now we are going to change indentation a little bit. Every time that we need an indentation, we need `:` at the line before the indentation. - - In this level you can also use a new command: `{elif}`. `{elif}` is short for `{else} {if}` and you need it when you want to make 3 (or more!) options. - Check it out! - 18: - story_text: |- - We arrived at real Python code! That means we need to use parentheses with {print} and {range} from now on. - {print}('My name is ', naam) - dice: - levels: - 3: - example_code: | - ``` - choices {is} 1, 2, 3, 4, 5, earthworm - {print} choices {at} {random} - ``` - 4: - story_text: | - In this level we can make sentences with the die value in the sentence, with quotes of course. - This time the sample code is not quite complete. Can you finish the code? - 5: - story_text: | - You can also make a die again in this level using the `{if}`. - Complete the sample code so that the code says "You can stop throwing" once you have thrown an earthworm. - - But maybe you want to recreate a die from a completely different game. That's fine too! Then make up your own reaction. Eg 'yes' for 6 and 'pity' for something {else}. - example_code: | - ``` - choices {is} 1, 2, 3, 4, 5, earthworm - throw {is} _ - {print} 'you have' _ 'thrown' - {if} _ {is} earthworm {print} 'You can stop throwing.' _ {print} 'You have to hear it again!' - ``` - 6: - story_text: | - You can also make an Earthworm die again in this, but now you can also calculate how many points have been rolled. - You may know that the worm counts 5 points for Earthworms. Now after a roll you can immediately calculate how many points you have thrown. - This is the code to calculate points for one die: - example_code: | - ``` - choices = 1, 2, 3, 4, 5, earthworm - points = 0 - throw = choices {at} {random} - {print} 'you threw' throw - {if} throw {is} earthworm points = points + 5 {else} points = points + throw - {print} 'those are' points ' point' - ``` - Can you make the code so that you get the total score for 8 dice? To do that, you have to cut and paste some lines of the code. - example_code_2: | - Did you manage to calculate the score for 8 dice? That required a lot of cutting and pasting, right? We are going to make that easier in level 7! - 7: - story_text: | - You can also make a die again in level 5. With the `{repeat}` code you can easily roll a whole hand of dice. - Try to finish the sample code! The dashes should contain multiple commands and characters. - - But maybe you want to make a completely different die. Of course you can! - example_code: | - ``` - choices = 1, 2, 3, 4, 5, earthworm - {repeat} _ _ {print} _ _ _ - ``` - 10: - story_text: | - Is everybody taking too long throwing the dice? In this level you can let Hedy throw all the dice at once! - example_code: | - ``` - players = Ann, John, Jesse - choices = 1, 2, 3, 4, 5, 6 - {for} player {in} players - {print} player ' throws ' choices {at} {random} - {sleep} - ``` - dishes: - description: Use the computer to see who does the dishes (Start at level 2) - levels: - 3: - story_text: | - Do you always disagree at home about who should wash the dishes or change the litter box today? - Then you can let the computer choose very fairly. You can program that in this level! - You first make a list of the members of your family. Then choose '{at} {random}' from the list. - example_code: | - ``` - people {is} mom, dad, Emma, Sophie - {print} people {at} {random} - ``` - story_text_2: | - Don't feel like doing the dishes yourself? Hack the program to remove your name from the list. - 4: - story_text: | - With quotation marks you can make your dishwashing planning more beautiful. - This time the sample code is not quite complete. - - Can you complete the code by filling the blanks? Every blank must be replaced with one word of symbol. - - Tip: Don't forget the quotation marks! - 5: - story_text: | - With the `{if}` you can now have more fun with choice in the program. You can have your program respond to the choice that the computer has made. - - Can you finish the code so that it prints 'too bad' when it is your turn and otherwise 'yes!'? - Don't forget the quotes! - example_code: | - ``` - people {is} mom, dad, Emma, Sophie - dishwasher {is} people {at} {random} - {if} dishwasher {is} Sophie {print} _ too bad I have to do the dishes _ {else} {print} 'luckily no dishes because' _ 'is already washing up' - ``` - 6: - story_text_2: | - If you are extremely unlucky the previous program might choose you to to the dishes for the whole week! That's not fair! - To create a fairer system you can use the `{remove}` command to remove the chosen person from the list. This way you don't have to do the dishes again untill everybody has had a turn. - - Monday and tuesday are ready for you! Can you add the rest of the week? - And... can you come up with a solution for when your list is empty? - example_code_2: | - ``` - people = mom, dad, Emma, Sophie - dishwasher = people {at} {random} - {print} 'Monday the dishes are done by: ' dishwasher - {remove} dishwasher {from} people - dishwasher = people {at} {random} - {print} 'Tuesday the dishes are done by: ' dishwasher - {remove} dishwasher {from} people - dishwasher = people {at} {random} - ``` - 7: - story_text: | - With the `{repeat}` you can repeat pieces of code. You can use this to calculate who will be washing dishes for the entire week. - example_code: | - ``` - people = mom, dad, Emma, Sophie - {repeat} _ _ {print} 'the dishwasher is' _ - ``` - 10: - story_text: | - In this level you could make an even better dish washing shedule. - elif_command: - description: elif - levels: - 17: - example_code: | - ``` - prices = ['1 million dollars', 'an apple pie', 'nothing'] - your_price = prices[{random}] - {print} 'You win ' your_price - {if} your_price == '1 million dollars' : - {print} 'Yeah! You are rich!' - {elif} your_price == 'an apple pie' : - {print} 'Lovely, an apple pie!' - {else}: - {print} 'Better luck next time..' - ``` - for_command: - description: for command - levels: - 11: - story_text: |- - In this level, we add a new form of the `{for}`. In earlier levels, we used `{for}` with a list, but we can also use `{for}` with numbers. - We do that by adding a variable name, followed by `{in}` `{range}`. We then write the number to start at, `{to}` and the number to end at. - Try the example to see what happens! In this level again, you will need to use indentations in lines below the `{for}` statements. - fortune: - levels: - 1: - story_text: | - Have you ever been to a carnival and had your future predicted by a fortune teller? Or have you ever played with a magic eight ball? - Then you probably know that they can't really predict your future, but it's still fun to play! - - In the upcoming levels you can learn how to create your own fortune telling machine! - In level 1 you can start off easy by letting Hedy introduce herself as a fortune teller and let her {echo} the players' answers. - Like this: - example_code: | - ``` - {print} Hello, I'm Hedy the fortune teller! - {ask} Who are you? - {print} Let me take a look in my crystal ball - {print} I see... I see... - {echo} Your name is - ``` - story_text_2: | - ### Exercise - Hedy now only tells you your name. Can you expand the code so that Hedy can predict more things about you? - Obviously, Hedy isn't a very good fortune teller yet, as she can only repeat the answers that were given by the players! - Take a look in level 2 to improve your fortune teller. - 3: - story_text: | - In the previous levels you've created your first fortune telling machine, but Hedy couldn't really predict anything, only {echo}. - In this level you can use a variable and the `{at} {random}` command to really let Hedy choose an answer for you. Check out this code for instance: - story_text_2: | - ### Exercises - Now, Hedy can only answer yes, no or maybe. Can you give Hedy more answer options, like 'definitely' or '{ask} again'. - 4: - example_code: | - ``` - {print} 'Im Hedy the fortune teller!' - question {is} {ask} 'What do you want to know?' - {print} 'This is your question: ' question - answers {is} yes, no, maybe - {print} 'My crystal ball says...' - {sleep} 2 - {print} answers {at} {random} - ``` - 5: - story_text: | - In this level you'll learn to (secretly) tip the odds in your favor, when using the fortune teller! - By using `{if}` and `{else}` you can make sure that you will always get a good fotune, while other people might not. - Check out this example to find out how. - example_code: | - ``` - {print} 'Im Hedy the fortune teller!' - {print} 'I can predict {if} youll win the lottery tomorrow!' - person {is} {ask} 'Who are you?' - {if} person {is} Hedy {print} 'You will definitely win!🤩' {else} {print} 'Bad luck! Someone {else} will win!😭' - ``` - 6: - story_text: | - In this level you can use math in your predictions as a fortune teller. This allows you to make up (silly) formulas to calculate the future. - For example you could calculate how rich you'll get or how many kids you will have when you grow up. - example_code: | - ``` - {print} 'I am Hedy the fortune teller!' - {print} 'I can predict how many kids youll get when you grow up!' - age = {ask} 'How old are you?' - siblings = {ask} 'How many siblings do you have?' - length = {ask} 'How tall are you in centimetres?' - kids = length / age - kids = kids - siblings - {print} 'You will get ...' - {sleep} - {print} kids ' kids!' - ``` - - If the previous example wasn't silly enough for you, take a look at this one! - - ``` - {print} 'Im Hedy the silly fortune teller!' - {print} 'I will predict how smart you are!' - football = {ask} 'On a scale 1-10 how much do you love football?' - bananas = {ask} 'How many bananas did you eat this week?' - hygiene = {ask} 'How many times did you wash your hands today?' - result = bananas + hygiene - result = result * football - {print} 'You are ' result ' percent smart.' - ``` - 7: - story_text: | - In this level you can use the `{repeat}` command to make your machine tell multiple fortunes at once. - example_code: | - ``` - {print} 'Im Hedy the fortune teller!' - {print} 'You can {ask} 3 questions!' - {repeat} 3 {times} question = {ask} 'What do you want to know?' - answer = yes, no, maybe - {repeat} 3 {times} {print} 'My crystal ball says... ' answer {at} {random} - ``` - 8: - story_text: | - In the previous levels you've learned how to use repeat to make the fortune teller answer 3 questions in a row, but we had a problem with printing the questions. - Now that problem is solved, because of the new way of using the repeat command. - In the next example you can have your fortune teller {ask} 3 questions and also print them! - example_code: | - ``` - {print} 'I am Hedy the fortune teller!' - {print} 'You can {ask} me 3 questions.' - answers = yes, no, maybe - {repeat} 3 {times} - question = {ask} 'What do you want to know?' - {print} question - {sleep} - {print} 'My crystal ball says...' answers {at} {random} - ``` - 10: - story_text: | - In this level you'll learn how to program the game MASH (mansion, apartement, shack, house). In this game you can predict for all the players at once, what their future will look like. - example_code: | - ``` - houses = mansion, apartment, shack, house - loves = nobody, a royal, their neighbour, their true love - pets = dog, cat, elephant - names = Jenna, Ryan, Jim - {for} name {in} names - {print} name ' lives in a ' houses {at} {random} - {print} name ' will marry ' loves {at} {random} - {print} name ' will get a ' pets {at} {random} ' as their pet.' - {sleep} - ``` - 12: - story_text: | - In this level you can make your fortunes multiple words. Like in this example below: - example_code: | - ``` - fortunes = 'you will be rich', 'you will fall in love', 'you will slip on a banana peel' - {print} 'I will take a look in my crystall ball for your future.' - {print} 'I see... I see...' - {sleep} - {print} fortunes {at} {random} - ``` - functions: - levels: - 12: - example_code: | - ``` - sides = 'left', 'right' - limbs = 'hand', 'foot' - colors = 'red', 'blue', 'green', 'yellow' - - {define} turn - chosen_side = sides {at} {random} - chosen_limb = limbs _ - chosen_color = colors _ - {print} chosen_side ' ' chosen_limb ' on ' chosen_color - - {print} 'Lets play a game of Twister!' - {for} i {in} {range} 1 to _ - {call} turn - {sleep} 2 - ``` - 13: - story_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. - - For example in this code we've programmed the first verse of the song 'My Bonnie is over the ocean'. - In this example code the argument `place` is used. Place is a variable that is only used in the function, so an argument. - To use `place` we have programmed the line `define song with place`. - When the function is called, computer will replace the argument `place`, with the piece of text after `call song with`. - - ### Exercise - The next verse of this song goes: - - Last night as I lay on my pillow - Last night as I lay on my bed - Last night as I lay on my pillow - I dreamed that my Bonnie is dead - - Can you program this verse in the same way as the example? - 14: - example_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?' - - new_price = _ calculate_new_price {with} old_price, _ - {print} 'The new price is ' new_price ' dollar' - ``` - haunted: - levels: - 1: - story_text: | - In this adventure you are working towards making a game in which you have to escape from a haunted house by picking the correct door. - If you pick the right door you'll survive, but {if} not a terrible monster might... - - In level 1 we start our haunted house game by making up a scary story and {ask} the player what monster they'll see in the haunted house. - story_text_2: | - ### Exercise - Can you finish the scary story? Or make up your own haunted house story? - 2: - example_code: | - ``` - monster_1 {is} 👻 - monster_2 {is} 🤡 - monster_3 {is} 👶 - {print} You enter the haunted house. - {print} Suddenly you see a monster_1 - {print} You run into the other room, but a monster_2 is waiting there for you! - {print} Oh no! Quickly get to the kitchen. - {print} But as you enter monster_3 attacks you! - ``` - example_code_2: | - ``` - monster_1 {is} _ - monster_2 {is} _ - monster_3 {is} _ - {print} You enter the haunted house. - {print} Suddenly you see a monster_1 - {print} You run into the other room, but a monster_2 is waiting there for you! - {print} Oh no! Quickly get to the kitchen. - {print} But as you enter monster_3 attacks you! - ``` - 3: - story_text: | - In the previous levels you've made an introduction to your haunted house game, but as you might have noticed the story would always have a dreadful end. - In this level you can make your story more interactive by changing the outcome of the game; sometimes you'll get eaten, sometimes you'll escape! - Let Hedy decide randomly! - 4: - story_text: | - In this level you learn how to use quotation marks in your games. - Can you make your Haunted House level 4 proof? - example_code: | - ``` - {print} _Escape from the haunted house!_ - {print} _There are 3 doors in front of you..._ - choice {is} {ask} _Which door do you choose?_ - {print} _You picked door ..._ choice - monsters {is} a zombie, a vampire, NOTHING YOUVE ESCAPED - {print} _You see..._ - {sleep} - {print} monsters {at} {random} - ``` - 5: - story_text: | - Up until this level the haunted house game always asked the player to choose a door, but as you might have noticed, they didn't really have to answer correctly. - If the player filled in a completely random answer, the game would still work and the player might even win (despite not picking a door). - In this level you can only win the game by picking the same door Hedy picked randomly. - example_code: | - ``` - {print} 'Escape from the haunted house!' - {print} 'There are 3 doors in front of you...' - doors {is} 1, 2, 3 - monsters {is} werewolf, mummy, vampire, zombie - chosen_door {is} {ask} 'Which door do you choose?' - {print} 'You chose door...' chosen_door - {sleep} - correct_door {is} doors {at} {random} - {if} chosen_door {is} correct_door {print} 'Great! Youve escaped!' - {else} {print} 'Oh no! You are being eaten by a...' monsters {at} {random} - ``` - 9: - story_text: | - In this level you can use nesting, which allows you to make the haunted house even more interactive! - - ### Exercise - Now it's very hard to win this game, can you make it easier to win? - For example by only having 1 wrong door and 2 correct doors instead of 1 correct door and 2 wrong ones? - 11: - story_text: | - In this level we've changed the repeat command and we've added a line to our haunted house that tells the player in which room they are. - example_code: | - ``` - {print} 'Escape from the Haunted House!' - player {is} alive - doors = 1, 2, 3 - monsters = zombie, vampire, giant spider - {for} i {in} {range} 1 {to} 3 - {if} player {is} alive - correct_door = doors {at} {random} - {print} 'Room ' i - {print} 'There are 3 doors in front of you...' - chosendoor = {ask} 'Which door do you choose?' - {if} chosendoor {is} correct_door - {print} 'No monsters here!' - {else} - {print} 'You are eaten by a ' monsters {at} {random} - player = dead - {else} - {print} 'GAME OVER' - {if} player {is} alive - {print} 'Great! You survived!' - ``` - if_command: - description: Introducing the if command - levels: - 9: - story_text: | - In this level you can also put an {if} command inside another {if} command. - in_command: - description: Introducing the in command - levels: - 5: - example_code_2: | - ``` - animals is dog, cow, sheep - answer is ask 'What is your favorite animal?' - _ answer _ animals _ 'Mine too!' - _ _ 'My favorite animals are dogs, cows and sheep' - ``` - is_command: - description: introducing is command - levels: - 2: - story_text_2: | - ### Exercise - Time to make your own variables! - In the example code we made an example of the variable `favorite_animal`. In line 1 the variable is set, and in line 2 we haved used the variable in a print command. - Firstly, finish our example by filling in your favorite animal on the blank. Then make at least 3 of these codes yourself. Pick a variable, and set the variable with the {is} command. Then use it with a {print} command, just like we did. - 14: - example_code: | - ``` - age = {ask} 'How old are you?' - {if} age > 12 - {print} 'You are older than I am!' - ``` - example_code_3: | - ``` - name = {ask} 'What is your name?' - {if} name != 'Hedy' - {print} 'You are not Hedy' - ``` - - {if} age < 13 - {print} 'You are younger than me!' - {else} - {print} 'You are older than me!' - language: - levels: - 5: - story_text: | - Make your own program to practice your vocabulary in a new language. - maths: - levels: - 6: - example_code: | - ``` - {print} '5 plus 5 is ' 5 + 5 - {print} '5 minus 5 is ' 5 - 5 - {print} '5 times 5 is ' 5 * 5 - ``` - 12: - example_code_2: | - ``` - a = 'Hello ' - b = 'world!' - {print} a + b - ``` - - {print} 2.5 + 2.5 - music: - levels: - 6: - story_text: "Instead of playing notes, you can also play numbers now. Simply type `{play} 1` for the lowest note, `{play} 70` for the highest note, or anything in between.\n\n### Exercise\n This calls for musical maths! Try out the example code a couple of times with different starting numbers. \nThen, see if you can compose a song using the numbers.\n" - parrot: - levels: - 1: - story_text_2: | - ### Exercise - Can you make the parrot ask a different question? Fill in the blanks in the example! - example_code_2: |- - ``` - {print} オウムのヘディーです。 - {ask} _ - {echo} - {echo} - ``` - 2: - story_text: | - Create your own online pet parrot that will copy you! - example_code: | - ``` - {print} Im Hedy the parrot - name {is} {ask} whats your name? - {print} name - {sleep} - {print} squawk - {sleep} - {print} name - ``` - story_text_2: | - ### Exercise - You can use variables to make the parrot say more than only your name. Can you complete this code? - 3: - story_text: | - Teach your parrot a new word with `{add}`. - example_code: | - ``` - words {is} squawk, Hedy - {print} Train your parrot! - new_word {is} {ask} Which word do you want to teach them? - {add} new_word {to_list} words - {print} 🧒 Say new_word , Hedy! - {print} 🦜 words {at} {random} - ``` - 4: - story_text: | - In this level we have to use quotation marks with the commands `{ask}` and `{print}`. - Can you complete the code by adding quotation marks? - 5: - story_text: | - Reward your parrot {if} it says the correct word! - example_code: | - ``` - words {is} squawk, Hedy - {print} 'Train your parrot!' - new_word {is} {ask} 'Which word do you want to teach them?' - {add} new_word {to_list} words - said_word {is} words {at} {random} - {print} '🧒 Say ' new_word ', Hedy!' - {print} '🦜 ' said_word - {if} said_word {is} new_word {print} '🧒 Great job, Hedy! 🍪' - {else} {print} '🧒 No, Hedy! Say ' new_word - ``` - piggybank: - levels: - 12: - story_text: | - In this adventure you learn how to make a digital piggy bank, to calculate how much money you have and how long you need to save up to buy what you want! - example_code: | - ``` - {print} 'The digital piggy bank' - wish = {ask} 'What would you like to buy?' - price = {ask} 'How much does that cost?' - saved = {ask} 'How much money have you saved already?' - allowance = {ask} 'How much pocket money do you get per week?' - to_save = price - saved - weeks = to_save / allowance - {print} 'You can buy a ' wish ' in ' weeks ' weeks.' - ``` - 14: - example_code: | - ``` - _ calculate_budget with wish, money, allowance - to_save = wish - money - weeks = to_save / allowance - {if} wish _ money - {print} 'You need to save up some more!' - {print} 'Youll need ' weeks ' more weeks.' - {else} - {print} 'Great! You have enough' - {print} 'Lets go shopping!' - - money = {ask} 'How much money have you saved?' - wish = {ask} 'How much money do you need?' - allowance = {ask} 'How much pocket money do you get each week?' - - {call} calculate_budget with _, _, _ - ``` - pressit: - levels: - 9: - story_text: | - Now that you know how to combine statements, you can create a touch type tool with `{pressed}`. - - ### Exercise - Finish the code. Each time a random letter should be chosen, which you have to press. You get a point for a correct press, and and two points deduction for a wrong press. - **(extra)** Clear the screen after each letter, and show the user how many points they have scored. - print_command: - levels: - 18: - example_code_2: | - ``` - temperature = 25 - {print}('It is ', temperature, ' degrees outside') - ``` - - {print}('My name is ', name) - random_command: - levels: - 16: - story_text: |- - We are going to make lists the Python way, with square brackets around the lists! We also keep the quotation marks around each item like we have learned in previous levels. - We use square brackets to point out a place in a list. For example: `friends[1]` is the first name on the list of friends, as you can see in the first part of the example code. The second part of the example code shows you that we can also match 2 lists using the variable i. - repeat_command: - description: repeat command - levels: - 7: - story_text: | - ## Repeat! Repeat! Repeat! - Level 7 adds the `{repeat}` command. `{repeat}` can be used to execute one line of code multiple times. Like this: - - ### Exercise - Play around with the repeat command. Can you make the happy birthday song in only 3 lines of code instead of 4 now? - 9: - story_text: | - Great job! You've reached another new level! In the previous level you've learned to use multiple lines of code in an {if} or {repeat} command. But you can't yet combine the two... - Good news! In this level you will be allowed to put an {if} inside an {if}, or inside a {repeat} command. Putting a block of code inside another block of code is called nesting. ``` Putting a block of code inside another block of code is called nesting. - example_code: | - ``` - answer = {ask} 'Are you ready to learn something new?' - {if} answer {is} yes - {print} 'Great! You can learn to use the repeat command in the if command!' - {print} 'Hooray!' - {print} 'Hooray!' - {print} 'Hooray!' - {else} - {print} 'Maybe you should practice some more in the previous level' - repeat_command_2: - description: repeat command 2 - levels: - 7: - story_text_2: | - Another interesting thing you can so with the `{repeat}` command is using variables to set the amount of times something should be repeated. In the example code you can see that we first ask the person how old they are. - Then, in line 3, the question is repeated 'age' times. So we have used the variable 'age' with the `{repeat}` command. - restaurant: - levels: - 1: - story_text_2: | - ### Exercise - Can you think of more lines to add to your restaurant code? For example, can you {ask} the guests what they'd like to drink, tell them the price, or wish them a pleasant meal? - example_code_2: | - ``` - {print} Welcome to Hedy's restaurant 🍟 - {ask} What would you like to order? - {echo} So you would like to order - {print} Thanks you for your order! - {print} It's on its way! - ``` - 2: - story_text: | - In level 2 you could expand your restaurant by using variables. In level 1 Hedy could only {echo} the order once and only remember the last thing that was ordered. - Now you can use variables and Hedy can remember both the food and the drinks! - example_code: | - ``` - {print} Welcome to Hedy's restaurant! - {print} Today we're serving pizza or lasagna. - food {is} {ask} What would you like to eat? - {print} Great choice! The food is my favorite! - topping {is} {ask} Would you like meat or veggies on that? - {print} food with topping is on its way! - drinks {is} {ask} What would you like to drink with that? - {print} Thank you for your order. - {print} Your food and drinks will be right there! - ``` - story_text_2: | - ### Exercise - Can you make this code more elaborate? For example by adding drinks to the order? Or...? - 3: - example_code: | - ``` - {print} Welcome to Hedy's Random Restaurant! - {print} The only restaurant that will randomly choose your meal and its price for you! - starters {is} salad, soup, carpaccio - mains {is} pizza, brussels sprouts, spaghetti - desserts {is} brownies, ice cream, french cheeses - drinks {is} cola, beer, water - prices {is} 1 dollar, 10 dollars, 100 dollars - {print} You will start with: starters {at} {random} - {print} Then we'll serve: mains {at} {random} - {print} And as dessert: desserts {at} {random} - {print} You will get a drinks {at} {random} to drink - {print} That will be: prices {at} {random} - {print} Thank you and enjoy your meal! - ``` - story_text_2: | - Does your costumer have any allergies or do they dislike certain dishes? Then you can use the `{remove}`command to remove it from your menu. - example_code_2: | - ``` - {print} Mystery milkshake - flavors {is} strawberry, chocolate, vanilla - allergies {is} {ask} Are you allergic to any falvors? - {remove} allergies {from} flavors - {print} You get a flavors {at} {random} milkshake - ``` - 4: - story_text: | - ### Exercise - Add the quotation marks to this code to make it work! Be careful: variables should not be in quotation marks. - Then, use the `{clear}` command to only show one line at a time in your output screen. - - ### Exercise 2 - Go back to the previous level and copy your restaurant code. Make the code work in this level by adding quotation marks in the right spots and add some `{clear}` commands. - 5: - story_text: | - In this level the {if} command allows you to {ask} your customers questions and give different responses to the answers. - In the example below, you see that you can {ask} the customer {if} they want to hear the specials and Hedy can respond accordingly. - example_code: | - ``` - {print} 'Welcome to Hedys restaurant!' - special {is} {ask} 'Would you like to hear our specials today?' - {if} special {is} yes {print} 'Todays special is chicken piri piri and rice.' {else} {print} 'No problem.' - food {is} {ask} 'What would you like to eat?' - {print} 'One ' food ', coming right up!' - drink {is} {ask} 'What would you like to drink with that?' - {if} drink {is} cola {print} 'Im sorry, we are out of cola!' {else} {print} 'Great choice!' - anything {is} {ask} 'Would you like anything {else}?' - {print} 'Let me repeat your order...' - {print} 'One ' food - {if} drink {is} cola {print} 'and...' {else} {print} 'One ' drink - {if} anything {is} no {print} 'Thats it!' {else} {print} 'One ' anything - {print} 'Thank you for your order and enjoy your meal!' - ``` - 6: - story_text: | - In this level you can use maths to calculate the total price of your customer's order, which can make your virtual restaurant more realistic. - 7: - story_text: | - In this level you've learned how to use the {repeat} command to repeat a line of code a certain amount of times. - You can use that in your restaurant to {ask} multiple people what they'd like to eat. Like this: - example_code: | - ``` - {print} 'Welcome to Hedys restaurant!' - people = {ask} 'How many people are joining us today?' - {repeat} people times food = {ask} 'What would you like to eat?' - {print} 'Thanks for your order! Its coming right up!' - ``` - 9: - story_text: | - In this level you can use nesting to make your restaurant more realistic and more fun! - For example you would {ask} for sauce {if} somebody orders fries, but you wouldn't {if} someone orders pizza! - Check out the example, and try this at your own virtual restaurant! - example_code: | - ``` - {print} 'Welcome to Hedys restaurant!' - people = {ask} 'How many people will be joining us today?' - {print} 'Great!' - price = 0 - {repeat} people {times} - food = {ask} 'What would you like to order?' - {print} food - {if} food {is} fries - price = price + 3 - sauce = {ask} 'What kind of sauce would you like with your fries?' - {if} sauce {is} no - {print} 'no sauce' - {else} - price = price + 1 - {print} 'with ' sauce - {if} food {is} pizza - price = price + 4 - {print} 'That will be ' price ' dollar' - {print} 'Enjoy your meal!' - ``` - 10: - story_text: | - In this level you'll learn how to easily {ask} your guests' orders in a short code. - example_code: | - ``` - courses = appetizer, main course, dessert - {for} course {in} courses - food = {ask} 'What would you like to eat as your ' course '?' - {print} food ' will be your ' course - ``` - example_code_2: | - ``` - courses = appetizer, main course, dessert - names = Timon, Onno - {for} name {in} names - {for} course {in} courses - food = {ask} name ', what would you like to eat as your ' course '?' - {print} name ' orders ' food ' as their ' course - ``` - 11: - story_text: | - We can use the `{for} i {in} {range} 1 {to} 5` to {print} the orders from multiple customers in an orderly manner. - example_code: | - ``` - {print} 'Welcome to Restaurant Hedy!' - people = {ask} 'For how many people would you like to order?' - {for} i {in} {range} 1 {to} people - {print} 'Order number ' i - food = {ask} 'What would you like to eat?' - {print} food - {if} food {is} fries - sauce = {ask} 'What kind of sauce would you like with that?' - {print} sauce - drinks = {ask} 'What would you like to drink?' - {print} drinks - price = 4 * people - {print} 'That will be ' price ' dollars, please!' - ``` - 12: - story_text: | - From this level on you can use decimal numbers to make you menu more realistic. - example_code: | - ``` - price = 0 - food = {ask} 'What would you like to order?' - drink = {ask} 'What would you like to drink?' - {if} food {is} 'hamburger' - price = price + 6.50 - {if} food {is} 'pizza' - price = price + 5.75 - {if} drink {is} 'water' - price = price + 1.20 - {if} drink {is} 'soda' - price = price + 2.35 - {print} 'That will be ' price ' dollar, please' - ``` - 13: - story_text: | - In this level we can use the new commands to upgrade our restaurant. - We use `{and}` to see {if} two things are both the case. - example_code: | - ``` - price = 10 - food = {ask} 'What would you like to eat?' - drinks = {ask} 'What would you like to drink?' - {if} food {is} 'sandwich' {and} drinks {is} 'juice' - {print} 'Thats our discount menu' - price = price - 3 - {print} 'That will be ' price ' dollars' - ``` - rock: - default_save_name: Rock - levels: - 1: - example_code: | - ``` - {print} what do you choose? - {ask} choose from rock, paper or scissors - {echo} so your choice was: - ``` - Instead of using words, you could also use emojis of course: ✊✋✌ - 2: - story_text: | - In this level you can practise using the variables, so that you can make the rock, paper, scissors game in the next level! - example_code: | - ``` - choice {is} _ - {print} I choose choice - ``` - 3: - example_code: | - ``` - choices {is} rock, paper, scissors - {print} choices {at} {random} - ``` - story_text_2: | - ### Exercise - Now you only have one player, so can you add a second player? - You can even use variables to name player 1 and player 2. - example_code_2: | - ``` - choices {is} rock, paper, scissors - {print} player 1 chooses... choices {at} {random} - {print} player 2 _ - ``` - 5: - story_text: | - In this level we can determine who won. - For that you need the new `{if}` code. - - Save your choice with the name of choice and the choice of computer as computer choice. - Then you can use `{if}` to see {if} they are the same or different. - Will you finish the code? - example_code: | - ``` - options {is} rock, paper, scissors - computer_choice {is} _ - choice {is} {ask} 'What do you choose?' - {print} 'you chose ' _ - {print} 'computer chose ' _ - {if} _ {is} _ {print} 'tie!' {else} {print} 'no tie' - ``` - - Fill in the correct code on the blanks to see {if} it is a draw. - 9: - story_text: | - In this level you can program the whole rock, paper, scissors game by nesting the {if}-commands. Can you finish the code? - example_code: | - ``` - choices = rock, paper, scissors - your_choice = {ask} 'What do you choose?' - {print} 'You choose ' your_choice - computer_choice = choices {at} {random} - {print} 'The computer chooses ' computer_choice - {if} computer_choice {is} your_choice - {print} 'Tie' - {if} computer_choice {is} rock - {if} your_choice {is} paper - {print} 'You win!' - {if} your_choice {is} scissors - {print} 'You lose!' - # finish this code - ``` - 10: - story_text: | - Feeling too lazy to play the game yourself? Let Hedy play it for you! - example_code: | - ``` - choices = rock, paper, scissors - players = Marleen, Michael - {for} player {in} players - {print} player ' chooses ' choices {at} {random} - ``` - 13: - story_text: | - With the `{and}` command you can shorten your rock, paper, scissors code! Check out the example code below and try to finish it. - example_code: | - ``` - options = 'rock', 'paper', 'scissors' - your_choice = {ask} 'What do you choose?' - computer_choice = options {at} {random} - {print} 'You choose ' your_choice - {print} 'The computer chooses ' computer_choice - {if} computer_choice {is} your_choice - {print} 'Tie' - {if} computer_choice {is} 'rock' {and} your_choice {is} 'paper' - {print} 'You win!' - {if} computer_choice {is} 'rock' {and} your_choice {is} 'scissors' - {print} 'The computer wins!' - ``` - 15: - example_code: | - ``` - won = 'no' - options = 'rock', 'paper', 'scissors' - {while} won == 'no' - your_choice = {ask} 'What do you choose?' - computer_choice = options {at} {random} - {print} 'you chose ' your_choice - {print} 'the computer chose ' computer_choice - {if} computer_choice == your_choice - {print} 'Tie!' - {if} computer_choice == 'rock' {and} your_choice == 'scissors' - {print} 'You lose!' - {if} computer_choice == 'rock' {and} your_choice == 'paper' - {print} 'You win!' - won = 'yes' - ``` - rock_2: - levels: - 2: - story_text: | - Now that you have learned how to use the `{ask} command, you can make your rock, paper, scissors code interavtive too! - - ### Exercise - Make the rock, paper, scissors code interactive by adding the `{ask}` command and a question to your rock, paper, scissors code. - example_code: | - ``` - choice is _ - {print} I choose choice - ``` - secret: - levels: - 12: - story_text: | - In this adventure you can create your own super spy code. Encode a message that only the right agent can decipher. - If the enemy tries to crack the code, they will get some false info to waste their time. - example_code: | - ``` - name {is} {ask} 'What is your name?' - {if} name {is} '_' - a {is} 'Go to the airport ' - {else} - a {is} 'Go to the trainstation ' - password {is} {ask} 'What is the password?' - {if} password {is} _ - b {is} 'tomorrow at 02.00' - {else} - b {is} 'today at 10.00' - {print} _ _ _ - ``` - 13: - story_text: | - The code you made in the previous level can be made a lot easier in this one with the `{and}` command. - sleep_command: - description: introducing sleep command - levels: - 2: - story_text: | - ## The sleep command - Another new command in this level is `{sleep}`, which pauses your program for a second. If you type a number behind the {sleep} command, the program pauses for that amount of seconds. - songs: - levels: - 6: - story_text: | - Songs often contain a lot of repetition. Sometimes the repetition is also based on counting. - For example, in the well-known song 'Bottles of beer'. You can program that song with a little math. - example_code: | - ``` - verse = 99 - {print} verse ' bottles of beer on the wall' - {print} verse ' bottles of beer' - {print} 'Take one down, pass it around' - verse = verse - 1 - {print} verse ' bottles of beer on the wall' - ``` - - You can now repeat lines 2 to 9 as many times as you want by copying the lines. - example_code_2: | - ``` - number = 6 - number = number - 1 - print number ' little monkeys jumping on the bed' - print 'One fell off and bumped his head' - print 'Mama called the doctor and the doctor said' - print 'NO MORE MONKEYS JUMPING ON THE BED!' - sleep - ``` - 7: - story_text: | - Songs often contain a lot of repetition. For example... Baby Shark! If you sing it, you keep singing the same thing: - - Baby Shark tututudutudu
- Baby Shark tututudutudu
- Baby Shark tututudutudu
- Baby Shark - - You can make this song much shorter with a `{repeat}`! Can you finish the code? - example_code: | - ``` - {repeat} _ _ {print} 'Baby Shark tututudutudu' - {print} 'Baby Shark' - ``` - - After Baby Shark you can of course also program other songs. There are many songs with repetition. - 8: - story_text: | - In a previous level you've programmed the song 'Bottles of beer'. You made one verse and then had to copy the verses 99 times. In level 7 you can repeat the song 99 times, just by adding one simple line! - example_code: | - ``` - verse = 99 - {repeat} 99 {times} - {print} verse ' bottles of beer on the wall' - {print} verse ' bottles of beer' - {print} 'Take one down, pass it around' - verse = verse - 1 - {print} verse ' bottles of beer on the wall' - ``` - 10: - story_text: | - In this level you can easily make the childrens' song 'Five little monkeys'. Can you make the last chorus? - You can also make the whole baby shark song (including all the other sharks in the family) in only 6 lines! - Or you can make Old MacDonald with all the different animals. - example_code: | - ``` - monkeys = 5, 4, 3, 2 - {for} monkey {in} monkeys - {print} monkey ' little monkeys jumping on the bed' - {print} 'One fell off and bumped his head' - {print} 'Mama called the doctor and the doctor said' - {print} 'NO MORE MONKEYS JUMPING ON THE BED!' - ``` - - ``` - sharks = baby, mommy, daddy, grandma, grandpa - {for} shark {in} sharks - {print} shark 'tututututudu' - {print} shark 'tututututudu' - {print} shark 'tututututudu' - {print} shark - ``` - ``` - animals = pig, dog, cow - {for} animal {in} animals - {if} animal {is} pig - sound = oink - {if} animal {is} dog - sound = woof - {if} animal {is} cow - sound = moo - {print} 'Old MacDonald had a farm' - {print} 'E I E I O!' - {print} 'and on that farm he had a ' animal - {print} 'E I E I O!' - {print} 'with a ' sound sound ' here' - {print} 'and a ' sound sound ' there' - {print} 'here a ' sound - {print} 'there a ' sound - {print} 'everywhere a ' sound sound - ``` - story_text_2: | - ### Exercise 2 - Print the song Five little moneys jumping on the bed. Look up the text if you don't remember. - - **(extra)** Print the song Old MacDonald had a farm, and make sure all animals make a different sound, using an `{if}`. - 11: - story_text: | - In this level you can use the `{for} i {in} {range}` command to make songs that use counting. - example_code: | - ``` - {for} i {in} {range} 5 {to} 1 - {print} i ' little monkeys jumping on the bed' - {print} 'One fell off and bumped his head' - {print} 'Mama called the doctor and the doctor said' - {if} i {is} 1 - {print} 'PUT THOSE MONKEYS RIGHT TO BED!' - {else} - {print} 'NO MORE MONKEYS JUMPING ON THE BED!' - ``` - songs_2: - levels: - 12: - example_code: | - ``` - {define} twinkle - {print} 'Twinkle' - {print} '...' - - {call} twinkle - {print} 'Up above the world so high' - {print} 'Like a diamond in the sky' - {call} _ - ``` - turtle: - levels: - 1: - story_text: | - You can also use Hedy to draw. By combining turns and lines, you can make a square or stairs! - - Using `{forward}` you draw a line forwards. The number behind it determines how far the turtle will walk. `{turn} {right}` turns a quarter turn in clockwise direction, `{turn} {left}` turns counter clockwise. - If you want to go backwards, you use the `{forward}` command but with a negative number. So for example `{forward} -100` - 3: - story_text: | - In this level you can use use `{at} {random}` with the drawing turtle. A random choice makes the turtle walk a different path each time. - Use `{at} {random}` to choose a value from a list. You can copy and paste lines 2 and 3 to create a longer random path. - 4: - example_code: | - ``` - {print} 'Drawing figures' - angle {is} 90 - {turn} angle - {forward} 25 - {turn} angle - {forward} 25 - ``` - 5: - example_code_2: | - ``` - direction {is} {ask} 'Do you want to go left, right, or straight ahead?' - if direction is left turn _ - if direction is right turn _ - forward 100 - ``` - 8: - story_text: | - Now that we can repeat several lines, we can make figures more easily. - We only have to set the angle once and then use that variable in the `{repeat}`. - example_code: | - ``` - angle = 90 - {repeat} 10 {times} - {turn} angle - {forward} 50 - ``` - story_text_2: | - Also, we can now improve the program that draws different figures. - Can you figure out how far the turtle has to turn here? Finish the code and you can draw any polygon you'd like! - 9: - story_text: | - Now that we can use a `{repeat}` inside a `{repeat}`, we can create more complex figures. - - ### Exercise 1 - This code creates three black triangles, change that into five pink squares. - - **(extra)** Create a figure of your own choosing consisting of at least two different shapes types. - 10: - story_text: | - In this level you can make the turtle draw a figure. - The turtle will travel the distances in the list, one by one, making bigger and bigger steps. - ### Exercise 1 - Add a 90 degree turn in the loop, so that a spiral is drawn. - Add at least 5 numbers to the list, so the spiral grows larger. - **(extra)** can you change the spiral into another shape? Experiment with numbers for the turn! - ### Exercise 2 - The spiral is drawn outwards, make it go inwards? - turtle_draw_it: - levels: - 9: - example_code: | - Hint for the nested squares: - ``` - colors = red, blue, orange, yellow, pink, purple, green, brown, black - distance = 120 - repeat 5 times - _ - ``` - Hint for the flags: - ``` - country = ask 'which country would you like to see the flag of?' - if country is 'the Netherlands' - color_1 = red - color_2 = white - color_3 = blue - ``` - 10: - example_code: | - Hint Nested Hexagon: - ``` - distances = 100, 80, 60, 40, 20 - {for} distance {in} distances - _ - ``` - - Hint Traffic Lights: - ``` - colors = red, yellow, green - {for} chosen_color {in} colors - color _ - {repeat} _ - ``` - 12: - story_text: | - ### Exercise - Recreate the drawings with the turtle! - Hint: Bracelet designing program. Firstly, define a function **for each shape** you want to use on the bacelet. Then, add the shapes to the bacelet like this: - - Bracelet Designing program - example_code: | - ``` - {define} draw_a_square - _ - - {color} white - {turn} -90 - {forward} 300 - {turn} 180 - - {for} i {in} {range} 1 {to} 5 - {color} gray - {forward} 100 - shape = {ask} 'What kind of shape would you like next on the bracelet?' - chosen_color = {ask} 'In which color?' - {color} chosen_color - {if} shape = 'square' - {call} draw_a_square - ``` - while_command: - description: while - years: - description: Countdown to the new year! - levels: - 11: - story_text: | - In this level you can use the `{for} i {in} {range}` command to countdown to the New Year. - - ### Exercise - Fill in the blanks and make the code work! - example_code: | - ``` - for _ in _ 10 to 1 - {print} i - {print} 'Happy New Year!' - ``` diff --git a/content/adventures/kmr.yaml b/content/adventures/kmr.yaml index 8dd24eb5808..98cbe06dd8a 100644 --- a/content/adventures/kmr.yaml +++ b/content/adventures/kmr.yaml @@ -1,462 +1,4 @@ adventures: - story: - levels: - 2: - 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. - 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!\n\n### Exercise 1\nThe example code shows two different endings; one where the characters jump in a time machine and one where they do not.\nComplete the blanks with at least one sentence per ending. \n**(extra)** Make the story longer. What happens in the story? You can also add a second `{ask}` with different options.\n \n### Exercise 2\nGo back to your saved programs, choose your story program from level 5. Now write a good and a bad ending of at least three lines long each! \n" - 10: - example_code: "```\nanimals = _ , _ , _ \n{print} 'Brown bear, Brown bear'\n {print} 'What do you see?'\n```\n" - 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' - ``` - add_remove_command: - name: '{add} {to} & {remove} {from}' - 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. - 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. - and_or_command: - description: introducing and or - ask_command: - description: Introduction ask command - levels: - 1: - 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. - calculator: - levels: - 6: - 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_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`. - 11: - example_code: | - ``` - number = 10 - {for} i {in} {range} 1 to 10 - {print} i * number - ``` - 12: - story_text: | - Now you can make a calculator that works for decimal numbers. Fill in the blanks to get it to work properly! - example_code: | - ``` - number1 = {ask} 'What is the first number?' - number2 = {ask} 'What is the second number?' - answer = _ - {print} number1 ' plus ' number2 ' is ' answer - ``` - 14: - 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 - clear_command: - description: clear command - debugging: - levels: - 3: - 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} - ``` - 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! - 8: - 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: - 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!' - {else} - 'I'm sorry we don't sell that' - topping {is} {ask} 'What kind of topping would you like?' - sauce {is} {ask} 'What kind of sauce would you like?' - {print} One chosen_bread with topping and sauce. - price = amount * 6 - {print} 'That will be 'price dollar' please' - ``` - - price = amount * 6 - {print} 'That will be 'price dollar' please' - 10: - example_code: | - **Warning! This code needs to be debugged!** - ``` - names = Muad Hasan Samira Noura - activities = fly a kite, go swimming, go hiking, catch tan in the sun - {for} name {is} names - {print} At the beach name loves to activity at random - ``` - 11: - story_text: |- - ### Exercise - Debug this calender program. The output of this program is supposed to look like a list of dates. - For example: - - ``` - Hedy calender - Here are all the days of November - November 1 - November 2 - November 3 - ``` - And so on. - - Mind that you have to test your code extra carefully for the month February, because the amount of days in this month changes in leap years. - example_code: | - **Warning! This code needs to be debugged!** - ``` - print 'Hedy calender' - months_with_31 days = January, March, May, July, September, October, December - months_with_30_days = April, June, August, November - month = ask 'Which month would you like to see?' - if month in months_with_31_days - days = 31 - if month in months_with30_days - days = 30 - if month = February - leap_years = 2020, 2024, 2028, 2036, 2040, 2044, 2028 - year = ask 'What year is it?' - if year in leap_years - days = 29 - else - days = 28 - - print 'Here are all the days of ' moth - for i in range 1 to days - print month i - ``` - 12: - example_code: | - **Warning! This code needs to be debugged!** - ``` - define greet - greetings = 'Hello', 'Hi there', 'Goodevening' - print greetings at random - - define take_order - food = ask 'What would you like to eat?' - print 'One food' - drink = 'What would you like to drink?' - print 'One ' drink - more = ask 'Would you like anything else?' - if more is 'no' - print 'Alright' - else - print 'And ' more - print 'Thank you' - - print 'Welcome to our restaurant' - people = ask 'How many people are in your party tonight?' - for i in range 0 to people - call greet_costumer - ``` - 13: - example_code: | - **Warning! This code needs to be debugged!** - ``` - defin movie_recommendation with name - action_movies == 'Die Hard', 'Fast and Furious', 'Inglorious Bastards' - romance_movies = 'Love Actually', 'The Notebook', 'Titanic' - comedy_movies = 'Mr Bean' 'Barbie''Deadpool' - kids_movies = 'Minions', 'Paddington', 'Encanto' - if name is 'Camila' or name is 'Manuel' - recommended_movie = kids_movie at random - if name is 'Pedro' or 'Gabriella' - mood = ask 'What you in the mood for?' - if mood is 'action' - recommended_movie = comedy_movies at random - if mood is 'romance' - recommended_movie = romance_movies - if mood is 'comedy' - recommended_movie = comedy_movies at random - - print 'I would recommend ' recommended_movie ' for ' name - - name = ask 'Who is watching?' - recommendation = ask 'Would you like a recommendation?' - if recommendaion is 'yes' - print movie_recommendation with name - else - print 'No problem!' - ``` - 14: - example_code: | - **Warning! This code needs to be debugged!** - ``` - define calculate_heartbeat - print 'Press your fingertips gently against the side of your neck' - print '(just under your jawline)' - print 'Count the number of beats you feel for 15 seconds' - beats == ask 'How many beats do you feel in 15 seconds?' - heartbeat = beats*4 - print 'Your heartbeat is ' heartbeat - if heartbeat >= 60 or heartbeat <= 100 - print 'Your heartbeat seems fine' - else - if heartbeat > 60 - print 'Your heartbeat seems to be too low' - if heartbeat < 100 - print 'Your heartbeat seems to be too high' - print 'You might want to contact a medical professional' - - measure_heartbeat = ask 'Would you like to measure your heartbeat?' - if measure_heartbeat = 'yes' - call measure_heartbeat - else - 'no problem' - ``` - - print '(just under your jawline)' - print 'Count the number of beats you feel for 15 seconds' - beats == ask 'How many beats do you feel in 15 seconds?' - heartbeat = beats*4 - print 'Your heartbeat is ' heartbeat - if heartbeat >= 60 or heartbeat <= 100 - print 'Your heartbeat seems fine' - else - if heartbeat > 60 - print 'Your heartbeat seems to be too low' - if heartbeat < 100 - print 'Your heartbeat seems to be too high' - print 'You might want to contact a medical professional' - - measure_heartbeat = ask 'Would you like to measure your heartbeat?' - if measure_heartbeat = 'yes' - call measure_heartbeat - else - 'no problem' - 15: - example_code: | - **Warning! This code needs to be debugged!** - ``` - names = 'Tanya', 'Romy', 'Kayla', 'Aldrin', 'Ali' - verbs='walking', 'skipping', 'cycling', 'driving', 'running' - locations = 'on a mountaintop', 'in the supermarket', 'to the swimming pool' - hiding_spots = 'behind a tree', under a table', in a box' - sounds = 'a trumpet', 'a car crash', 'thunder' - causes_of_noise = 'a television', 'a kid with firecrackers', 'a magic elephant', 'a dream' - - chosen_ name = names at random - chosen_verb = verbs at random - chosen_location = 'locations at random' - chosen_sounds = noises at random - chosen_spot = hiding_spots random - chosen_causes = causes_of_noise at random - - print chosen_name ' was ' chosen_verb ' ' chosen_location - print 'when they suddenly heard a sound like ' sounds at random - print chosen_name ' looked around, but they couldn't discover where the noise came from' - print chosen_name ' hid ' chosen_spot' - print 'They tried to look around, but couldn't see anything from there' - hidden = 'yes' - while hidden = 'yes' - print chosen_name 'still didn't see anything' - answer = ask 'does ' chosen_name ' move from their hiding spot?' - if answer = 'yes' - hidden == 'no' - print 'chosen_name moved from' chosen_spot - print 'And then they saw it was just' chosen_cause - print chosen_name 'laughed and went on with their day' - print The End - ``` - 16: - example_code: | - **Warning! This code needs to be debugged!** - ``` - country = ['The Netherlands', 'Poland', 'Turkey', 'Zimbabwe', 'Thailand', 'Brasil', 'Peru', 'Australia', 'India', 'Romania' ] - capitals = 'Amsterdam', 'Warshaw' 'Istanbul', 'Harare', 'Bangkok', 'Brasilia', 'Lima', 'Canberra', 'New Delhi', 'Bucharest' - score = 0 - for i in range 0 to 10 - answer = ask 'What's the capital of ' countries[i] - correct = capital[i] - if answer = correct - print 'Correct!' - score = score + 1 - else - print 'Wrong,' capitals[i] 'in the capital of' countries[i] - print 'You scored ' score ' out of 10' - - ``` - 17: - example_code: | - **Warning! This code needs to be debugged!** - ``` - define food_order - toppings = ask 'pepperoni, tuna, veggie or cheese?' - size = ask 'big, medium or small?' - number_of_pizza = ask 'How many these pizzas would you like?' - - print 'YOU ORDERED' - print number_of_pizzas ' size ' topping ' pizza' - - define drinks_order - drink = ask 'water, coke, icetea, lemonade or coffee?' - number_of_drinks = ask 'How many of these drinks would you like?' - - print 'YOU ORDERED' - print number_of_drinks ' ' drink - - 'Welcome to Hedy pizza' - more_food = ask 'Would you like to order a pizza?' - while more_food = 'yes' - return food_order - more_food = ask 'Would you like to order a pizza?' - more_drinks = ask 'Would you like to order some drinks?' - while more_drinks == 'yes' - call drink_order - more_drinks == ask 'Would you like to order more drinks?' - - - print 'Thanks for ordering!' - ``` - 18: - example_code: | - **Warning! This code needs to be debugged!** - ``` - animals = ['pig', 'dog', 'cow'] - sounds = ['oink', 'woof', 'moo'] - for i in range 1 to 3 - animal = animals[i] - sound = sounds[i] - print 'Old MacDonald had a farm' - print 'E I E I O!' - print 'and on that farm he had a ' animal - print 'E I E I O!' - print 'with a ' sound sound ' here' - print 'and a ' sound sound ' there' - print 'here a ' sound - print 'there a ' sound - print 'everywhere a ' sound sound - ``` default: name: Pêşkêş description: Ravekirina astê @@ -469,15 +11,7 @@ adventures: Bi bişkoja kesk 'Run code' di binê qada bernamekirinê de kodê biceribînin. Hûn dikarin nivîsê li ser ekranê bi karanîna `{print}` çap bikin Amade ne? Ew cax biçin tabloya din da ku emrê xweya yekem fêr bibin . ! - 3: - story_text: | - In level 3 you can make a list. You can let the computer choose something random from the list. You do that with `{at} {random}`. 4: - story_text: | - In level 4 `{ask}` and `{print}` have changed. - You must put text that you want to print between quotation marks. - This is useful, because now you can print all the words you want. Also the words you used to store something with `{is}`. - Most programming languages also use quotation marks when printing, so we are also getting a step closer to real programming! example_code: | ``` {print} 'Pêwîste ku hûn ji nuha û pê ve nîşanan bikar bînin!' @@ -485,26 +19,12 @@ adventures: {print} 'Divê em navê Sophie bikar bînin' {print} 'Navê min navê min' 5: - story_text: | - In level 5 there is something new, the `{if}`! With the `{if}` you can choose between two different options. - This code prints nice if you enter Hedy as a name, and boo! if you enter something else. - `{ask}` and `{print}` still work like they did in level 4. example_code: | ``` nav {is} {ask} 'Navê te çi ye?' {if} nav {is} Hedy {print} 'xweşik' {else} {print} 'boo!' ``` 6: - story_text: | - In the previous level you have practiced with `{ask}` and `{if}`. For example you can ask guests what they would like to eat. - What you can't yet do though, is calculate the price for everyone's dinner. - - In the previous level you have practiced with `{ask}` and `{if}`. For example you can ask guests what they would like to eat. - What you can't yet do though, is calculate the price for everyone's dinner. - - This level makes it possible to use addition, subtraction and multiplication in your programs. This way you can calculate the prices in your restaurant, but you could also add a secret code to give your friends and family a discount. - Another option in this level is programming your own maths game, for your little brother or sister to practice their multiplications. - Go see for yourself! example_code: | ``` {print} '5 biserve 5 {is} ' 5 + 5 @@ -518,985 +38,3 @@ adventures: {repeat} 3 {times} {print} 'Hedy kêfxweş e! {print} 'rojbûna te pîroz be' {repeat} 3 {times} {print} 'Hedy kêfxweş e!print!' ``` - 8: - story_text: | - `{ask}` and `{print}` still work as you know them. But `{if}`, `{else}`, {pressed} and `{repeat}` have changed! - You can now group several lines together, but you will have to *indent* the code. - That means putting four spaces at the beginning of the line. You will also have to indent when you just want to create a block of one line. - example_code: | - This is how the `{repeat}` command works now: - ``` - {repeat} 5 {times} - {print} 'Hello everyone' - {print} 'This is all repeated 5 times' - ``` - This is how the `{if}` and `{else}` command work now: - - ``` - name = {ask} 'What is your name?' - {if} name {is} Hedy - {print} 'Welcome Hedy' - {print} 'You can play on your computer!' - {else} - {print} 'INTRUDER!' - {print} 'You cannot use this computer!' - ``` - 10: - story_text: |- - In this level we learn a new code called `{for}`. With `{for}` you can make a list and use all elements. - `{for}` creates a block, like `{repeat}` and `{if}` so all lines in the block need to start with spaces. - example_code: | - ``` - animals {is} dog, cat, blobfish - {for} animal {in} animals - {print} 'I love ' animal - ``` - 12: - story_text: |- - **Decimal numbers** - So far, Hedy did not allow for decimal numbers like 1.5, but now we do allow that. Note that computers use the `.` for decimal numbers. - example_code: | - ``` - {print} 'Two and a half plus two and a half is...' - {print} 2.5 + 2.5 - ``` - - {print} 2.5 + 2.5 - 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!' - ``` - 14: - story_text: | - We are going to learn more new items. You might know them already from mathematics, the `<` and `>`. - The `<` checks if the first number is smaller than the second, for example age `<` 12 checks if age is smaller than 12. - If you want to check if the first number is smaller or equal to the second, you can use `<=`, for example age `<=` 11. - The `>` checks if the first number is bigger than the second, for example points `>` 10 checks if points is larger than 10. - If you want to check if the first number is bigger or equal to the second, you can use `>=`, for example points `>=` 11. - You use these comparisons in an `{if}`, like this: - example_code: | - ``` - age = {ask} 'How old are you?' - {if} age > 12 - {print} 'You are older than I am!' - ``` - - {if} age < 13 - {print} 'You are younger than me!' - {else} - {print} 'You are older than me!' - 15: - story_text: |- - We are going to learn a new loop, the `{while}` loop! We continue the loop as long as the statement is true. - So don't forget to change the value in the loop. - - In the example code, we continue until a correct answer has been given. - If the correct answer is never given, the loop never ends! - example_code: | - ``` - answer = 0 - {while} answer != 25 - answer = {ask} 'What is 5 times 5?' - {print} 'A correct answer has been given' - ``` - 16: - story_text: |- - We are going to make lists the Python way, with square brackets around the lists! We also keep the quotation marks around each item like we have learned in previous levels. - You can use the square brackets as well to point out a place in the lists. - example_code: | - ``` - friends = ['Ahmed', 'Ben', 'Cayden'] - {print} friends[1] ' is the first friend on the list.' - {print} friends[2] ' is the second friend on the list.' - {print} friends[3] ' is the third friend on the list.' - #now we will match 2 lists using the variable i - lucky_numbers = [15, 18, 6] - {for} i {in} {range} 1 {to} 3 - {print} friends[i] 's lucky number is ' lucky_numbers[i] - ``` - 17: - story_text: |- - Now we are going to change indentation a little bit. Every time that we need an indentation, we need `:` at the line before the indentation. - - In this level you can also use a new command: `{elif}`. `{elif}` is short for `{else} {if}` and you need it when you want to make 3 (or more!) options. - Check it out! - 18: - story_text: |- - We arrived at real Python code! That means we need to use parentheses with {print} and {range} from now on. - It also means you can use Hedy code from this level in any Python environment as long as you use the English commands. If you haven't until now, you can switch the toggle in the commands menu to do so. - - {print}('My name is ', name) - dice: - levels: - 3: - example_code: | - ``` - choices {is} 1, 2, 3, 4, 5, earthworm - {print} You threw _ {at} {random} - ``` - 5: - story_text: | - You can also make a die again in this level using the `{if}`. - Complete the sample code so that the code says "You can stop throwing" once you have thrown an earthworm. - - But maybe you want to recreate a die from a completely different game. That's fine too! Then make up your own reaction, e.g. 'yes' for 6 and 'pity' for something else. - example_code: | - ``` - choices {is} 1, 2, 3, 4, 5, earthworm - throw {is} _ - {print} 'you have' _ 'thrown' - {if} _ {is} earthworm {print} 'You can stop throwing.' _ {print} 'You have to hear it again!' - ``` - 6: - story_text: | - You can also make an Earthworm die again in this, but now you can also calculate how many points have been rolled. - You may know that the worm counts 5 points for Earthworms. Now after a roll you can immediately calculate how many points you have thrown. - This is the code to calculate points for one die: - - ### Exercise - Can you make the code so that you get the total score for 8 dice? To do that, you have to cut and paste some lines of the code. - example_code: | - ``` - choices = 1, 2, 3, 4, 5, earthworm - points = 0 - throw = choices {at} {random} - {print} 'you threw' throw - {if} throw {is} earthworm points = points + 5 {else} points = points + throw - {print} 'those are' points ' point' - ``` - example_code_2: | - Did you manage to calculate the score for 8 dice? That required a lot of cutting and pasting, right? We are going to make that easier in level 7! - 7: - story_text: | - You can also make a dice again in level 5. With the `{repeat}` code you can easily roll a whole hand of dice. - - ### Exercise - Try to finish the sample code! **(extra)** Think of a game you know that involves a dice and program that using a `{repeat}`. - 10: - story_text: "Is everybody taking too long throwing the dice? In this level you can let Hedy throw all the dice at once!\n\n### Exercise \nChange the names into names of your friends or family, and finish the code.\n" - dishes: - levels: - 5: - story_text: | - With the `{if}` you can now have more fun with choice in the program. You can have your program respond to the choice that the computer has made. - - Can you finish the code so that it prints 'too bad' when it is your turn and otherwise 'yes!'? - Don't forget the quotes! - example_code: "```\npeople {is} mom, dad, Emma, Sophie\ndishwasher {is} people {at} {random}\n{if} dishwasher {is} Sophie {print} _ too bad I have to do the dishes _ \n{else} {print} 'luckily no dishes because' _ 'is already washing up'\n```\n" - 6: - story_text_2: | - If you are extremely unlucky the previous program might choose you to to the dishes for the whole week! That's not fair! - To create a fairer system you can use the `{remove}` command to remove the chosen person from the list. This way you don't have to do the dishes again untill everybody has had a turn. - - Monday and tuesday are ready for you! Can you add the rest of the week? - And... can you come up with a solution for when your list is empty? - example_code_2: | - ``` - people = mom, dad, Emma, Sophie - dishwasher = people {at} {random} - {print} 'Monday the dishes are done by: ' dishwasher - {remove} dishwasher {from} people - dishwasher = people {at} {random} - {print} 'Tuesday the dishes are done by: ' dishwasher - {remove} dishwasher {from} people - dishwasher = people {at} {random} - ``` - 7: - story_text: | - With the `{repeat}` you can repeat pieces of code. You can use this to calculate who will be washing dishes for multiple days! - ### Exercise - Use the `{repeat}` command to decide on who needs to wash the dishes for an entire week. Each blank needs to be filled with one command or number! - **(extra)** Can you think of other tasks in the house? Adapt the code so it decides on three household chores. Do not forget to print what tasks it concerns! - 10: - story_text: | - In this level you can make a schedule for the whole week in an easy way! - - ### Exercise - Add a second chore, such as vacuuming or tidying up, and make sure it is also divided for the whole week. -
**(extra)** The program is not fair, you can be unlucky and wash up all week. How could you make the program more fair? - elif_command: - description: elif - levels: - 17: - example_code: | - ``` - prices = ['1 million dollars', 'an apple pie', 'nothing'] - your_price = prices[{random}] - {print} 'You win ' your_price - {if} your_price == '1 million dollars' : - {print} 'Yeah! You are rich!' - {elif} your_price == 'an apple pie' : - {print} 'Lovely, an apple pie!' - {else}: - {print} 'Better luck next time..' - ``` - for_command: - description: for command - levels: - 11: - story_text: |- - In this level, we add a new form of the `{for}`. In earlier levels, we used `{for}` with a list, but we can also use `{for}` with numbers. - We do that by adding a variable name, followed by `{in}` `{range}`. We then write the number to start at, `{to}` and the number to end at. - Try the example to see what happens! In this level again, you will need to use indentations in lines below the `{for}` statements. - fortune: - levels: - 1: - story_text: | - Have you ever been to a carnival and had your future predicted by a fortune teller? Or have you ever played with a magic eight ball? - Then you probably know that they can't really predict your future, but it's still fun to play! - - In the upcoming levels you can learn how to create your own fortune telling machine! - In level 1 you can start off easy by letting Hedy introduce herself as a fortune teller and let her {echo} the players' answers. - Like this: - story_text_2: | - ### Exercise - Copy the example code into your inputscreen and fill in the blanks to make the code work. - **Extra** Change the code and let the fortune teller not only predict your name, but also your age, your favorite sports team or something else about yourself. - 3: - story_text: | - In the previous levels you've created your first fortune telling machine, but Hedy couldn't really predict anything, only {echo}. - In this level you can use a variable and the `{at} {random}` command to really let Hedy choose an answer for you. Check out this code for instance: - 5: - story_text: | - In this level you'll learn to (secretly) tip the odds in your favor, when using the fortune teller! - By using `{if}` and `{else}` you can make sure that you will always get a good fotune, while other people might not. - Check out this example to find out how. - example_code: | - ``` - {print} 'Im Hedy the fortune teller!' - {print} 'I can predict if youll win the lottery tomorrow!' - person {is} {ask} 'Who are you?' - {if} person {is} Hedy {print} 'You will definitely win!🤩' {else} {print} 'Bad luck! Someone else will win!😭' - ``` - 6: - example_code: | - ``` - {print} 'I am Hedy the fortune teller!' - {print} 'I can predict how many kids youll get when you grow up!' - age = {ask} 'How old are you?' - siblings = {ask} 'How many siblings do you have?' - length = {ask} 'How tall are you in centimetres?' - kids = length / age - kids = kids - siblings - {print} 'You will get ...' - {sleep} - {print} kids ' kids!' - ``` - - If the previous example wasn't silly enough for you, take a look at this one! - ``` - {print} 'Im Hedy the silly fortune teller!' - {print} 'I will predict how smart you are!' - football = {ask} 'On a scale 1-10 how much do you love football?' - bananas = {ask} 'How many bananas did you eat this week?' - hygiene = {ask} 'How many times did you wash your hands today?' - result = bananas + hygiene - result = result * football - {print} 'You are ' result ' percent smart.' - ``` - 7: - story_text: | - In this level you can use the `{repeat}` command to make your machine tell multiple fortunes at once. - example_code: | - ``` - {print} 'Im Hedy the fortune teller!' - {print} 'You can ask 3 questions!' - {repeat} 3 {times} question = {ask} 'What do you want to know?' - answer = yes, no, maybe - {repeat} 3 {times} {print} 'My crystal ball says... ' answer {at} {random} - ``` - 8: - story_text: | - In the previous levels you've learned how to use `{repeat}` to make the fortune teller answer 3 questions in a row, but we had a problem with printing the questions. - Now that problem is solved, because of the new way of using the `{repeat}` command. - In the next example you can have your fortune teller ask 3 questions and also print them! - - ### Exercise - Can you fill in right command on the blanks? - example_code: | - ``` - {print} 'I am Hedy the fortune teller!' - {print} 'You can ask me 3 questions.' - answers = yes, no, maybe - _ _ _ - question = {ask} 'What do you want to know?' - {print} question - {sleep} - {print} 'My crystal ball says...' answers {at} {random} - ``` - 10: - story_text: | - In this level you'll learn how to program the game MASH (mansion, apartment, shack, house). In this game you can predict for all the players at once, what their future will look like. - - ### Exercise 1 - Add two names to the list and see how the output of the program changes when you run it. - example_code: | - ``` - houses = mansion, apartment, shack, house - loves = nobody, a royal, their neighbour, their true love - pets = dog, cat, elephant - names = Jenna, Ryan, Jim - {for} name {in} names - {print} name ' lives in a ' houses {at} {random} - {print} name ' will marry ' loves {at} {random} - {print} name ' will get a ' pets {at} {random} ' as their pet.' - {sleep} - ``` - 12: - story_text: | - In this level you can make your fortunes multiple words. Can you add more different fortunes to the list? - example_code: | - ``` - fortunes = 'you will slip on a banana peel', _ - {print} 'I will take a look in my crystall ball for your future.' - {print} 'I see... I see...' - {sleep} - {print} fortunes {at} {random} - ``` - functions: - levels: - 12: - example_code: | - ``` - sides = 'left', 'right' - limbs = 'hand', 'foot' - colors = 'red', 'blue', 'green', 'yellow' - - {define} turn - chosen_side = sides {at} {random} - chosen_limb = limbs _ - chosen_color = colors _ - {print} chosen_side ' ' chosen_limb ' on ' chosen_color - - {print} 'Lets play a game of Twister!' - {for} i {in} {range} 1 to _ - {call} turn - {sleep} 2 - ``` - 13: - story_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. - - For example in this code we've programmed the first verse of the song 'My Bonnie is over the ocean'. - In this example code the argument `place` is used. Place is a variable that is only used in the function, so an argument. - To use `place` we have programmed the line `define song with place`. - When the function is called, computer will replace the argument `place`, with the piece of text after `call song with`. - - ### Exercise - The next verse of this song goes: - - Last night as I lay on my pillow - Last night as I lay on my bed - Last night as I lay on my pillow - I dreamed that my Bonnie is dead - - Can you program this verse in the same way as the example? - 14: - example_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?' - - new_price = _ calculate_new_price {with} old_price, _ - {print} 'The new price is ' new_price ' dollar' - ``` - haunted: - levels: - 2: - example_code: | - ``` - monster_1 {is} 👻 - monster_2 {is} 🤡 - monster_3 {is} 👶 - {print} You enter the haunted house. - {print} Suddenly you see a monster_1 - {print} You run into the other room, but a monster_2 is waiting there for you! - {print} Oh no! Quickly get to the kitchen. - {print} But as you enter monster_3 attacks you! - ``` - example_code_2: | - ``` - monster_1 {is} _ - monster_2 {is} _ - monster_3 {is} _ - {print} You enter the haunted house. - {print} Suddenly you see a monster_1 - {print} You run into the other room, but a monster_2 is waiting there for you! - {print} Oh no! Quickly get to the kitchen. - {print} But as you enter monster_3 attacks you! - ``` - 3: - story_text: | - In the previous levels you've made an introduction to your haunted house game, but as you might have noticed the story would always have a dreadful end. - In this level you can make your story more interactive by changing the outcome of the game; sometimes you'll get eaten, sometimes you'll escape! - Let Hedy decide randomly! - 11: - story_text: "In this level we've changed the `{for}` command so we can tell the player where they are. \n\n### Exercise 1\nFinish the program so the player knows which room they are in.\n\n### Exercise 2\nMake the program into an adventure by following these steps:\n\n1. Make a list of choices (like: fight or flight)\n2. Make sure the player can choose an option with `{ask}`\n3. Is answer correct? Then they may proceed to the next monster. Do they give a wrong answer? Let the player know with a `{print}`. \n\n **(extra)** If you make a wrong choice, a monster is still shown! How could you change that?\n" - if_command: - description: Introducing the if command - levels: - 9: - story_text: | - In this level you can also put an {if} command inside another {if} command. - in_command: - description: Introducing the in command - levels: - 5: - example_code_2: | - ``` - animals is dog, cow, sheep - answer is ask 'What is your favorite animal?' - _ answer _ animals _ 'Mine too!' - _ _ 'My favorite animals are dogs, cows and sheep' - ``` - is_command: - description: introducing is command - levels: - 2: - story_text_2: | - ### Exercise - Time to make your own variables! - In the example code we made an example of the variable `favorite_animal`. In line 1 the variable is set, and in line 2 we haved used the variable in a print command. - Firstly, finish our example by filling in your favorite animal on the blank. Then make at least 3 of these codes yourself. Pick a variable, and set the variable with the {is} command. Then use it with a {print} command, just like we did. - 14: - example_code: | - ``` - age = {ask} 'How old are you?' - {if} age > 12 - {print} 'You are older than I am!' - ``` - example_code_3: | - ``` - name = {ask} 'What is your name?' - {if} name != 'Hedy' - {print} 'You are not Hedy' - ``` - - {if} age < 13 - {print} 'You are younger than me!' - {else} - {print} 'You are older than me!' - maths: - levels: - 6: - example_code: | - ``` - {print} '5 plus 5 is ' 5 + 5 - {print} '5 minus 5 is ' 5 - 5 - {print} '5 times 5 is ' 5 * 5 - ``` - 12: - example_code_2: | - ``` - a = 'Hello ' - b = 'world!' - {print} a + b - ``` - - {print} 2.5 + 2.5 - music: - levels: - 6: - story_text: "Instead of playing notes, you can also play numbers now. Simply type `{play} 1` for the lowest note, `{play} 70` for the highest note, or anything in between.\n\n### Exercise\n This calls for musical maths! Try out the example code a couple of times with different starting numbers. \nThen, see if you can compose a song using the numbers.\n" - parrot: - levels: - 2: - story_text: | - Create your own online pet parrot that will copy you! - example_code: | - ``` - {print} Im Hedy the parrot - name {is} {ask} whats your name? - {print} name - {sleep} - {print} squawk - {sleep} - {print} name - ``` - story_text_2: | - ### Exercise - You can use variables to make the parrot say more than only your name. Can you complete this code? - 3: - story_text: | - Teach your parrot a new word with `{add}`. - ### Exercise - How can you make your parrot say multiple words? - example_code: | - ``` - words {is} squawk, Hedy - {print} Train your parrot! - new_word {is} {ask} Which word do you want to teach them? - {add} new_word {to_list} words - {print} 🧒 Say new_word, Hedy! - {print} 🦜 words {at} {random} - ``` - 5: - story_text: | - Reward your parrot if it says the correct word! - Finish the code by filling in the 4 missing commands. - piggybank: - levels: - 12: - story_text: | - In this adventure you learn how to make a digital piggy bank. - Finish the code to calculate how much money you have and how long you need to save up to buy what you want! - 14: - example_code: | - ``` - _ calculate_budget with wish, money, allowance - to_save = wish - money - weeks = to_save / allowance - {if} wish _ money - {print} 'You need to save up some more!' - {print} 'Youll need ' weeks ' more weeks.' - {else} - {print} 'Great! You have enough' - {print} 'Lets go shopping!' - - money = {ask} 'How much money have you saved?' - wish = {ask} 'How much money do you need?' - allowance = {ask} 'How much pocket money do you get each week?' - - {call} calculate_budget with _, _, _ - ``` - pressit: - levels: - 9: - story_text: | - Now that you know how to combine statements, you can create a touch type tool with `{pressed}`. - - ### Exercise - Finish the code. Each time a random letter should be chosen, which you have to press. You get a point for a correct press, and and two points deduction for a wrong press. - **(extra)** Clear the screen after each letter, and show the user how many points they have scored. - print_command: - levels: - 18: - example_code_2: | - ``` - temperature = 25 - {print}('It is ', temperature, ' degrees outside') - ``` - - {print}('My name is ', name) - random_command: - levels: - 16: - story_text: |- - We are going to make lists the Python way, with square brackets around the lists! We also keep the quotation marks around each item like we have learned in previous levels. - We use square brackets to point out a place in a list. For example: `friends[1]` is the first name on the list of friends, as you can see in the first part of the example code. The second part of the example code shows you that we can also match 2 lists using the variable i. - repeat_command: - description: repeat command - levels: - 7: - story_text: | - ## Repeat! Repeat! Repeat! - Level 7 adds the `{repeat}` command. `{repeat}` can be used to execute one line of code multiple times. Like this: - - ### Exercise - Play around with the repeat command. Can you make the happy birthday song in only 3 lines of code instead of 4 now? - 9: - story_text: | - Great job! You've reached another new level! In the previous level you've learned to use multiple lines of code in an {if} or {repeat} command. But you can't yet combine the two... - Good news! In this level you will be allowed to put an {if} inside an {if}, or inside a {repeat} command. Putting a block of code inside another block of code is called nesting. ``` Putting a block of code inside another block of code is called nesting. - example_code: | - ``` - answer = {ask} 'Are you ready to learn something new?' - {if} answer {is} yes - {print} 'Great! You can learn to use the repeat command in the if command!' - {print} 'Hooray!' - {print} 'Hooray!' - {print} 'Hooray!' - {else} - {print} 'Maybe you should practice some more in the previous level' - repeat_command_2: - description: repeat command 2 - levels: - 7: - story_text_2: | - Another interesting thing you can so with the `{repeat}` command is using variables to set the amount of times something should be repeated. In the example code you can see that we first ask the person how old they are. - Then, in line 3, the question is repeated 'age' times. So we have used the variable 'age' with the `{repeat}` command. - restaurant: - levels: - 2: - story_text: | - In level 2 you could expand your restaurant by using variables. In level 1 Hedy could only {echo} the order once and only remember the last thing that was ordered. - Now you can use variables and Hedy can remember both the food and the toppings! - 4: - story_text: | - ### Exercise - Add the quotation marks to this code to make it work! Be careful: variables should not be in quotation marks. - - ### Exercise 2 - Go back to the previous level and copy your restaurant code. Make the code work in this level by adding quotation marks in the right spots. - 5: - story_text: | - In this level the `{if}` command allows you to `{ask}` your customers questions and give different responses to the answers. - In the example below, you see that you can `{ask}` the customer `{if}` they want to hear the specials and Hedy can respond accordingly. - example_code: | - ``` - {print} 'Welcome to Restaurant Chez Hedy!' - special {is} {ask} 'Would you like to hear our specials today?' - {if} special {is} yes {print} 'Todays special is chicken piri piri and rice.' {else} {print} 'No problem.' - food {is} {ask} 'What would you like to eat?' - {print} 'One ' food ', coming right up!' - drink {is} {ask} 'What would you like to drink with that?' - {if} drink {is} cola {print} 'Im sorry, we are out of cola!' {else} {print} 'Great choice!' - anything {is} {ask} 'Would you like anything else?' - {print} 'Let me repeat your order...' - {print} 'One ' food - {if} drink {is} cola {print} 'and...' {else} {print} 'One ' drink - {if} anything {is} no {print} 'Thats it!' {else} {print} 'One ' anything - {print} 'Thank you for your order and enjoy your meal!' - ``` - 6: - story_text: | - In this level you can use maths to calculate the total price of your customer's order, which can make your virtual restaurant more realistic. - 7: - story_text: | - In this level you've learned how to use the `{repeat}` command to repeat a line of code a certain amount of times. - You can use that in your restaurant to `{ask}` multiple people what they'd like to eat. - - ### Exercise - Can you complete the code? Hedy needs to repeat this question as many times as there are people. So if there are 5 people, the question needs to be asked 5 times. - **(extra)** Expand your code with more questions, for example about drinks or sauce. - 9: - story_text: "In this level you can use nesting to make your restaurant more realistic and more fun!\n\n### Exercise\nThe indentation was removed in the example code. \nCan you figure out how much indentation each line needs in order for the code to work properly?\nIf the customer orders pizza, Hedy shouldn't ask what sauce the costumer wants.\n\n**(extra)** A restaurant does not stock all sauces. Make a list of available sauces and give a reply with each order whether you sell it.
\n**(extra)** Pizzas have toppings. Ask customers what they want.
\n**(extra)** Do customers want a drink? Ask them too!
\n" - 10: - example_code_2: | - ``` - _ courses = appetizer, main course, dessert - _ names = Timon, Onno - _ {for} name {in} names - _ {for} course {in} courses - _ food = {ask} name ', what would you like to eat as your ' course '?' - _ {print} name ' orders ' food ' as their ' course - ``` - 11: - story_text: | - We can use the `{for}` with `{range}` to print the orders from multiple customers in an orderly manner. - - ### Exercise - Finish the restaurant code, so that you can ask for the order of multiple people. Print the order number each time: 'Order 1', 'Order 2', etc. - Are you not sure how to go about this? Have a peek at your level 8 code. - - **(extra)** In level 9 the restaurant also used prices. You can add that here too! - 12: - story_text: | - From this level on you can use decimal numbers to make you menu more realistic. - - ### Exercise - Can you think of a code to give your friends and family a 15% discount? - 13: - story_text: | - In this level we can use the new commands to upgrade our restaurant. - We use `{and}` to see {if} two things are both the case. - - ### Exercise - Fill in `{and}` and `{or}` on the right blanks. - example_code: | - ``` - price = 10 - food = {ask} 'What would you like to eat?' - drinks = {ask} 'What would you like to drink?' - {if} food {is} 'sandwich' _ drinks {is} 'juice' - {print} 'Thats our discount menu' - price = price - 3 - {if} drinks {is} 'juice' _ drinks {is} 'sap' - {print} 'What a healthy choice!' - {print} 'That will be ' price ' dollars' - ``` - rock: - default_save_name: Rock - levels: - 2: - story_text: | - In this level you can practise using the variables, so that you can make the rock, paper, scissors game in the next level! - example_code: | - ``` - _ {is} {ask} rock, paper, or scissors? - {print} I choose _ - ``` - 3: - example_code: | - ``` - choices {is} rock, paper, scissors - {print} choices {at} {random} - ``` - story_text_2: | - ### Exercise - Copy the example code and fill in the blanks to add an extra player to this game. - - **Extra** Now the players are just called player 1 and player 2. Can you add ask commands (with variables of course) to ask the players' names? - This way you could create this output, for example: `James picks... paper` - example_code_2: | - ``` - choices {is} rock, paper, scissors - {print} player 1 chooses... choices {at} {random} - {print} player 2 _ - ``` - 5: - story_text: | - In this level we can determine who won. - For that you need the new `{if}` code. - - Save your choice with the name of choice and the choice of computer as computer choice. - Then you can use `{if}` to see if they are the same or different. - Will you finish the code? - example_code: | - ``` - options {is} rock, paper, scissors - computer_choice {is} _ - choice {is} {ask} 'What do you choose?' - {print} 'you chose ' _ - {print} 'computer chose ' _ - {if} _ {is} _ {print} 'tie!' {else} {print} 'no tie' - ``` - - Fill in the correct code on the blanks to see {if} it is a draw. - 9: - story_text: "In this level you can program the whole rock, paper, scissors game by nesting the `{if}` commands. \n\n### Exercise\nCan you finish the code? The program must tell who has won for every combination.\n\n**(extra)** Want to play more than one game? Expand the code so that you can play multiple rounds. You can even use an `{ask}` to ask the user how many rounds they want to play.\n" - example_code: | - ``` - choices = rock, paper, scissors - your_choice = {ask} 'What do you choose?' - {print} 'You choose ' your_choice - computer_choice = choices {at} {random} - {print} 'The computer chooses ' computer_choice - {if} computer_choice {is} your_choice - {print} 'Tie' - {if} computer_choice {is} rock - {if} your_choice {is} paper - {print} 'You win!' - {if} your_choice {is} scissors - {print} 'You lose!' - # finish this code - ``` - 10: - story_text: | - Feeling too lazy to play the game yourself? Let Hedy play it for you! - You only have to fill in the names of the players and they get a random choice. - - ### Exercise 1 - Finish the program by filling in a list of names. - - ### Exercise 2 - Add a computer player that chooses with each player. - - **(extra)** Go back to your code and decide who wins in each round: the computer or the named person. - example_code: | - ``` - choices = rock, paper, scissors - players = _ - {for} player {in} players - {print} player ' chooses ' choices {at} {random} - ``` - 13: - story_text: | - With the `{and}` command you can shorten your rock, paper, scissors code! Check out the example code below and try to finish it. - rock_2: - levels: - 2: - story_text: | - Now that you have learned how to use the `{ask} command, you can make your rock, paper, scissors code interavtive too! - - ### Exercise - Make the rock, paper, scissors code interactive by adding the `{ask}` command and a question to your rock, paper, scissors code. - example_code: | - ``` - choice is _ - {print} I choose choice - ``` - secret: - levels: - 12: - story_text: | - In this adventure you can create your own super spy code. Encode a message that only the right agent can decipher. - If the enemy tries to crack the code, they will get some false info to waste their time. - - ### Exercise - Make your own secret code for your superspy. Can you make it consist of even more variables? - example_code: | - ``` - name {is} {ask} 'What is your name?' - {if} name {is} '_' - a {is} 'Go to the airport ' - {else} - a {is} 'Go to the trainstation ' - password {is} {ask} 'What is the password?' - {if} password {is} _ - b {is} 'tomorrow at 02.00' - {else} - b {is} 'today at 10.00' - {print} _ _ _ - ``` - 13: - story_text: | - Can you fill in the right command on the blank? Mind: The superspy has to answer BOTH questions correctly, before they get the confidential information! - sleep_command: - description: introducing sleep command - levels: - 2: - story_text: | - ## The sleep command - Another new command in this level is `{sleep}`, which pauses your program for a second. If you type a number behind the {sleep} command, the program pauses for that amount of seconds. - songs: - levels: - 10: - story_text_2: | - ### Exercise 2 - Print the song Five little moneys jumping on the bed. Look up the text if you don't remember. - - **(extra)** Print the song Old MacDonald had a farm, and make sure all animals make a different sound, using an `{if}`. - songs_2: - levels: - 12: - example_code: | - ``` - {define} twinkle - {print} 'Twinkle' - {print} '...' - - {call} twinkle - {print} 'Up above the world so high' - {print} 'Like a diamond in the sky' - {call} _ - ``` - turtle: - levels: - 2: - story_text: | - In this level you can use variables to make the turtle interactive. For example you can ask the player how many steps the turtle must make. - example_code: | - ``` - answer {is} {ask} How many steps should the turtle make? - {forward} answer - ``` - story_text_2: | - Also, in level 1 the turtle could only turn left or right. That is a bit boring! - In level 2 he can point his nose in all directions. - - Use 90 to turn a quarter. We call this degrees. A full turn is 360 degrees. - - ### Exercise - Can you make a figure with this code? Maybe a triangle or a circle? - example_code_2: | - ``` - {print} Drawing figures - angle {is} 90 - {turn} angle - {forward} 25 - {turn} angle - {forward} 25 - ``` - 5: - example_code_2: | - ``` - direction {is} {ask} 'Do you want to go left, right, or straight ahead?' - if direction is left turn _ - if direction is right turn _ - forward 100 - ``` - 8: - story_text_2: | - **(extra)** We can now improve the program that draws different figures. Finish the code and you can draw any polygon you'd like! - 9: - story_text: | - Now that we can use a `{repeat}` inside a `{repeat}`, we can create more complex figures. - - ### Exercise 1 - This code creates three black triangles, change that into five pink squares. - - **(extra)** Create a figure of your own choosing consisting of at least two different shapes types. - 10: - story_text: | - In this level you can make the turtle draw a figure. - The turtle will travel the distances in the list, one by one, making bigger and bigger steps. - ### Exercise 1 - Add a 90 degree turn in the loop, so that a spiral is drawn. - Add at least 5 numbers to the list, so the spiral grows larger. - **(extra)** can you change the spiral into another shape? Experiment with numbers for the turn! - ### Exercise 2 - The spiral is drawn outwards, make it go inwards? - turtle_draw_it: - levels: - 9: - example_code: | - Hint for the nested squares: - ``` - colors = red, blue, orange, yellow, pink, purple, green, brown, black - distance = 120 - repeat 5 times - _ - ``` - Hint for the flags: - ``` - country = ask 'which country would you like to see the flag of?' - if country is 'the Netherlands' - color_1 = red - color_2 = white - color_3 = blue - ``` - 10: - example_code: | - Hint Nested Hexagon: - ``` - distances = 100, 80, 60, 40, 20 - {for} distance {in} distances - _ - ``` - - Hint Traffic Lights: - ``` - colors = red, yellow, green - {for} chosen_color {in} colors - color _ - {repeat} _ - ``` - 12: - story_text: | - ### Exercise - Recreate the drawings with the turtle! - Hint: Bracelet designing program. Firstly, define a function **for each shape** you want to use on the bacelet. Then, add the shapes to the bacelet like this: - - Bracelet Designing program - example_code: | - ``` - {define} draw_a_square - _ - - {color} white - {turn} -90 - {forward} 300 - {turn} 180 - - {for} i {in} {range} 1 {to} 5 - {color} gray - {forward} 100 - shape = {ask} 'What kind of shape would you like next on the bracelet?' - chosen_color = {ask} 'In which color?' - {color} chosen_color - {if} shape = 'square' - {call} draw_a_square - ``` - while_command: - description: while - years: - levels: - 11: - example_code: | - ``` - {for} number {in} {range} _ {to} _ - {print} number - {print} 'Happy New Year!' - ``` diff --git a/content/adventures/ko.yaml b/content/adventures/ko.yaml index 1542a7fc0b9..6078bf9f5bd 100644 --- a/content/adventures/ko.yaml +++ b/content/adventures/ko.yaml @@ -27,17 +27,7 @@ adventures: 레벨 3 에서 더 재미있게 만들 수 있습니다.괴물, 동물 또는 다른 장애에 대한 랜덤성을 사용할 수 있습니다. story_text_2: | `{add}`라는 명령어는 당신의 스토리에도 도움이 될 것이다. - example_code_2: | - ``` - {print} He hears a sound - animals {is} 🐿, 🦔, 🦇, 🦉 - animal {is} {ask} What do you think it is? - {add} animal {to_list} animals - {print} it was a animals {at} {random} - ``` story_text_3: | - This is an example of the `{remove}` command in your story - ### 연습문제 이전 레벨에서 이 레벨로 스토리를 복사합니다. 이 레벨에서는 `{at} {random}`, `{add} {to_list}` 및 `{remove} {from}` 명령 3개를 새로 배웠습니다. @@ -67,15 +57,6 @@ adventures: 자신의 스토리 모험에서 만든 스토리를 이전 레벨에 복사합니다. 스토리에 최소한 두 개의 `{if}` 명령과 `{else}` 명령을 추가하는 방법을 찾으십시오. 이것은 행복한 결말일 수도 있고 나쁜 결말일 수도 있지만 명령어를 통합하는 다른 방법을 찾을 수도 있습니다. - example_code: | - ``` - name {is} {ask} 'Who is walking in the forest?' - {print} name 'walks through the forest' - {print} name 'encounter 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: | 스토리에서, 어떤 사람은 여러 번 말을 합니다. 예를 들어, 누군가가 도움을 요청하거나 노래를 부를 때 말입니다. @@ -97,21 +78,6 @@ adventures: 저장된 프로그램으로 돌아가서 5단계에서 스토리 프로그램을 선택하세요. 이제 각각 최소 세 줄의 좋은 결말과 나쁜 결말을 쓰세요! 9: story_text: "이 레벨에서는 다른 `{if}` 및 `{repeat}` 명령어 내에서 {if} 및 {repeat} 명령어를 사용할 수 있습니다. \n이것은 여러분에게 많은 선택권을 주고 여러분의 이야기를 상호작용적으로 만드는 데 정말로 도움을 줍니다.\n\n ### 연습문제 1\n코드를 완료하여 `{if}`가 올바르게 작동하도록 하십시오.\n\n### 연습문제 2\n로빈이 집에 가는 스토리의 부분도 `{if}`와 `{else}`를 붙인다.\n\n### 연습문제 3\n레벨 8 스토리로 돌아가서 다른 `{if}` 안에 최소한 두 개의 `{if}`을 사용합니다.\n" - 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: | 이 레벨에서 스토리에서 {for} 명령을 사용할 수 있다. 이렇게 하면 어린이 책 '갈색 곰, 갈색곰, 무엇이 보이니'를 쉽게 프로그래밍할 수 있다. @@ -217,148 +183,11 @@ adventures: name: 블랙잭 default_save_name: 블랙잭 description: 숫자 21에 근접하도록 노력해보세요 - levels: - 17: - story_text: | - 블랙잭은 당신이 가능한 한 21점에 근접해야 하는 단순한 카드 게임입니다. 당신은 두 장의 카드를 받습니다. 각각의 카드는 숫자만큼 가치가 있고, 페이스 카드(잭, 퀸, 킹)는 10점의 가치가 있습니다. - 에이스는 1점 또는 11점의 가치가 있습니다. (선택하실 수 있습니다.) 딜러, 상대방도 2장의 카드를 받습니다. - 당신이 원한다면 다른 카드를 얻을 수 있고, 그 카드의 포인트는 당신의 총합에 추가됩니다. 딜러는 다른 카드를 가져가기를 선택할 수도 있습니다. - 하지만 21점 이상 받지 않도록 조심하세요, 그러면 지는 거니까요! - 넘어가지 않고 21에 가장 근접한 선수가 승리! - - ### 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! calculator: levels: 6: story_text: | 이제 수학을 할 수 있게 되었으니, 계산기를 직접 만들 수 있을 거야! - 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: | - ### 연습문제 - 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! - story_text_3: | - **Extra** You can also let the computer do random sums 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 level 6 you created a calculator, in this level you can expand that code so it asks multiple questions. - - ### 연습문제 1 - Can you finish line 10 to make to program work? - - ### 연습문제 2 - Give the player feedback when the enter a right or wrong answer. To achieve that, expand your program with an `{else}`. - example_code: | - ``` - score = 0 - {repeat} 10 {times} - numbers = 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 - number1 = numbers {at} {random} - number2 = numbers {at} {random} - correct_answer = number1 * number2 - {print} 'What is ' number1 ' times ' number2 '?' - 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!' - ``` - 11: - story_text: | - With a `{for}` you can simplify tables of multiplication practise program. - - ### 연습문제 1 - Improve the example code such that it prints a nice multiplication table:
"1 times 10 is 10", "2 times 10 is 20", etc. - - ### 연습문제 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. - - ### 연습문제 1 - Fill out the blanks to complete the calculator. Remember to use a period and not a comma for decimal numbers. - - ### 연습문제 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 = number1 + number2 - {print} number1 ' plus ' number2 ' is ' answer - ``` - 13: - story_text: | - ### 연습문제 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. - - ### 연습문제 2 Extra - 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. - 14: - 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: | - 이전 레벨에서 배운 계산기 게임에 `{while}` 루프를 추가하면 된다. - 이렇게 하면 플레이어가 틀린 답변을 할 경우 다음 질문을 계속할 수 없습니다. - - ### 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. clear_command: description: clear 명령어 levels: @@ -379,322 +208,6 @@ adventures: {clear} {print} '서프라이즈!' ``` - debugging: - levels: - 3: - 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} - ``` - 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! - 8: - 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: - 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!' - {else} - 'I'm sorry we don't sell that' - topping {is} {ask} 'What kind of topping would you like?' - sauce {is} {ask} 'What kind of sauce would you like?' - {print} One chosen_bread with topping and sauce. - price = amount * 6 - {print} 'That will be 'price dollar' please' - ``` - - price = amount * 6 - {print} 'That will be 'price dollar' please' - 10: - example_code: | - **Warning! This code needs to be debugged!** - ``` - names = Muad Hasan Samira Noura - activities = fly a kite, go swimming, go hiking, catch tan in the sun - {for} name {is} names - {print} At the beach name loves to activity at random - ``` - 11: - story_text: |- - ### Exercise - Debug this calender program. The output of this program is supposed to look like a list of dates. - For example: - - ``` - Hedy calender - Here are all the days of November - November 1 - November 2 - November 3 - ``` - And so on. - - Mind that you have to test your code extra carefully for the month February, because the amount of days in this month changes in leap years. - example_code: | - **Warning! This code needs to be debugged!** - ``` - print 'Hedy calender' - months_with_31 days = January, March, May, July, September, October, December - months_with_30_days = April, June, August, November - month = ask 'Which month would you like to see?' - if month in months_with_31_days - days = 31 - if month in months_with30_days - days = 30 - if month = February - leap_years = 2020, 2024, 2028, 2036, 2040, 2044, 2028 - year = ask 'What year is it?' - if year in leap_years - days = 29 - else - days = 28 - - print 'Here are all the days of ' moth - for i in range 1 to days - print month i - ``` - 12: - example_code: | - **Warning! This code needs to be debugged!** - ``` - define greet - greetings = 'Hello', 'Hi there', 'Goodevening' - print greetings at random - - define take_order - food = ask 'What would you like to eat?' - print 'One food' - drink = 'What would you like to drink?' - print 'One ' drink - more = ask 'Would you like anything else?' - if more is 'no' - print 'Alright' - else - print 'And ' more - print 'Thank you' - - print 'Welcome to our restaurant' - people = ask 'How many people are in your party tonight?' - for i in range 0 to people - call greet_costumer - ``` - 13: - example_code: | - **Warning! This code needs to be debugged!** - ``` - defin movie_recommendation with name - action_movies == 'Die Hard', 'Fast and Furious', 'Inglorious Bastards' - romance_movies = 'Love Actually', 'The Notebook', 'Titanic' - comedy_movies = 'Mr Bean' 'Barbie''Deadpool' - kids_movies = 'Minions', 'Paddington', 'Encanto' - if name is 'Camila' or name is 'Manuel' - recommended_movie = kids_movie at random - if name is 'Pedro' or 'Gabriella' - mood = ask 'What you in the mood for?' - if mood is 'action' - recommended_movie = comedy_movies at random - if mood is 'romance' - recommended_movie = romance_movies - if mood is 'comedy' - recommended_movie = comedy_movies at random - - print 'I would recommend ' recommended_movie ' for ' name - - name = ask 'Who is watching?' - recommendation = ask 'Would you like a recommendation?' - if recommendaion is 'yes' - print movie_recommendation with name - else - print 'No problem!' - ``` - 14: - example_code: | - **Warning! This code needs to be debugged!** - ``` - define calculate_heartbeat - print 'Press your fingertips gently against the side of your neck' - print '(just under your jawline)' - print 'Count the number of beats you feel for 15 seconds' - beats == ask 'How many beats do you feel in 15 seconds?' - heartbeat = beats*4 - print 'Your heartbeat is ' heartbeat - if heartbeat >= 60 or heartbeat <= 100 - print 'Your heartbeat seems fine' - else - if heartbeat > 60 - print 'Your heartbeat seems to be too low' - if heartbeat < 100 - print 'Your heartbeat seems to be too high' - print 'You might want to contact a medical professional' - - measure_heartbeat = ask 'Would you like to measure your heartbeat?' - if measure_heartbeat = 'yes' - call measure_heartbeat - else - 'no problem' - ``` - - print '(just under your jawline)' - print 'Count the number of beats you feel for 15 seconds' - beats == ask 'How many beats do you feel in 15 seconds?' - heartbeat = beats*4 - print 'Your heartbeat is ' heartbeat - if heartbeat >= 60 or heartbeat <= 100 - print 'Your heartbeat seems fine' - else - if heartbeat > 60 - print 'Your heartbeat seems to be too low' - if heartbeat < 100 - print 'Your heartbeat seems to be too high' - print 'You might want to contact a medical professional' - - measure_heartbeat = ask 'Would you like to measure your heartbeat?' - if measure_heartbeat = 'yes' - call measure_heartbeat - else - 'no problem' - 15: - example_code: | - **Warning! This code needs to be debugged!** - ``` - names = 'Tanya', 'Romy', 'Kayla', 'Aldrin', 'Ali' - verbs='walking', 'skipping', 'cycling', 'driving', 'running' - locations = 'on a mountaintop', 'in the supermarket', 'to the swimming pool' - hiding_spots = 'behind a tree', under a table', in a box' - sounds = 'a trumpet', 'a car crash', 'thunder' - causes_of_noise = 'a television', 'a kid with firecrackers', 'a magic elephant', 'a dream' - - chosen_ name = names at random - chosen_verb = verbs at random - chosen_location = 'locations at random' - chosen_sounds = noises at random - chosen_spot = hiding_spots random - chosen_causes = causes_of_noise at random - - print chosen_name ' was ' chosen_verb ' ' chosen_location - print 'when they suddenly heard a sound like ' sounds at random - print chosen_name ' looked around, but they couldn't discover where the noise came from' - print chosen_name ' hid ' chosen_spot' - print 'They tried to look around, but couldn't see anything from there' - hidden = 'yes' - while hidden = 'yes' - print chosen_name 'still didn't see anything' - answer = ask 'does ' chosen_name ' move from their hiding spot?' - if answer = 'yes' - hidden == 'no' - print 'chosen_name moved from' chosen_spot - print 'And then they saw it was just' chosen_cause - print chosen_name 'laughed and went on with their day' - print The End - ``` - 16: - example_code: | - **Warning! This code needs to be debugged!** - ``` - country = ['The Netherlands', 'Poland', 'Turkey', 'Zimbabwe', 'Thailand', 'Brasil', 'Peru', 'Australia', 'India', 'Romania' ] - capitals = 'Amsterdam', 'Warshaw' 'Istanbul', 'Harare', 'Bangkok', 'Brasilia', 'Lima', 'Canberra', 'New Delhi', 'Bucharest' - score = 0 - for i in range 0 to 10 - answer = ask 'What's the capital of ' countries[i] - correct = capital[i] - if answer = correct - print 'Correct!' - score = score + 1 - else - print 'Wrong,' capitals[i] 'in the capital of' countries[i] - print 'You scored ' score ' out of 10' - - ``` - 17: - example_code: | - **Warning! This code needs to be debugged!** - ``` - define food_order - toppings = ask 'pepperoni, tuna, veggie or cheese?' - size = ask 'big, medium or small?' - number_of_pizza = ask 'How many these pizzas would you like?' - - print 'YOU ORDERED' - print number_of_pizzas ' size ' topping ' pizza' - - define drinks_order - drink = ask 'water, coke, icetea, lemonade or coffee?' - number_of_drinks = ask 'How many of these drinks would you like?' - - print 'YOU ORDERED' - print number_of_drinks ' ' drink - - 'Welcome to Hedy pizza' - more_food = ask 'Would you like to order a pizza?' - while more_food = 'yes' - return food_order - more_food = ask 'Would you like to order a pizza?' - more_drinks = ask 'Would you like to order some drinks?' - while more_drinks == 'yes' - call drink_order - more_drinks == ask 'Would you like to order more drinks?' - - - print 'Thanks for ordering!' - ``` - 18: - example_code: | - **Warning! This code needs to be debugged!** - ``` - animals = ['pig', 'dog', 'cow'] - sounds = ['oink', 'woof', 'moo'] - for i in range 1 to 3 - animal = animals[i] - sound = sounds[i] - print 'Old MacDonald had a farm' - print 'E I E I O!' - print 'and on that farm he had a ' animal - print 'E I E I O!' - print 'with a ' sound sound ' here' - print 'and a ' sound sound ' there' - print 'here a ' sound - print 'there a ' sound - print 'everywhere a ' sound sound - ``` default: name: 소개 default_save_name: 인트로 @@ -746,21 +259,6 @@ adventures: 다음 단계는 프로그램에서 덧셈, 뺄셈, 곱셈을 사용하는 것을 가능하게 한다. 이런 식으로 당신은 당신의 식당의 가격을 계산할 수 있지만, 친구들과 가족들에게 할인을 주기 위해 비밀 암호를 추가할 수도 있다. 다음 단계의 또 다른 옵션은 당신의 남동생이나 여동생이 그들의 곱셈을 연습할 수 있도록 당신 자신의 수학 게임을 프로그래밍하는 것이다. 직접 가보세요! - example_code: | - ``` - food_price {is} 0 - drink_price {is} 0 - total_price {is} 0 - {print} 'Welcome to McHedy' - order {is} {ask} 'What would you like to eat?' - {if} order {is} hamburger food_price {is} 5 - {if} order {is} fries food_price {is} 2 - drink {is} {ask} 'What would you like to drink?' - {if} drink {is} water drink_price {is} 0 - else drink_price {is} 3 - total_price {is} food_price + drink_price - {print} 'That will be ' total_price ' dollars, please' - ``` 7: story_text: | 잘했어요! 다음 레벨에 도달했으니 `{if}`와 `{else}`로 연습한 셈이죠. 코드가 점점 길어지는 것을 알아차렸을 거예요. @@ -775,16 +273,6 @@ adventures: story_text: | 잘했어요! 다른 새 레벨에 도달했어요! 이전 레벨에서는 {if} 또는 {repeat} 명령어에서 여러 줄의 코드를 사용하는 법을 배웠지만 아직 둘을 결합할 수는 없어요... 좋은 소식입니다! 이 레벨에서는 {if} 명령 또는 {repeat} 명령에 {if}을(를) 넣을 수 있습니다. - example_code: | - ``` - answer = {ask} 'Are you ready to learn something new?' - {if} answer {is} yes - {print} 'Great! You can learn to use the repeat commando in the if command!' - {print} 'Hooray!' - {print} 'Hooray!' - {print} 'Hooray!' - {else} - {print} 'Maybe you should practice some more in the previous level' 10: story_text: | 잘하고 있어요! 이전 레벨에서 우리는 여전히 작은 문제에 직면했어요. 당신은 선을 반복하는 법을 배웠지만, 선을 살짝 바꾸고 싶다면 어떻게 해야 하죠. @@ -824,21 +312,6 @@ adventures: 이 레벨에서 우리는 실제 파이썬 코드를 향해 조금 더 성장할 것이다. 두 개의 목록을 함께 맞추는 방법도 배울 것이다. 이렇게 하면 올바른 동물이 올바른 소리에 맞게 코드를 프로그래밍할 수 있습니다. 왜냐하면 아래의 두 코드는... 말도 안 되는 소리야! - example_code: | - ``` - animals = 'chicken', 'horse', 'cow' - sounds = 'cluck', 'neigh', 'moo' - {for} animal {in} animals - {print} 'A ' animal ' says ' sounds {at} {random} - ``` - You could also try to make it work this way, but.... - ``` - animals = 'chicken', 'horse', 'cow' - sounds = 'cluck', 'neigh', 'moo' - {for} animal {in} animals - {for} sound {in} sounds - {print} 'A ' animal ' says ' sound - ``` 17: story_text: | Hedy의 마지막 레벨에 거의 다 도달했습니다. 잘했어요! 이 레벨에서는 `{print}`을(를) 사용하는 실제 파이썬 방법을 배울 수 있습니다. @@ -846,108 +319,12 @@ adventures: story_text: | 축하합니다! Hedy의 마지막 레벨에 도달했습니다! 여기서 만든 코드를 레플릿이나 파이참과 같은 실제 파이썬 환경에 복사할 수 있고, 거기서 계속 배울 수 있습니다! 참고로 파이썬은 영어 명령어만 읽을 수 있기 때문에 다른 언어를 사용해 왔다면 지금은 영어로 전환해야 한다. - dice: - levels: - 3: - example_code: | - ``` - choices {is} 1, 2, 3, 4, 5, earthworm - {print} choices {at} {random} - ``` - story_text_2: | - ### 연습문제 - The dice in the example above are dice for a specific game. Can you make normal dice? - Or other special dice from a different game? - 4: - story_text: | - In this level you can also create dice. But this time you can try it yourself, without an example code! - - ### 연습문제 - Make your own dice in this level. - Tip: If you have no idea how to make dice. Take a peek at your dice from the previous level, but don't forget to add quotation marks. - 5: - story_text: | - We are going to add the `{if}` and `{else}` commands to our dice! - - ### 연습문제 - Complete the sample code so that the code says "You can stop throwing" once you have thrown an earthworm. It should say "You have to throw again" if you've thrown anything else. - **Extra** Maybe you want to recreate a die from a completely different game. That's fine too! Then make up your own reaction, e.g. 'yes' for 6 and 'pity' for something else. - 6: - story_text: | - You can also make an Earthworm die again in this, but now you can also calculate how many points have been rolled. - You may know that the worm counts 5 points for Earthworms. Now after a roll you can immediately calculate how many points you have thrown. - This is the code to calculate points for one die: - - ### 연습문제 - Can you make the code so that you get the total score for 8 dice? To do that, you have to cut and paste some lines of the code. - example_code_2: | - Did you manage to calculate the score for 8 dice? That required a lot of cutting and pasting, right? We are going to make that easier in level 7! - 7: - story_text: | - You can also make a dice again in this level. With the `{repeat}` code you can easily roll a whole hand of dice. - - ### 연습문제 - Try to finish the sample code! **Extra** Think of a game you know that involves a dice and program that using a `{repeat}`. - 10: - story_text: | - ### 연습문제 - Is everybody taking too long throwing the dice? In this level you can let Hedy throw all the dice at once! - Change the names into names of your friends or family, and finish the code. dishes: description: Use the computer to see who does the dishes (Start at level 2) levels: - 3: - example_code: | - ``` - people {is} mom, dad, Emma, Sophie - {print} people {at} {random} - ``` - story_text_2: | - ### 연습문제 - Make your own version of the dishwasher program. Firstly make a list of your family members. - Then think of a task that needs to be done, and let the computer decide who has to do the task with the `{at} {random}` command. - - **Extra** Don't feel like doing the dishes yourself? Hack the program by removing your name from the list with the `{remove}` `{from}` command. - 4: - story_text: | - With quotation marks you can make your dishwashing program even better. - - ### 연습문제 - First, fill in right symbols or commands on the blanks to make this example program work. - Did you get it? Great! Now copy your own code from the previous level and make it work in this level by adding quotation marks in the right spots. - 5: - story_text: | - With the `{if}` you can now have more fun with choice in the program. You can have your program respond to the choice that the computer has made. - ### 연습문제 - Can you finish the code so that it prints 'too bad' when it is your turn and otherwise 'yes!'? - Don't forget the quotes! 6: story_text: | 얼마나 자주 설거지를 할까요? 공평한가요? 이 정도면 계산할 수 있어요. - story_text_2: | - If you are extremely unlucky the previous program might choose you to to the dishes for the whole week! That's not fair! - To create a fairer system you can use the `{remove}` command to remove the chosen person from the list. This way you don't have to do the dishes again untill everybody has had a turn. - - Monday and tuesday are ready for you! Can you add the rest of the week? - And... can you come up with a solution for when your list is empty? - 7: - story_text: | - With the `{repeat}` you can repeat pieces of code. You can use this to calculate who will be washing dishes for multiple days! - ### 연습문제 - Use the `{repeat}` command to decide on who needs to wash the dishes for an entire week. Each blank needs to be filled with one command or number! - **Extra** Can you think of other tasks in the house? Adapt the code so it decides on three household chores. Do not forget to print what tasks it concerns! - example_code: | - ``` - people = mom, dad, Emma, Sophie - {repeat} _ _ {print} 'the dishwasher is' _ - ``` - 10: - story_text: | - In this level you can make a schedule for the whole week in an easy way! - - ### 연습문제 - Add a second chore, such as vacuuming or tidying up, and make sure it is also divided for the whole week. -
**Extra** The program is not fair, you can be unlucky and wash up all week. How could you make the program more fair? elif_command: description: elif levels: @@ -975,11 +352,6 @@ adventures: ## For 이 레벨에서 우리는 `{for}`라는 새로운 코드를 배운다. `{for}`를 사용하면 목록을 만들고 모든 요소를 사용할 수 있다. `{for}`는 `{repeat}`와 `{if}`와 같은 블록을 생성하므로 블록의 모든 행은 4개의 공백으로 시작해야 한다. - 11: - story_text: |- - In this level, we add a new form of the `{for}`. In earlier levels, we used `{for}` with a list, but we can also use `{for}` with numbers. - We do that by adding a variable name, followed by `{in}` `{range}`. We then write the number to start at, `{to}` and the number to end at. - Try the example to see what happens! In this level again, you will need to use indentations in lines below the `{for}` statements. 17: story_text: | 이제 들여쓰기를 조금 바꿀 것이다. 들여쓰기가 필요할 때마다 우리는 들여쓰기 앞 줄에 `:`가 필요하다. @@ -999,213 +371,43 @@ adventures: ### 연습문제 예제 코드를 입력 화면에 복사하고 빈칸을 입력하면 코드가 작동합니다. **추가** 코드를 바꿔서 점쟁이가 당신의 이름뿐만 아니라 당신의 나이, 당신이 좋아하는 스포츠 팀, 또는 당신 자신에 관한 다른 것들도 예측할 수 있도록 하세요. - 3: - story_text_2: | - ### 연습문제 - Now, Hedy can only answer yes, no or maybe. Can you give Hedy more answer options, like 'definitely' or 'ask again'. - 5: - story_text: | - ### 연습문제 - In the example code you see how to make a fortune teller program that allows you to tip the odds in your favor. This cheating program always tells you that you will win the lottery, but your friends will never win. - Use this to make your own program, be creative! For example you could create a code that predicts that: - * your favorite sports team will beat all the competitors! - * your favorite movie will be chosen for movie night! - * you win tickets to your favorite show! - * you are the fairest of them all, like Snow White's magic mirror. - Let your imagination do the work! - - Your program has to exist of at least 10 lines of code and need to have at least one `{if}` and `{else}` command. - 6: + haunted: + name: 유령의 집 + default_save_name: 유령의 집 + levels: + 1: story_text: | - In this level you can use math in your predictions as a fortune teller. This allows you to make up (silly) formulas to calculate the future. - For example you could calculate how rich you'll get or how many kids you will have when you grow up. - - + 이 모험에서 여러분은 올바른 문을 선택하여 유령의 집에서 탈출해야 하는 게임을 만들기 위해 노력하고 있습니다. + 오른쪽 문을 선택하면 살아남겠지만, 끔찍한 괴물이 아니라면... - ### 연습문제 - Can you think of your own (silly) fortune telling machine? - 7: + 레벨 1에서는 무서운 이야기를 지어내는 것으로 유령의 집 게임을 시작하고 플레이어에게 유령의 집에서 어떤 괴물을 보게 될지 물어봅니다. + 2: story_text: | - ### 연습문제 - Finish this program that tells you if your crush loves you back or not. - 8: + 이 유령이 나오는 집에서는 이모지로 몬스터를 고를 수 있습니다. 물론 단어도 사용할 수 있습니다. + if_command: + description: Introducing the if command + levels: + 5: story_text: | - In the next example you can have your fortune teller ask multiple questions and also print them! - - ### 연습문제 - Can you fill in right command on the blanks? - example_code: | - ``` - {print} 'I am Hedy the fortune teller!' - {print} 'You can ask me 3 questions.' - answers = yes, no, maybe - _ _ _ - question = {ask} 'What do you want to know?' - {print} question - {sleep} - {print} 'My crystal ball says...' answers {at} {random} - ``` - 10: + ## If... else.... + 레벨 5에는 새로운 것인 {if}가 있다! `{if}`을(를) 사용하면 두 개의 다른 옵션 중에서 선택할 수 있다. + 이 코드는 이름으로 Hedy를 입력하면 인쇄가 잘 되고, 다른 이름으로 입력하면 야유. + `{ask}`와 `{print}`는 여전히 레벨 4와 같이 작동한다. + story_text_2: | + `{if}`인 코드가 정말 길어져서 행에 잘 맞지 않을 때도 있다.
코드를 두 줄에 걸쳐 나눌 수도 있는데, 두 번째 줄은 다음과 같이 `{else}`에서 시작한다: + story_text_3: | + ### 연습 문제 + `{if}`와 `{else}`로 자신만의 코드를 만들어 보자. 원한다면 예제 코드를 사용할 수 있다. + 8: story_text: | - In this level you'll learn how to program the game MASH (mansion, apartment, shack, house). In this game you can predict for all the players at once, what their future will look like. - - ### 연습문제 - Fil in the blanks by using the new command that you've learned this level. - 12: - story_text: |- - From level 12 on, you will also have to use quotation marks in lists, before and after each item. - - ### 연습문제 - Add two predictions to the list - example_code: | - ``` - fortunes = 'you will be rich', 'you will fall in love', 'you will slip on a banana peel' - {print} 'I will take a look in my crystall ball for your future.' - {print} 'I see... I see...' - {sleep} - {print} fortunes {at} {random} - ``` - functions: - levels: - 12: - example_code: | - ``` - sides = 'left', 'right' - limbs = 'hand', 'foot' - colors = 'red', 'blue', 'green', 'yellow' - - {define} turn - chosen_side = sides {at} {random} - chosen_limb = limbs _ - chosen_color = colors _ - {print} chosen_side ' ' chosen_limb ' on ' chosen_color - - {print} 'Lets play a game of Twister!' - {for} i {in} {range} 1 to _ - {call} turn - {sleep} 2 - ``` - 13: - story_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. - - For example in this code we've programmed the first verse of the song 'My Bonnie is over the ocean'. - In this example code the argument `place` is used. Place is a variable that is only used in the function, so an argument. - To use `place` we have programmed the line `define song with place`. - When the function is called, computer will replace the argument `place`, with the piece of text after `call song with`. - - ### Exercise - The next verse of this song goes: - - Last night as I lay on my pillow - Last night as I lay on my bed - Last night as I lay on my pillow - I dreamed that my Bonnie is dead - - Can you program this verse in the same way as the example? - 14: - example_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?' - - new_price = _ calculate_new_price {with} old_price, _ - {print} 'The new price is ' new_price ' dollar' - ``` - harry_potter: - levels: - 10: - story_text: | - ### 연습문제 - We can also make a Harry Potter themed fortune teller. Fill in blanks such that 9 lines are printed. - **Extra** Change the theme of the fortune teller into something else, such as your favorite book, film or tv show. - haunted: - name: 유령의 집 - default_save_name: 유령의 집 - levels: - 1: - story_text: | - 이 모험에서 여러분은 올바른 문을 선택하여 유령의 집에서 탈출해야 하는 게임을 만들기 위해 노력하고 있습니다. - 오른쪽 문을 선택하면 살아남겠지만, 끔찍한 괴물이 아니라면... - - 레벨 1에서는 무서운 이야기를 지어내는 것으로 유령의 집 게임을 시작하고 플레이어에게 유령의 집에서 어떤 괴물을 보게 될지 물어봅니다. - story_text_2: | - ### 연습문제 - Copy the example code to your input screen by clicking the yellow button. - Now finish the story by adding at least 5 lines of code. - Remember to start each line of codes with a `{print}` command. - 2: - story_text: | - 이 유령이 나오는 집에서는 이모지로 몬스터를 고를 수 있습니다. 물론 단어도 사용할 수 있습니다. - story_text_2: | - ### 연습문제 - In the example above the monsters are predetermined. So each time you run your code, the output is the same. - Can you add `{ask}` commands to make the haunted house interactive and have the players choose the monsters they come across? - 3: - story_text: | - In the previous levels you've made an introduction to your haunted house game, but as you might have noticed the story would always have a dreadful end. - In this level you can make your story more interactive by changing the outcome of the game; sometimes you'll get eaten, sometimes you'll escape! - Let Hedy decide randomly! - - ### 연습문제 - Copy the example codes and fill in the blanks to make it work! - - **Extra** This story is pretty straight forward, maybe you can spook it up a bit by adding a more exciting story. - Also you have very limited outcomes right now, there are only 3 options of what's behind the doors. Maybe you can think of more monsters to add to the list! - 4: - story_text: | - In this level you learn how to use quotation marks in your games. - - ### 연습문제 - Can you make your Haunted House level 4 proof? - - ### 연습문제 2 - Go back to the previous level and copy your haunted house code. Make the code work in this level by adding quotation marks in the right spots. - 5: - story_text: | - Up until this level the haunted house game always asked the player to choose a door, but as you might have noticed, they didn't really have to answer correctly. - If the player filled in a completely random answer, the game would still work and the player might even win (despite not picking a door). - In this level you can only win the game by picking the same door Hedy picked randomly. - - ### 연습문제 - Can you find the 4 missing words to complete the code? - 9: - story_text: "In this level you can use nesting, which allows you to make the haunted house even more interactive!\n\n### 연습문제\nNow it's very hard to win this game, can you make it easier to win?\nChange your code so it only has one wrong door and two correct doors instead of one correct door and two wrong ones? \nTip: This means changing the variable correct_door into wrong_door, and switching the `{if}` and `{else}` code.\nAnd of course you may also change the story and make it your own. Change the monsters or make it a happy game show where you get a gift!\n" - 11: - story_text: "In this level we've changed the `{for}` command so we can tell the player where they are. \n\n### 연습문제 1\nFinish the program so the player knows which room they are in.\n\n### 연습문제 2\nMake the program into an adventure by following these steps:\n\n1. Make a list of choices (like: fight or flight)\n 2. Make sure the player can choose an option with `{ask}`\n3. Is answer correct? Then they may proceed to the next monster. Do they give a wrong answer? Let the player know with a `{print}`. \n\n**Extra** If you make a wrong choice, a monster is still shown! How could you change that?\n" - if_command: - description: Introducing the if command - levels: - 5: - story_text: | - ## If... else.... - 레벨 5에는 새로운 것인 {if}가 있다! `{if}`을(를) 사용하면 두 개의 다른 옵션 중에서 선택할 수 있다. - 이 코드는 이름으로 Hedy를 입력하면 인쇄가 잘 되고, 다른 이름으로 입력하면 야유. - `{ask}`와 `{print}`는 여전히 레벨 4와 같이 작동한다. - story_text_2: | - `{if}`인 코드가 정말 길어져서 행에 잘 맞지 않을 때도 있다.
코드를 두 줄에 걸쳐 나눌 수도 있는데, 두 번째 줄은 다음과 같이 `{else}`에서 시작한다: - story_text_3: | - ### 연습 문제 - `{if}`와 `{else}`로 자신만의 코드를 만들어 보자. 원한다면 예제 코드를 사용할 수 있다. - 8: - story_text: | - ## If... Else... - `{repeat}` 명령 후 코드 행 블록을 반복하는 법을 배웠습니다. - 이제 들여쓰기를 사용하여 {if} 또는 {else} 명령 뒤에 블록을 만들 수도 있습니다. - 예제 코드를 확인해 보세요. + ## If... Else... + `{repeat}` 명령 후 코드 행 블록을 반복하는 법을 배웠습니다. + 이제 들여쓰기를 사용하여 {if} 또는 {else} 명령 뒤에 블록을 만들 수도 있습니다. + 예제 코드를 확인해 보세요. ### 연습 문제 예제 코드에 {else} 명령어를 추가합니다. 들여쓰기를 사용하여 선 블록을 만듭니다. 이것은 각 선을 4개의 공백으로 시작하여 수행합니다. - 9: - story_text: | - In this level you can also put an {if} command inside another {if} command. in_command: description: Introducing the in command levels: @@ -1218,13 +420,7 @@ adventures: ### 연습문제 배운 명령어를 빈칸에 채워 예제 코드를 완성합니다. 코드를 완성했으면 자신의 코드를 만들고 자신이 생각한 질문을 사용해 보십시오. - example_code_2: | - ``` - animals is dog, cow, sheep - answer is ask 'What is your favorite animal?' - _ answer _ animals _ 'Mine too!' - _ _ 'My favorite animals are dogs, cows and sheep' - ``` + is_command: description: introducing is command levels: @@ -1245,58 +441,10 @@ adventures: `>`은 첫 번째 숫자가 두 번째 숫자보다 큰지 확인하고, 예를 들어 `>` 는 포인트가 10보다 큰지 확인한다. 첫 번째 숫자가 두 번째 숫자보다 크거나 같은지 확인하려면 점 `>=`를 사용하면 된다. 다음과 같이 `{if}`에서 이들 비교를 사용한다: - example_code: | - ``` - age = {ask} 'How old are you?' - {if} age > 12 - {print} 'You are older than I am!' - ``` story_text_2: | 이 레벨부터는 정확하게 비교하고 싶다면 두 개의 등호를 사용할 수 있다. 대부분의 프로그래밍 언어는 다음과 같이 한다: story_text_3: | 다음과 같이 `!=`을 사용하여 어떤 것이 다른 것과 *not* 같은지 비교할 수도 있습니다: - example_code_3: | - ``` - name = {ask} 'What is your name?' - {if} name != 'Hedy' - {print} 'You are not Hedy' - ``` - - {if} age < 13 - {print} 'You are younger than me!' - {else} - {print} 'You are older than me!' - language: - levels: - 5: - story_text: | - Make your own program to practice your vocabulary in a new language. - - ### 연습문제 - Make the code longer by adding at least 3 more words for the player to learn. - **Extra** Of course, you can choose to use a different language than French. You can change to code to any language you'd like to learn. - maths: - levels: - 6: - example_code: | - ``` - {print} '5 plus 5 is ' 5 + 5 - {print} '5 minus 5 is ' 5 - 5 - {print} '5 times 5 is ' 5 * 5 - ``` - 12: - example_code_2: | - ``` - a = 'Hello ' - b = 'world!' - {print} a + b - ``` - - {print} 2.5 + 2.5 - music: - levels: - 6: - story_text: "Instead of playing notes, you can also play numbers now. Simply type `{play} 1` for the lowest note, `{play} 70` for the highest note, or anything in between.\n\n### Exercise\n This calls for musical maths! Try out the example code a couple of times with different starting numbers. \nThen, see if you can compose a song using the numbers.\n" parrot: name: 앵무새 default_save_name: 앵무새 @@ -1333,74 +481,6 @@ adventures: ### 연습문제 누락된 명령어 4개를 입력하여 코드를 마무리합니다. - piggybank: - levels: - 12: - story_text: | - In this adventure you learn how to make a digital piggy bank. - - ### 연습문제 - Finish the code to calculate how much money you have and how long you need to save up to buy what you want! - **Extra** Maybe you have already saved some money? Deduct that from the amount you will have to save up. - example_code: | - ``` - {print} 'The digital piggy bank' - wish = {ask} 'What would you like to buy?' - price = {ask} 'How much does that cost?' - saved = {ask} 'How much money have you saved already?' - allowance = {ask} 'How much pocket money do you get per week?' - to_save = price - saved - weeks = to_save / allowance - {print} 'You can buy a ' wish ' in ' weeks ' weeks.' - ``` - 14: - example_code: | - ``` - _ calculate_budget with wish, money, allowance - to_save = wish - money - weeks = to_save / allowance - {if} wish _ money - {print} 'You need to save up some more!' - {print} 'Youll need ' weeks ' more weeks.' - {else} - {print} 'Great! You have enough' - {print} 'Lets go shopping!' - - money = {ask} 'How much money have you saved?' - wish = {ask} 'How much money do you need?' - allowance = {ask} 'How much pocket money do you get each week?' - - {call} calculate_budget with _, _, _ - ``` - pressit: - levels: - 5: - story_text: | - In this level there is another new keyword: `{pressed}`! - With `{pressed}` you can use keys on your keyboard to control what lines are used. - - ### 연습문제 - Look at the example and add one more line of code that reacts to a key press. - story_text_2: | - You can also link turtle commands to keys. - - ### 연습문제 - Copy the lines a few times so you can create a larger drawing. - 7: - story_text: | - Now that you have learned about `{repeat}`, we can press keys multiple times. - You can use it to make the turtle walk forward and turn. - - ### 연습문제 - The code you have seen in level 5 only checks the key once. Copy the example code and add a `{repeat}` to it, so that you can press the keys many times. - Use this code to draw something nice. - 9: - story_text: | - Now that you know how to combine statements, you can create a touch type tool with `{pressed}`. - - ### 연습문제 - Finish the code. Each time a random letter should be chosen, which you have to press. You get a point for a correct press, and and two points deduction for a wrong press. - **Extra** Clear the screen after each letter, and show the user how many points they have scored. print_command: levels: 1: @@ -1428,13 +508,6 @@ adventures: 진짜 파이썬 코드에 도착했어! 이제부터는 `{print}`와 `{range}`가 있는 괄호를 써야 한다는 얘기다. 영어 명령어만 사용하면 파이썬 환경에서 이 레벨의 Hedy 코드를 사용할 수 있다는 의미도 있다. 지금까지 사용하지 않았다면 명령어 메뉴의 토글을 전환하여 사용할 수 있다. story_text_2: 두 개 이상의 항목을 인쇄하려면 쉼표,으로 구분해야 합니다. - example_code_2: | - ``` - temperature = 25 - {print}('It is ', temperature, ' degrees outside') - ``` - - {print}('My name is ', name) quotation_marks: name: '''따옴표''' levels: @@ -1483,20 +556,6 @@ adventures: 이것은 반복하고 싶은 선들의 블록을 만들어서 하는 것이다. 이 블록의 줄에는 **indentation**가 필요합니다. 그것은 각 줄의 시작에 4칸을 넣는 것을 의미한다. 한 줄로 된 블록을 만들고 싶을 때도 들여쓰기를 해야 한다. - 9: - story_text: | - Great job! You've reached another new level! In the previous level you've learned to use multiple lines of code in an {if} or {repeat} command. But you can't yet combine the two... - Good news! In this level you will be allowed to put an {if} inside an {if}, or inside a {repeat} command. Putting a block of code inside another block of code is called nesting. ``` Putting a block of code inside another block of code is called nesting. - example_code: | - ``` - answer = {ask} 'Are you ready to learn something new?' - {if} answer {is} yes - {print} 'Great! You can learn to use the repeat command in the if command!' - {print} 'Hooray!' - {print} 'Hooray!' - {print} 'Hooray!' - {else} - {print} 'Maybe you should practice some more in the previous level' repeat_command_2: description: repeat 명령어 2 levels: @@ -1532,53 +591,6 @@ adventures: 그러면 식당 프로그램에 최소 4줄의 코드를 추가해주세요. 고객에게 무엇을 마시고 싶은지 물어보고 현금이나 카드로 지불하고 싶은지 물어봅니다. 마지막으로 고객과 작별할 수 있는 좋은 방법을 생각해 보세요. - 2: - story_text_2: | - ### 연습문제 - Copy your own restaurant code from to previous level to the input screen below. - Fix the code by replacing the `{ask}` and `{echo}` commands and using variables, like you've learned in this level. - - Now that your code is working again, it's time to add something more. - Look at the last line of the example code: `{print} food with topping is on its way!` - In this single line 2 variables have been used to create a summary of the order. - Now add your own summary of the food and drinks ordered by the customer. - - **Extra** Now that you've learned how to use variables, you can use as many variables in one line as you'd like. Can you add more variables to your code, like eat in or take-away, cash or card, with or without a straw etc.? - 3: - story_text_2: | - ### 연습문제 - Now make your own version of the random restaurant. - Make a list of starts, mains, desserts, drinks and prices yourself. - Then use `{print}` and `{at} {random}` commands to tell the costumer what will be on their menu tonight. - 4: - story_text: | - ### 연습문제 - Add the quotation marks to this code to make it work! Be careful: variables should not be in quotation marks. - Then, use the `{clear}` command to only show one line at a time in your output screen. - - ### 연습문제 2 - Go back to the previous level and copy your restaurant code. Make the code work in this level by adding quotation marks in the right spots and add some `{clear}` commands. - 5: - story_text: | - ### 연습문제 - The example code shows how you could program that you've run out of a menu item in your restaurant. - Copy your own restaurant code from the previous levels. Create a problem in your restaurant and code it, like the example code did. - For instance, you could also run out of a menu item, or you don't take credit cards, or the ice cream machine is broken. - - **Extra** Have you programmed the problem and programmed appropriate responses? Then try to add more `{if}` and `{else}` commands into your code. - Try to add an `{if}` after every `{ask}` command in your code to make the code as interactive as possible! - 6: - story_text: | - In this level you can use maths to calculate the total price of your customer's order, which can make your virtual restaurant more realistic. - But you can also add many more things to your virtual restaurant, for example more courses. - - ### 연습문제 - You can add many more things to your virtual restaurant. For example, can you... - - ask how many people are coming and multiply the price by that amount? - - add another course? - - give people a discount when they enter a (secret) couponcode? - - add a children's menu? - - think of other fun things to add? 7: story_text: | 이 레벨에서는 코드의 한 줄을 일정 시간 반복하기 위해 `{repeat}` 명령을 사용하는 방법을 배웠습니다. @@ -1587,87 +599,6 @@ adventures: ### 연습문제 코드를 완성할 수 있나요? Hedy는 이 질문을 사람 수만큼 반복해야 합니다. 그래서 만약에 5명이면 5번 질문을 해야 합니다. **추가** 음료나 소스와 같은 더 많은 질문으로 코드를 확장합니다. - 8: - story_text: | - 이 레벨에서 당신은 여러 줄의 코드를 반복함으로써 가상 식당을 더 정교하게 만들 수 있다. 다음과 같이: - - ### 연습문제 - This code can be expanded with more items on the menu, for example offering drinks, and/or multiple courses or desserts. Add at least one more item. - **Extra** Add even more items, as many options as you like! - example_code: | - ``` - {print} 'Welcome to Hedys restaurant!' - people = {ask} 'How many people will be joining us today?' - {print} 'Great!' - {repeat} people {times} - food = {ask} 'What would you like to order?' - {print} food - {print} 'Thank you for ordering!' - {print} 'Enjoy your meal!' - ``` - 9: - story_text: "In this level you can use nesting to make your restaurant more realistic and more fun!\n\n### 연습문제\nThe indentation was removed in the example code. \nCan you figure out how much indentation each line needs in order for the code to work properly?\nIf the customer orders pizza, Hedy shouldn't ask what sauce the costumer wants.\n\n**Extra** A restaurant does not stock all sauces. Make a list of available sauces and give a reply with each order whether you sell it.
\n**Extra** Pizzas have toppings. Ask customers what they want.
\n**Extra** Do customers want a drink? Ask them too!
\n" - 10: - story_text: | - In this level you'll learn how to easily ask orders for different courses. - - ### 연습문제 1 - Finish the code with an `{ask}` on the blanks such that the customer is asked what they want to eat for each course. - story_text_2: | - ### 연습문제 - Of course, you could also order for multiple people! - Can you add the correct amount of indentation before each line to make the code work properly? - Tip: some lines don't need any indentation at all. - example_code_2: | - ``` - courses = appetizer, main course, dessert - names = Timon, Onno - {for} name {in} names - {for} course {in} courses - food = {ask} name ', what would you like to eat as your ' course '?' - {print} name ' orders ' food ' as their ' course - ``` - 11: - story_text: | - We can use the `{for}` with `{range}` to print the orders from multiple customers in an orderly manner. - - ### 연습문제 - Finish the restaurant code, so that you can ask for the order of multiple people. Print the order number each time: 'Order 1', 'Order 2', etc. - Are you not sure how to go about this? Have a peek at your level 8 code. - - **Extra** In level 9 the restaurant also used prices. You can add that here too! - 12: - story_text: | - From this level on you can use decimal numbers to make you menu more realistic. - - ### 연습문제 - Can you think of a code to give your friends and family a 15% discount? - example_code: | - ``` - price = 0 - food = {ask} 'What would you like to order?' - drink = {ask} 'What would you like to drink?' - {if} food {is} 'hamburger' - price = price + 6.50 - {if} food {is} 'pizza' - price = price + 5.75 - {if} drink {is} 'water' - price = price + 1.20 - {if} drink {is} 'soda' - price = price + 2.35 - {print} 'That will be ' price ' dollar, please' - ``` - 13: - story_text: | - In this level you will learn new commands to extend your code even further. - - ### 연습문제 1 - Place a `{and}` and a `{or}` in the logical place in the program. - - ### 연습문제 2 - Expand your restaurant with at least one more `{and}` and one `{or}`. - For example, create a special discount coupon that only applies to pizza, or give your customer a free drink - with fries and pancakes. Or something completely different of course! 15: story_text: | `{while}`를 사용하면 고객이 주문이 완료될 때까지 주문을 계속 추가할 수 있습니다. @@ -1684,228 +615,18 @@ adventures: 1단계에서는 가위바위보 게임으로 시작할 수 있습니다. `{ask}`를 사용하면 선택을 할 수 있고, `{echo}`를 사용하면 선택을 반복할 수 있습니다. - story_text_2: | - ### 연습문제 - Instead of using words, you could also use emojis: ✊✋✌ - Can you create a code using emojis? - 2: - story_text: | - In this level you can practise using the variables, so that you can make the rock, paper, scissors game in the next level! - ### 연습문제 - Finish the code by filling in the **variable** on the blanks. - This game is not very interactive, but no worries! In the next tab you'll learn how to use variables with the `{ask}` command to make your game interactive! - example_code: | - ``` - choice is rock - {print} I choose _ - ``` 3: - story_text: | - You can use the `{at} {random}` command to let the computer pick rock, paper or scissors! - - ### 연습문제 - Finish the code by using the `{at} {random}` command. story_text_2: | **추가** 두 플레이어가 게임을 하도록 하세요. 먼저 두 플레이어에게 이름을 입력해달라고 요청하고 컴퓨터가 임의로 선택하도록 하세요. - 5: - story_text: | - In this level we can determine whether it's a tie or not. For that you need the new `{if}` code. - - ### 연습문제 - Finish the code by filling in the blanks: - * Let the computer pick a random option - * Ask the player what they want to choose - * Fill in the correct variables in line 4 and 5 - * Finish line 6 so that Hedy can check whether it's a tie or not. - example_code: | - ``` - options {is} rock, paper, scissors - computer_choice {is} _ - choice {is} _ - {print} 'you chose ' _ - {print} 'computer chose ' _ - {if} _ {is} _ {print} 'tie!' {else} {print} 'no tie' - ``` - - 비겼는지 확인하려면 빈칸에 정확한 코드를 입력하세요. - 9: - story_text: "In this level you can program the whole rock, paper, scissors game by nesting the `{if}` commands. \n\n### 연습문제\nCan you finish the code? The program must tell who has won for every combination.\n\n**Extra** Want to play more than one game? Expand the code so that you can play multiple rounds. You can even use an `{ask}` to ask the user how many rounds they want to play.\n" - example_code: | - ``` - choices = rock, paper, scissors - your_choice = {ask} 'What do you choose?' - {print} 'You choose ' your_choice - computer_choice = choices {at} {random} - {print} 'The computer chooses ' computer_choice - {if} computer_choice {is} your_choice - {print} 'Tie' - {if} computer_choice {is} rock - {if} your_choice {is} paper - {print} 'You win!' - {if} your_choice {is} scissors - {print} 'You lose!' - # finish this code - ``` - 10: - story_text: | - ### 연습문제 - In the previous levels you have often made your own rock paper scissors game. Can you finish the code and use the {for} command properly to get the game to work? - 13: - story_text: | - With the `{and}` command you can shorten your rock, paper, scissors code! Check out the example code. - - ### 연습문제 - Finish the code such that a winner is always decided on. Run your code a few times to verify there is always a winner printed. 15: story_text: | ### 연습문제 컴퓨터를 이길 때까지 게임을 해! 하지만 일단 예제 코드를 완성하고... - rock_2: - levels: - 2: - story_text: | - Now that you have learned how to use the `{ask} command, you can make your rock, paper, scissors code interavtive too! - - ### 연습문제 - Make the rock, paper, scissors code interactive by adding the `{ask}` command and a question to your rock, paper, scissors code. - example_code: | - ``` - choice is _ - {print} I choose choice - ``` - secret: - levels: - 12: - story_text: | - In this adventure you can create your own super spy code. Encode a message that only the right agent can decipher. - If the enemy tries to crack the code, they will get some false info to waste their time. - - ### 연습문제 1 - Make your own secret code for your superspy and return both parts only to the real spy. - - ### 연습문제 2 - Add a third component to the code, like a piece of clothing or an object. - example_code: | - ``` - name = {ask} 'What is your name?' - if name {is} '_' - a = 'Go to the airport ' - {else} - a = 'Go to the trainstation ' - password = {ask} 'What is the password?' - {if} password {is} _ - b = 'tomorrow at 02.00' - {else} - b = 'today at 10.00' - {print} _ _ _ - ``` - 13: - story_text: | - We can simplify the superspy code with `{and}`, such that we only need one `{if}`. - - ### 연습문제 1 - Complete the code by filling the right command on the blank. Tip: The superspy has to answer BOTH questions correctly, before they get the confidential information! - - ### 연습문제 2 - We want confuse the enemy even more! Create a list with fake answers and select one at random when a wrong answer is given. sleep_command: description: introducing sleep command levels: 2: story_text: "이 레벨의 또 다른 새로운 명령어는 `{sleep}`으로 프로그램을 잠시 일시 중지한다. {sleep} 명령 뒤에 숫자를 입력하면 해당 시간 동안 프로그램이 일시 중지된다. \n\n### 연습 문제\n{sleep} 명령어를 적어도 3번 사용하는 자신만의 코드를 만들어 이 새로운 명령어를 연습한다. {sleep} 명령어마다 일시 중지 시간이 달라야 한다.\n" - songs: - levels: - 6: - story_text: | - Songs often contain a lot of repetition. Sometimes the repetition is also based on counting. - For example, in the well-known song 'Bottles of beer'. You can program that song with a little math. - - Tip: Use the read aloud function to let Hedy sing the song to you! - - ### 연습문제 - You can now repeat lines 2 to 7 as many times as you want by copying the lines. - 7: - story_text: | - Songs often contain a lot of repetition. For example... Baby Shark! If you sing it, you keep singing the same thing: - - Baby Shark tututudutudu
- Baby Shark tututudutudu
- Baby Shark tututudutudu
- Baby Shark - - ### 연습문제 - You can print the song Baby Shark with a `{repeat}`? Finish the code by replacing the blanks? - **Extra** After Baby Shark you can of course also program other songs. There are many songs with repetition! - Can you think of one more song and print it? - 8: - story_text: | - In a previous level you've programmed the song 'Bottles of beer'. But without the `{repeat}` command, you had to copy the verses many times. - In this level you can repeat the song 99 times, just by adding one simple line! - - ### 연습문제 - Add the right command on the blanks and indent the code correctly. - 10: - story_text: | - With `{for}` you can print make the whole baby shark song (including all the other sharks in the family) in only 6 lines! - - ### 연습문제 1 - Can you make the baby shark code even shorter by using a `{for}` command? Finish the example code. - story_text_2: | - ### 연습문제 2 - Print the song Five little moneys jumping on the bed. Look up the text if you don't remember. - - **Extra** Print the song Old MacDonald had a farm, and make sure all animals make a different sound, using an `{if}`. - 11: - story_text: | - In this level you can use the `{for}` with `{range}` to make songs that use counting, like the 5 little monkeys. - - ### 연습문제 1 - Fill in the blanks and make the code work! If you don't remember the song text, look it up yourself. - - ### 연습문제 2 - The final line of the song is different from the others. Print this line inside the `{for}`, and use an `{if}` to make it work correctly. - 12: - story_text: | - In this song we can make it even easier to program 'if you're happy and you know it, clap your hands'. Because we can put all of the actions in a variable, check it out: - - ### 연습문제 - Can you add the right amount of indentation to each line to make the song play correctly? - Hint: Not all lines need indentation. - example_code: | - ``` - actions = 'clap your hands', 'stomp your feet', 'shout Hurray!' - {for} action {in} actions - {for} i {in} {range} 1 {to} 2 - {print} 'if youre happy and you know it' - {print} action - {print} 'if youre happy and you know it and you really want to show it' - {print} 'if youre happy and you know it' - {print} action - ``` - 18: - story_text: | - In level 16 we made songs using lists. These programs however are no longer working properly in this level. The colons from level 17 and the brackets from level 18 still need to be added. - - ### 연습문제 1 - The Drunken sailor song is given as sample code, but not yet working. - Can you make sure everything works again? To help you, we've put _ in the places of _some_ errors. - - ### 연습문제 2 - Now also look up your Old MacDonald song from level 16, and correct it. - songs_2: - levels: - 12: - example_code: | - ``` - {define} twinkle - {print} 'Twinkle' - {print} '...' - - {call} twinkle - {print} 'Up above the world so high' - {print} 'Like a diamond in the sky' - {call} _ - ``` turtle: name: 거북이 default_save_name: 거북이 @@ -1923,156 +644,6 @@ adventures: 2: story_text: | 이 레벨에서 변수를 사용하여 거북이가 상호작용하도록 만들 수 있다. 예를 들어 플레이어에게 거북이가 몇 걸음을 걸어야 하는지 물어볼 수 있다. - example_code: | - ``` - answer {is} {ask} How many steps should the turtle make? - {forward} answer - ``` - story_text_2: | - Also, in level 1 the turtle could only turn left or right. That is a bit boring! - In level 2 he can point his nose in all directions. - - Use 90 to turn a quarter. We call this degrees. A full turn is 360 degrees. - - ### 연습문제 - Can you make a figure with this code? Maybe a triangle or a circle? - example_code_2: | - ``` - {print} Drawing figures - angle {is} 90 - {turn} angle - {forward} 25 - {turn} angle - {forward} 25 - ``` - 3: - story_text: | - In this level you can use `{at} {random}` with the drawing turtle. A random choice makes the turtle walk a different path each time. - Use `{at} {random}` to choose a value from a list. - ### 연습문제 - Can you copy and paste lines 2 and 3 to create a longer random path? - 4: - example_code: | - ``` - {print} 'Drawing figures' - angle {is} 90 - {turn} angle - {forward} 25 - {turn} angle - {forward} 25 - ``` - 5: - story_text_2: | - ### 연습문제 - Fill in the correct numbers in this code to get it to work. - After you've done that, you can try to add the option backwards. - - **Extra** Instead of using 'left' and 'right', remake the program with North, East, South and West. - This way you could add even more directions like Northeast and Southwest etc. 8: - story_text: "Now that we can repeat several lines, we can make figures more easily.\nWe only have to set the angle once and then use that variable in the `{repeat}`.\n\n### 연습문제 1\nThe example code creates a square. Change the code so that it create another figure, such as a triangle or a hexagon. \nThis requires a change to two lines of code.\nTip: An entire circle is 360 degrees.\n\n### 연습문제 2\nNow create a drawing consisting of at least two polygons.\n" - example_code: | - ``` - angle = 90 - {repeat} 10 {times} - {turn} angle - {forward} 50 - ``` story_text_2: | **Extra** 다양한 도형을 그리는 프로그램을 개선할 수 있습니다. 코드를 완성하면 원하는 다각형을 그릴 수 있습니다! - 9: - story_text: | - Now that we can use a `{repeat}` inside a `{repeat}`, we can create more complex figures. - - ### 연습문제 1 - This code creates three black triangles, change that into five pink squares. - - **Extra** Create a figure of your own choosing consisting of at least two different shapes types. - 10: - story_text: | - In this level you can make the turtle draw a figure. - The turtle will travel the distances in the list, one by one, making bigger and bigger steps. - ### Exercise 1 - Add a 90 degree turn in the loop, so that a spiral is drawn. - Add at least 5 numbers to the list, so the spiral grows larger. - **(extra)** can you change the spiral into another shape? Experiment with numbers for the turn! - ### Exercise 2 - The spiral is drawn outwards, make it go inwards? - turtle_draw_it: - levels: - 9: - example_code: | - Hint for the nested squares: - ``` - colors = red, blue, orange, yellow, pink, purple, green, brown, black - distance = 120 - repeat 5 times - _ - ``` - Hint for the flags: - ``` - country = ask 'which country would you like to see the flag of?' - if country is 'the Netherlands' - color_1 = red - color_2 = white - color_3 = blue - ``` - 10: - example_code: | - Hint Nested Hexagon: - ``` - distances = 100, 80, 60, 40, 20 - {for} distance {in} distances - _ - ``` - - Hint Traffic Lights: - ``` - colors = red, yellow, green - {for} chosen_color {in} colors - color _ - {repeat} _ - ``` - 12: - story_text: | - ### Exercise - Recreate the drawings with the turtle! - Hint: Bracelet designing program. Firstly, define a function **for each shape** you want to use on the bacelet. Then, add the shapes to the bacelet like this: - - Bracelet Designing program - example_code: | - ``` - {define} draw_a_square - _ - - {color} white - {turn} -90 - {forward} 300 - {turn} 180 - - {for} i {in} {range} 1 {to} 5 - {color} gray - {forward} 100 - shape = {ask} 'What kind of shape would you like next on the bracelet?' - chosen_color = {ask} 'In which color?' - {color} chosen_color - {if} shape = 'square' - {call} draw_a_square - ``` - while_command: - description: while - years: - description: Countdown to the new year! - levels: - 11: - story_text: | - 이 레벨에서는 `{for}` number `{in} {range}` 명령을 사용하여 새해를 카운트다운할 수 있습니다. - - ### 연습문제 - 빈칸을 채우고 코드를 작동시켜라! - example_code: | - ``` - {for} number {in} {range} _ {to} _ - {print} number - {print} 'Happy New Year!' - ``` diff --git a/content/adventures/mi.yaml b/content/adventures/mi.yaml index 7e6befb6a3d..0967ef424bc 100644 --- a/content/adventures/mi.yaml +++ b/content/adventures/mi.yaml @@ -1,727 +1 @@ -adventures: - story: - levels: - 12: - example_code: | - ``` - name = 'The Queen of England' - {print} name ' was eating a piece of cake, when suddenly...' - ``` - add_remove_command: - name: '{add} {to} & {remove} {from}' - 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. - and_or_command: - description: introducing and or - ask_command: - description: Introduction ask command - calculator: - levels: - 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`. - 14: - 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 - clear_command: - description: clear command - debugging: - levels: - 3: - 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} - ``` - 8: - 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: - 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!' - {else} - 'I'm sorry we don't sell that' - topping {is} {ask} 'What kind of topping would you like?' - sauce {is} {ask} 'What kind of sauce would you like?' - {print} One chosen_bread with topping and sauce. - price = amount * 6 - {print} 'That will be 'price dollar' please' - ``` - - price = amount * 6 - {print} 'That will be 'price dollar' please' - 11: - story_text: |- - ### Exercise - Debug this calender program. The output of this program is supposed to look like a list of dates. - For example: - - ``` - Hedy calender - Here are all the days of November - November 1 - November 2 - November 3 - ``` - And so on. - - Mind that you have to test your code extra carefully for the month February, because the amount of days in this month changes in leap years. - example_code: | - **Warning! This code needs to be debugged!** - ``` - print 'Hedy calender' - months_with_31 days = January, March, May, July, September, October, December - months_with_30_days = April, June, August, November - month = ask 'Which month would you like to see?' - if month in months_with_31_days - days = 31 - if month in months_with30_days - days = 30 - if month = February - leap_years = 2020, 2024, 2028, 2036, 2040, 2044, 2028 - year = ask 'What year is it?' - if year in leap_years - days = 29 - else - days = 28 - - print 'Here are all the days of ' moth - for i in range 1 to days - print month i - ``` - 12: - example_code: | - **Warning! This code needs to be debugged!** - ``` - define greet - greetings = 'Hello', 'Hi there', 'Goodevening' - print greetings at random - - define take_order - food = ask 'What would you like to eat?' - print 'One food' - drink = 'What would you like to drink?' - print 'One ' drink - more = ask 'Would you like anything else?' - if more is 'no' - print 'Alright' - else - print 'And ' more - print 'Thank you' - - print 'Welcome to our restaurant' - people = ask 'How many people are in your party tonight?' - for i in range 0 to people - call greet_costumer - ``` - 13: - example_code: | - **Warning! This code needs to be debugged!** - ``` - defin movie_recommendation with name - action_movies == 'Die Hard', 'Fast and Furious', 'Inglorious Bastards' - romance_movies = 'Love Actually', 'The Notebook', 'Titanic' - comedy_movies = 'Mr Bean' 'Barbie''Deadpool' - kids_movies = 'Minions', 'Paddington', 'Encanto' - if name is 'Camila' or name is 'Manuel' - recommended_movie = kids_movie at random - if name is 'Pedro' or 'Gabriella' - mood = ask 'What you in the mood for?' - if mood is 'action' - recommended_movie = comedy_movies at random - if mood is 'romance' - recommended_movie = romance_movies - if mood is 'comedy' - recommended_movie = comedy_movies at random - - print 'I would recommend ' recommended_movie ' for ' name - - name = ask 'Who is watching?' - recommendation = ask 'Would you like a recommendation?' - if recommendaion is 'yes' - print movie_recommendation with name - else - print 'No problem!' - ``` - 14: - example_code: | - **Warning! This code needs to be debugged!** - ``` - define calculate_heartbeat - print 'Press your fingertips gently against the side of your neck' - print '(just under your jawline)' - print 'Count the number of beats you feel for 15 seconds' - beats == ask 'How many beats do you feel in 15 seconds?' - heartbeat = beats*4 - print 'Your heartbeat is ' heartbeat - if heartbeat >= 60 or heartbeat <= 100 - print 'Your heartbeat seems fine' - else - if heartbeat > 60 - print 'Your heartbeat seems to be too low' - if heartbeat < 100 - print 'Your heartbeat seems to be too high' - print 'You might want to contact a medical professional' - - measure_heartbeat = ask 'Would you like to measure your heartbeat?' - if measure_heartbeat = 'yes' - call measure_heartbeat - else - 'no problem' - ``` - - print '(just under your jawline)' - print 'Count the number of beats you feel for 15 seconds' - beats == ask 'How many beats do you feel in 15 seconds?' - heartbeat = beats*4 - print 'Your heartbeat is ' heartbeat - if heartbeat >= 60 or heartbeat <= 100 - print 'Your heartbeat seems fine' - else - if heartbeat > 60 - print 'Your heartbeat seems to be too low' - if heartbeat < 100 - print 'Your heartbeat seems to be too high' - print 'You might want to contact a medical professional' - - measure_heartbeat = ask 'Would you like to measure your heartbeat?' - if measure_heartbeat = 'yes' - call measure_heartbeat - else - 'no problem' - 15: - example_code: | - **Warning! This code needs to be debugged!** - ``` - names = 'Tanya', 'Romy', 'Kayla', 'Aldrin', 'Ali' - verbs='walking', 'skipping', 'cycling', 'driving', 'running' - locations = 'on a mountaintop', 'in the supermarket', 'to the swimming pool' - hiding_spots = 'behind a tree', under a table', in a box' - sounds = 'a trumpet', 'a car crash', 'thunder' - causes_of_noise = 'a television', 'a kid with firecrackers', 'a magic elephant', 'a dream' - - chosen_ name = names at random - chosen_verb = verbs at random - chosen_location = 'locations at random' - chosen_sounds = noises at random - chosen_spot = hiding_spots random - chosen_causes = causes_of_noise at random - - print chosen_name ' was ' chosen_verb ' ' chosen_location - print 'when they suddenly heard a sound like ' sounds at random - print chosen_name ' looked around, but they couldn't discover where the noise came from' - print chosen_name ' hid ' chosen_spot' - print 'They tried to look around, but couldn't see anything from there' - hidden = 'yes' - while hidden = 'yes' - print chosen_name 'still didn't see anything' - answer = ask 'does ' chosen_name ' move from their hiding spot?' - if answer = 'yes' - hidden == 'no' - print 'chosen_name moved from' chosen_spot - print 'And then they saw it was just' chosen_cause - print chosen_name 'laughed and went on with their day' - print The End - ``` - 16: - example_code: | - **Warning! This code needs to be debugged!** - ``` - country = ['The Netherlands', 'Poland', 'Turkey', 'Zimbabwe', 'Thailand', 'Brasil', 'Peru', 'Australia', 'India', 'Romania' ] - capitals = 'Amsterdam', 'Warshaw' 'Istanbul', 'Harare', 'Bangkok', 'Brasilia', 'Lima', 'Canberra', 'New Delhi', 'Bucharest' - score = 0 - for i in range 0 to 10 - answer = ask 'What's the capital of ' countries[i] - correct = capital[i] - if answer = correct - print 'Correct!' - score = score + 1 - else - print 'Wrong,' capitals[i] 'in the capital of' countries[i] - print 'You scored ' score ' out of 10' - - ``` - 17: - example_code: | - **Warning! This code needs to be debugged!** - ``` - define food_order - toppings = ask 'pepperoni, tuna, veggie or cheese?' - size = ask 'big, medium or small?' - number_of_pizza = ask 'How many these pizzas would you like?' - - print 'YOU ORDERED' - print number_of_pizzas ' size ' topping ' pizza' - - define drinks_order - drink = ask 'water, coke, icetea, lemonade or coffee?' - number_of_drinks = ask 'How many of these drinks would you like?' - - print 'YOU ORDERED' - print number_of_drinks ' ' drink - - 'Welcome to Hedy pizza' - more_food = ask 'Would you like to order a pizza?' - while more_food = 'yes' - return food_order - more_food = ask 'Would you like to order a pizza?' - more_drinks = ask 'Would you like to order some drinks?' - while more_drinks == 'yes' - call drink_order - more_drinks == ask 'Would you like to order more drinks?' - - - print 'Thanks for ordering!' - ``` - 18: - example_code: | - **Warning! This code needs to be debugged!** - ``` - animals = ['pig', 'dog', 'cow'] - sounds = ['oink', 'woof', 'moo'] - for i in range 1 to 3 - animal = animals[i] - sound = sounds[i] - print 'Old MacDonald had a farm' - print 'E I E I O!' - print 'and on that farm he had a ' animal - print 'E I E I O!' - print 'with a ' sound sound ' here' - print 'and a ' sound sound ' there' - print 'here a ' sound - print 'there a ' sound - print 'everywhere a ' sound sound - ``` - default: - levels: - 6: - story_text: | - In the previous level you have practiced with `{ask}` and `{if}`. For example you can ask guests what they would like to eat. - What you can't yet do though, is calculate the price for everyone's dinner. - - In the previous level you have practiced with `{ask}` and `{if}`. For example you can ask guests what they would like to eat. - What you can't yet do though, is calculate the price for everyone's dinner. - - This level makes it possible to use addition, subtraction and multiplication in your programs. This way you can calculate the prices in your restaurant, but you could also add a secret code to give your friends and family a discount. - Another option in this level is programming your own maths game, for your little brother or sister to practice their multiplications. - Go see for yourself! - 9: - story_text: | - Great job! You've reached another new level! In the previous level you've learned to use multiple lines of code in an {if} or {repeat} command. But you can't yet combine the two... - Good news! In this level you will be allowed to put an {if} inside an {if}, or inside a {repeat} command. Putting a block of code inside another block of code is called nesting. ``` - 17: - story_text: | - Now we are going to change indentation a little bit. Every time that we need an indentation, we need `:` at the line before the indentation. - - In this level you can also use a new command: `{elif}`. `{elif}` is short for `{else} {if}` and you need it when you want to make 3 (or more!) options. - Check it out! - elif_command: - description: elif - levels: - 17: - example_code: | - ``` - prices = ['1 million dollars', 'an apple pie', 'nothing'] - your_price = prices[{random}] - {print} 'You win ' your_price - {if} your_price == '1 million dollars' : - {print} 'Yeah! You are rich!' - {elif} your_price == 'an apple pie' : - {print} 'Lovely, an apple pie!' - {else}: - {print} 'Better luck next time..' - ``` - for_command: - description: for command - fortune: - levels: - 8: - example_code: | - ``` - {print} 'I am Hedy the fortune teller!' - {print} 'You can ask me 3 questions.' - answers = yes, no, maybe - _ _ _ - question = {ask} 'What do you want to know?' - {print} question - {sleep} - {print} 'My crystal ball says...' answers {at} {random} - ``` - functions: - levels: - 12: - example_code: | - ``` - sides = 'left', 'right' - limbs = 'hand', 'foot' - colors = 'red', 'blue', 'green', 'yellow' - - {define} turn - chosen_side = sides {at} {random} - chosen_limb = limbs _ - chosen_color = colors _ - {print} chosen_side ' ' chosen_limb ' on ' chosen_color - - {print} 'Lets play a game of Twister!' - {for} i {in} {range} 1 to _ - {call} turn - {sleep} 2 - ``` - 13: - story_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. - - For example in this code we've programmed the first verse of the song 'My Bonnie is over the ocean'. - In this example code the argument `place` is used. Place is a variable that is only used in the function, so an argument. - To use `place` we have programmed the line `define song with place`. - When the function is called, computer will replace the argument `place`, with the piece of text after `call song with`. - - ### Exercise - The next verse of this song goes: - - Last night as I lay on my pillow - Last night as I lay on my bed - Last night as I lay on my pillow - I dreamed that my Bonnie is dead - - Can you program this verse in the same way as the example? - 14: - example_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?' - - new_price = _ calculate_new_price {with} old_price, _ - {print} 'The new price is ' new_price ' dollar' - ``` - if_command: - description: Introducing the if command - levels: - 9: - story_text: | - In this level you can also put an {if} command inside another {if} command. - in_command: - description: Introducing the in command - is_command: - description: introducing is command - levels: - 14: - example_code: | - ``` - age = {ask} 'How old are you?' - {if} age > 12 - {print} 'You are older than I am!' - ``` - example_code_3: | - ``` - name = {ask} 'What is your name?' - {if} name != 'Hedy' - {print} 'You are not Hedy' - ``` - - {if} age < 13 - {print} 'You are younger than me!' - {else} - {print} 'You are older than me!' - maths: - levels: - 12: - example_code_2: | - ``` - a = 'Hello ' - b = 'world!' - {print} a + b - ``` - - {print} 2.5 + 2.5 - music: - levels: - 6: - story_text: "Instead of playing notes, you can also play numbers now. Simply type `{play} 1` for the lowest note, `{play} 70` for the highest note, or anything in between.\n\n### Exercise\n This calls for musical maths! Try out the example code a couple of times with different starting numbers. \nThen, see if you can compose a song using the numbers.\n" - print_command: - levels: - 18: - example_code_2: | - ``` - temperature = 25 - {print}('It is ', temperature, ' degrees outside') - ``` - - {print}('My name is ', name) - repeat_command: - description: repeat command - levels: - 7: - story_text: | - ## Repeat! Repeat! Repeat! - Level 7 adds the `{repeat}` command. `{repeat}` can be used to execute one line of code multiple times. Like this: - - ### Exercise - Play around with the repeat command. Can you make the happy birthday song in only 3 lines of code instead of 4 now? - 9: - story_text: | - Great job! You've reached another new level! In the previous level you've learned to use multiple lines of code in an {if} or {repeat} command. But you can't yet combine the two... - Good news! In this level you will be allowed to put an {if} inside an {if}, or inside a {repeat} command. Putting a block of code inside another block of code is called nesting. ``` Putting a block of code inside another block of code is called nesting. - example_code: | - ``` - answer = {ask} 'Are you ready to learn something new?' - {if} answer {is} yes - {print} 'Great! You can learn to use the repeat command in the if command!' - {print} 'Hooray!' - {print} 'Hooray!' - {print} 'Hooray!' - {else} - {print} 'Maybe you should practice some more in the previous level' - repeat_command_2: - description: repeat command 2 - restaurant: - levels: - 4: - story_text: | - ### Exercise - Add the quotation marks to this code to make it work! Be careful: variables should not be in quotation marks. - Then, use the `{clear}` command to only show one line at a time in your output screen. - - ### Exercise 2 - Go back to the previous level and copy your restaurant code. Make the code work in this level by adding quotation marks in the right spots and add some `{clear}` commands. - 10: - example_code_2: | - ``` - _ courses = appetizer, main course, dessert - _ names = Timon, Onno - _ {for} name {in} names - _ {for} course {in} courses - _ food = {ask} name ', what would you like to eat as your ' course '?' - _ {print} name ' orders ' food ' as their ' course - ``` - 12: - story_text: | - From this level on you can use decimal numbers to make you menu more realistic. - - ### Exercise - Can you think of a code to give your friends and family a 15% discount? - rock: - levels: - 2: - story_text: | - In this level you can practise using the variables, so that you can make the rock, paper, scissors game in the next level! - ### Exercise - Finish the code by filling in the **variable** on the blanks. - This game is not very interactive, but no worries! In the next tab you'll learn how to use variables with the `{ask}` command to make your game interactive! - secret: - levels: - 12: - example_code: | - ``` - name = {ask} 'What is your name?' - {if} name {is} '_' - a = 'Go to the airport ' - {else} - a = 'Go to the trainstation ' - password = {ask} 'What is the password?' - {if} password {is} _ - b = 'tomorrow at 02.00' - {else} - b = 'today at 10.00' - {print} _ _ _ - ``` - 13: - story_text: | - We can simplify the superspy code with `{and}`, such that we only need one `{if}`. - - ### Exercise 1 - Complete the code by filling the right command on the blank. Tip: The superspy has to answer BOTH questions correctly, before they get the confidential information! - - ### Exercise 2 - We want confuse the enemy even more! Create a list with fake answers and select one at random when a wrong answer is given. - sleep_command: - description: introducing sleep command - songs_2: - levels: - 12: - example_code: | - ``` - {define} twinkle - {print} 'Twinkle' - {print} '...' - - {call} twinkle - {print} 'Up above the world so high' - {print} 'Like a diamond in the sky' - {call} _ - ``` - turtle: - levels: - 2: - story_text: | - In this level you can use variables to make the turtle interactive. For example you can ask the player how many steps the turtle must make. - example_code: | - ``` - answer {is} {ask} How many steps should the turtle make? - {forward} answer - ``` - story_text_2: | - Also, in level 1 the turtle could only turn left or right. That is a bit boring! - In level 2 he can point his nose in all directions. - - Use 90 to turn a quarter. We call this degrees. A full turn is 360 degrees. - - ### Exercise - Can you make a figure with this code? Maybe a triangle or a circle? - example_code_2: | - ``` - {print} Drawing figures - angle {is} 90 - {turn} angle - {forward} 25 - {turn} angle - {forward} 25 - ``` - 10: - example_code: | - ``` - {turn} 90 - distances = 10, 20, 30, 40, 50, 60 - {for} distance {in} distances - {forward} distance - ``` - ``` - turtle_draw_it: - levels: - 9: - example_code: | - Hint for the nested squares: - ``` - colors = red, blue, orange, yellow, pink, purple, green, brown, black - distance = 120 - repeat 5 times - _ - ``` - Hint for the flags: - ``` - country = ask 'which country would you like to see the flag of?' - if country is 'the Netherlands' - color_1 = red - color_2 = white - color_3 = blue - ``` - 10: - example_code: | - Hint Nested Hexagon: - ``` - distances = 100, 80, 60, 40, 20 - {for} distance {in} distances - _ - ``` - - Hint Traffic Lights: - ``` - colors = red, yellow, green - {for} chosen_color {in} colors - color _ - {repeat} _ - ``` - 12: - story_text: | - ### Exercise - Recreate the drawings with the turtle! - Hint: Bracelet designing program. Firstly, define a function **for each shape** you want to use on the bacelet. Then, add the shapes to the bacelet like this: - - Bracelet Designing program - example_code: | - ``` - {define} draw_a_square - _ - - {color} white - {turn} -90 - {forward} 300 - {turn} 180 - - {for} i {in} {range} 1 {to} 5 - {color} gray - {forward} 100 - shape = {ask} 'What kind of shape would you like next on the bracelet?' - chosen_color = {ask} 'In which color?' - {color} chosen_color - {if} shape = 'square' - {call} draw_a_square - ``` - while_command: - description: while - years: - levels: - 11: - example_code: | - ``` - {for} number {in} {range} _ {to} _ - {print} number - {print} 'Happy New Year!' - ``` +{} diff --git a/content/adventures/ms.yaml b/content/adventures/ms.yaml index 30e8fd6f3fe..0967ef424bc 100644 --- a/content/adventures/ms.yaml +++ b/content/adventures/ms.yaml @@ -1,42 +1 @@ -adventures: - calculator: - levels: - 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.\n\n### Exercise 1\nCan you finish line 10 to get the code to work?\n\n### Exercise 2\nGive the player feedback when they enter an answer, like `{print} 'Correct!'` or `{print} 'Wrong! The correct answer is ' correct_answer`.\n" - 14: - example_code: "```\n{define} calculate_mean_grade\n total = 0\n {for} i {in} {range} 1 {to} 4\n grade = {ask} _\n total = total + _\n return _ / 4\n\nmean_grade = {call} _\n{print} 'Your mean grade is ' mean_grade\n```\n\n total = total + _\n return _ / 4\n\nmean_grade = {call} _\n{print} 'Your mean grade is ' mean_grade\n" - rock: - levels: - 2: - story_text: "In this level you can practise using the variables, so that you can make the rock, paper, scissors game in the next level!\n### Exercise\nFinish the code by filling in the **variable** on the blanks.\nThis game is not very interactive, but no worries! In the next tab you'll learn how to use variables with the `{ask}` command to make your game interactive!\n" - tic: - name: Tic Tac Toe - levels: - 17: - example_code: "```\nsign = 'x'\nopen_spots = [1, 2, 3, 4, 5, 6, 7, 8, 9]\ngame = 'on'\nspot_1 = '.'\nspot_2 = '.'\nspot_3 = '.'\nspot_4 = '.'\nspot_5 = '.'\nspot_6 = '.'\nspot_7 = '.'\nspot_8 = '.'\nspot_9 = '.'\n{print} 'TIC TAC TOE!'\n{print} spot_1 spot_2 spot_3\n{print} spot_4 spot_5 spot_6\n{print} spot_7 spot_8 spot_9\n{print} ' '\n{while} game != 'over':\n choice = {ask} 'Player ' sign ', which spot?'\n {if} choice {in} open_spots:\n {remove} choice {from} open_spots\n {if} choice == 1:\n spot_1 = sign\n {if} choice == 2:\n spot_2 = sign\n {if} choice == 3:\n spot_3 = sign\n {if} choice == 4:\n spot_4 = sign\n {if} choice == 5:\n spot_5 = sign\n {if} choice == 6:\n spot_6 = sign\n {if} choice == 7:\n spot_7 = sign\n {if} choice == 8:\n spot_8 = sign\n {if} choice == 9:\n spot_9 = sign\n {else}:\n\ - \ {print} 'That spot was already taken'\n {print} spot_1 spot_2 spot_3\n {print} spot_4 spot_5 spot_6\n {print} spot_7 spot_8 spot_9\n {print} ' '\n {if} spot_1 == spot_2 {and} spot_2 == spot_3 {and} spot_1 != '.':\n {print} 'Player ' sign ' wins!'\n game = 'over'\n {elif} spot_4 == spot_5 {and} spot_5 == spot_6 {and} spot_4 != '.':\n {print} 'Player ' sign ' wins!'\n game = 'over'\n {elif} spot_7 == spot_8 {and} spot_8 == spot_9 {and} spot_7 != '.':\n {print} 'Player ' sign ' wins!'\n game = 'over'\n {elif} spot_1 == spot_4 {and} spot_4 == spot_7 {and} spot_1 != '.':\n {print} 'Player ' sign ' wins!'\n game = 'over'\n {elif} spot_2 == spot_5 {and} spot_5 == spot_8 {and} spot_2 != '.':\n {print} 'Player ' sign ' wins!'\n game = 'over'\n {elif} spot_3 == spot_6 {and} spot_6 == spot_9 {and} spot_3 != '.':\n {print} 'Player ' sign ' wins!'\n game = 'over'\n\ - \ {elif} spot_1 == spot_5 {and} spot_5 == spot_9 {and} spot_1 != '.':\n {print} 'Player ' sign ' wins!'\n game = 'over'\n {elif} spot_3 == spot_5 {and} spot_5 == spot_7 {and} spot_3 != '.':\n {print} 'Player ' sign ' wins!'\n game = 'over'\n {else}:\n {if} sign == 'x':\n sign = 'o'\n {else}:\n sign = 'x'\n```\n" - story_text: "In the previous levels the tic tac toe game had an annoying feature. After every move, you had to fill in yourself if you had won or not.\nThis made the game playable, but also quite slow. In this level we have learned the `{elif}` command, that could solve that problem.\nTo use the `{elif}` to let Hedy check whether or not a player has won is fun, but it also requires a fair amount of extra lines.\n\nIn the example code you see that we added the requirements to win (3 spots in a row horizontally, vertically or diagonally).\nYou can find them in line 46 to 69. You can see that each time the requirement is met (so if a player has won) the variable game is set to 'over'.\nThis means that the `{while}` loop will be stopped and the game ends.\n" - turtle_draw_it: - levels: - 9: - example_code: "Hint for the nested squares:\n```\ncolors = red, blue, orange, yellow, pink, purple, green, brown, black\ndistance = 120\nrepeat 5 times\n_\n```\nHint for the flags:\n```\ncountry = ask 'which country would you like to see the flag of?'\nif country is 'the Netherlands'\n color_1 = red\n color_2 = white\n color_3 = blue\n```\n" - functions: - levels: - 14: - example_code: "```\n{define} calculate_new_price {with} amount, percentage\n percentage = percentage / 100\n discount_amount = amount * percentage\n return amount - discount_amount\n\nold_price = {ask} 'How much is on the price tag?'\ndiscount = {ask} 'What percentage is the discount?'\n\nnew_price = _ calculate_new_price {with} old_price, _\n{print} 'The new price is ' new_price ' dollar'\n```\n" - 12: - example_code: "```\nsides = 'left', 'right'\nlimbs = 'hand', 'foot'\ncolors = 'red', 'blue', 'green', 'yellow'\n\n{define} turn\n chosen_side = sides {at} {random}\n chosen_limb = limbs _\n chosen_color = colors _\n {print} chosen_side ' ' chosen_limb ' on ' chosen_color\n\n{print} 'Lets play a game of Twister!'\n{for} i {in} {range} 1 to _\n {call} turn\n {sleep} 2\n```\n" - 13: - story_text: "Now that you've learned how to use functions, you'll learn how to use a function with an argument.\nAn **argument** is a variable that is used within a function. It is not used outside the function.\n\nFor example in this code we've programmed the first verse of the song 'My Bonnie is over the ocean'.\nIn this example code the argument 'place' is used. Place is a variable that is only used in the function, so an argument.\nTo use 'place' we have placed `{with} place` after `{define} song` .\nWhen the function is called, computer will replace the argument 'place', with the piece of text after `{call} song {with}`.\n\n### Exercise\nThe next verse of this song goes:\n\n```not_hedy_code\nLast night as I lay on my pillow\nLast night as I lay on my bed\nLast night as I lay on my pillow\nI dreamed that my Bonnie is dead\n```\n\nCan you program this verse in the same way as the example?\n" - music: - levels: - 6: - story_text: "Instead of playing notes, you can also play numbers now. Simply type `{play} 1` for the lowest note, `{play} 70` for the highest note, or anything in between.\n\n### Exercise\n This calls for musical maths! Try out the example code a couple of times with different starting numbers. \nThen, see if you can compose a song using the numbers.\n" - turtle: - levels: - 2: - example_code: "```\nanswer {is} {ask} How many steps should the turtle make?\n{forward} answer\n```\n" - example_code_2: "```\n{print} Drawing figures\nangle {is} 90\n{turn} angle\n{forward} 25\n{turn} angle\n{forward} 25\n```\n" - story_text: "In this level you can use variables to make the turtle interactive. For example you can ask the player how many steps the turtle must make.\n" - story_text_2: "Also, in level 1 the turtle could only turn left or right. That is a bit boring!\nIn level 2 he can point his nose in all directions.\n\nUse 90 to turn a quarter. We call this degrees. A full turn is 360 degrees.\n\n### Exercise\nCan you make a figure with this code? Maybe a triangle or a circle?\n" +{}