Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

📜 Explain functions and in range in level 18 #5471

Merged
merged 4 commits into from
Apr 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions content/adventures/ar.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1655,6 +1655,14 @@ adventures:
{print} i
{print} 'Ready or not, here I come!'
```
18:
story_text: |
Lastly, we'll turn `{for} i {in} {range} 1 to 5` into real Python code, like this:
example_code: |
```
{for} i {in} {range}(1,5):
{print} (i)
```
fortune:
name: العراف
default_save_name: العراف
Expand Down Expand Up @@ -1903,6 +1911,35 @@ adventures:
new_price = _ calculate_new_price {with} old_price, _
{print} 'The new price is ' new_price ' dollar'
```
18:
story_text: |
Let's make functions the Pythons way! To define a function, we no longer use:

`{define} name_function {with} argument_1, argument_2:`

but we use:

`{def} name_function(argument_1, argument_2):`.


If you don't want to use arguments, you just leave the space between the parantheses empty.
To call a function, we don't need the `{call}` command anymore. You just type the name of the function.
example_code: |
```
{def} calculate_score(answer, correct_answer):
{if} answer == correct_answer:
score = 1
{elif} answer == '?':
score = 0
{else}:
score = -1
{return} score

answer = {input} ('Where can you find the Eiffel Tower?')
correct_answer = 'Paris'
score = calculate_score(answer, correct_answer)
{print} ('Your score is... ', score)
```
guess_my_number:
name: Guess my number
default_save_name: guess my number
Expand Down
37 changes: 37 additions & 0 deletions content/adventures/bg.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1778,6 +1778,14 @@ adventures:
{print} i
{print} 'Ready or not, here I come!'
```
18:
story_text: |
Lastly, we'll turn `{for} i {in} {range} 1 to 5` into real Python code, like this:
example_code: |
```
{for} i {in} {range}(1,5):
{print} (i)
```
fortune:
name: Fortune teller
default_save_name: Fortune Teller
Expand Down Expand Up @@ -2044,6 +2052,35 @@ adventures:
new_price = _ calculate_new_price {with} old_price, _
{print} 'The new price is ' new_price ' dollar'
```
18:
story_text: |
Let's make functions the Pythons way! To define a function, we no longer use:

`{define} name_function {with} argument_1, argument_2:`

but we use:

`{def} name_function(argument_1, argument_2):`.


If you don't want to use arguments, you just leave the space between the parantheses empty.
To call a function, we don't need the `{call}` command anymore. You just type the name of the function.
example_code: |
```
{def} calculate_score(answer, correct_answer):
{if} answer == correct_answer:
score = 1
{elif} answer == '?':
score = 0
{else}:
score = -1
{return} score

answer = {input} ('Where can you find the Eiffel Tower?')
correct_answer = 'Paris'
score = calculate_score(answer, correct_answer)
{print} ('Your score is... ', score)
```
guess_my_number:
name: Guess my number
default_save_name: guess my number
Expand Down
37 changes: 37 additions & 0 deletions content/adventures/bn.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1712,6 +1712,14 @@ adventures:
{print} i
{print} 'Ready or not, here I come!'
```
18:
story_text: |
Lastly, we'll turn `{for} i {in} {range} 1 to 5` into real Python code, like this:
example_code: |
```
{for} i {in} {range}(1,5):
{print} (i)
```
fortune:
name: Fortune teller
default_save_name: Fortune Teller
Expand Down Expand Up @@ -1955,6 +1963,35 @@ adventures:
new_price = _ calculate_new_price {with} old_price, _
{print} 'The new price is ' new_price ' dollar'
```
18:
story_text: |
Let's make functions the Pythons way! To define a function, we no longer use:

`{define} name_function {with} argument_1, argument_2:`

but we use:

`{def} name_function(argument_1, argument_2):`.


If you don't want to use arguments, you just leave the space between the parantheses empty.
To call a function, we don't need the `{call}` command anymore. You just type the name of the function.
example_code: |
```
{def} calculate_score(answer, correct_answer):
{if} answer == correct_answer:
score = 1
{elif} answer == '?':
score = 0
{else}:
score = -1
{return} score

answer = {input} ('Where can you find the Eiffel Tower?')
correct_answer = 'Paris'
score = calculate_score(answer, correct_answer)
{print} ('Your score is... ', score)
```
guess_my_number:
name: Guess my number
default_save_name: guess my number
Expand Down
37 changes: 37 additions & 0 deletions content/adventures/ca.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1778,6 +1778,14 @@ adventures:
{print} i
{print} 'Ready or not, here I come!'
```
18:
story_text: |
Lastly, we'll turn `{for} i {in} {range} 1 to 5` into real Python code, like this:
example_code: |
```
{for} i {in} {range}(1,5):
{print} (i)
```
fortune:
name: Fortune teller
default_save_name: Fortune Teller
Expand Down Expand Up @@ -2031,6 +2039,35 @@ adventures:
new_price = _ calculate_new_price {with} old_price, _
{print} 'The new price is ' new_price ' dollar'
```
18:
story_text: |
Let's make functions the Pythons way! To define a function, we no longer use:

`{define} name_function {with} argument_1, argument_2:`

but we use:

`{def} name_function(argument_1, argument_2):`.


If you don't want to use arguments, you just leave the space between the parantheses empty.
To call a function, we don't need the `{call}` command anymore. You just type the name of the function.
example_code: |
```
{def} calculate_score(answer, correct_answer):
{if} answer == correct_answer:
score = 1
{elif} answer == '?':
score = 0
{else}:
score = -1
{return} score

answer = {input} ('Where can you find the Eiffel Tower?')
correct_answer = 'Paris'
score = calculate_score(answer, correct_answer)
{print} ('Your score is... ', score)
```
guess_my_number:
name: Guess my number
default_save_name: guess my number
Expand Down
37 changes: 37 additions & 0 deletions content/adventures/cs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1741,6 +1741,14 @@ adventures:
{print} i
{print} 'Ready or not, here I come!'
```
18:
story_text: |
Lastly, we'll turn `{for} i {in} {range} 1 to 5` into real Python code, like this:
example_code: |
```
{for} i {in} {range}(1,5):
{print} (i)
```
fortune:
name: Fortune teller
default_save_name: Fortune Teller
Expand Down Expand Up @@ -2007,6 +2015,35 @@ adventures:
new_price = _ calculate_new_price {with} old_price, _
{print} 'The new price is ' new_price ' dollar'
```
18:
story_text: |
Let's make functions the Pythons way! To define a function, we no longer use:

`{define} name_function {with} argument_1, argument_2:`

but we use:

`{def} name_function(argument_1, argument_2):`.


If you don't want to use arguments, you just leave the space between the parantheses empty.
To call a function, we don't need the `{call}` command anymore. You just type the name of the function.
example_code: |
```
{def} calculate_score(answer, correct_answer):
{if} answer == correct_answer:
score = 1
{elif} answer == '?':
score = 0
{else}:
score = -1
{return} score

answer = {input} ('Where can you find the Eiffel Tower?')
correct_answer = 'Paris'
score = calculate_score(answer, correct_answer)
{print} ('Your score is... ', score)
```
guess_my_number:
name: Guess my number
default_save_name: guess my number
Expand Down
37 changes: 37 additions & 0 deletions content/adventures/cy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1767,6 +1767,14 @@ adventures:
{print} i
{print} 'Ready or not, here I come!'
```
18:
story_text: |
Lastly, we'll turn `{for} i {in} {range} 1 to 5` into real Python code, like this:
example_code: |
```
{for} i {in} {range}(1,5):
{print} (i)
```
fortune:
name: Fortune teller
default_save_name: Fortune Teller
Expand Down Expand Up @@ -2025,6 +2033,35 @@ adventures:
new_price = _ calculate_new_price {with} old_price, _
{print} 'The new price is ' new_price ' dollar'
```
18:
story_text: |
Let's make functions the Pythons way! To define a function, we no longer use:

`{define} name_function {with} argument_1, argument_2:`

but we use:

`{def} name_function(argument_1, argument_2):`.


If you don't want to use arguments, you just leave the space between the parantheses empty.
To call a function, we don't need the `{call}` command anymore. You just type the name of the function.
example_code: |
```
{def} calculate_score(answer, correct_answer):
{if} answer == correct_answer:
score = 1
{elif} answer == '?':
score = 0
{else}:
score = -1
{return} score

answer = {input} ('Where can you find the Eiffel Tower?')
correct_answer = 'Paris'
score = calculate_score(answer, correct_answer)
{print} ('Your score is... ', score)
```
guess_my_number:
name: Guess my number
default_save_name: guess my number
Expand Down
37 changes: 37 additions & 0 deletions content/adventures/da.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1754,6 +1754,14 @@ adventures:
{print} i
{print} 'Ready or not, here I come!'
```
18:
story_text: |
Lastly, we'll turn `{for} i {in} {range} 1 to 5` into real Python code, like this:
example_code: |
```
{for} i {in} {range}(1,5):
{print} (i)
```
fortune:
name: Fortune teller
default_save_name: Fortune Teller
Expand Down Expand Up @@ -2007,6 +2015,35 @@ adventures:
new_price = _ calculate_new_price {with} old_price, _
{print} 'The new price is ' new_price ' dollar'
```
18:
story_text: |
Let's make functions the Pythons way! To define a function, we no longer use:

`{define} name_function {with} argument_1, argument_2:`

but we use:

`{def} name_function(argument_1, argument_2):`.


If you don't want to use arguments, you just leave the space between the parantheses empty.
To call a function, we don't need the `{call}` command anymore. You just type the name of the function.
example_code: |
```
{def} calculate_score(answer, correct_answer):
{if} answer == correct_answer:
score = 1
{elif} answer == '?':
score = 0
{else}:
score = -1
{return} score

answer = {input} ('Where can you find the Eiffel Tower?')
correct_answer = 'Paris'
score = calculate_score(answer, correct_answer)
{print} ('Your score is... ', score)
```
guess_my_number:
name: Guess my number
default_save_name: guess my number
Expand Down
Loading
Loading