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

Draft #79

Merged
merged 21 commits into from
Feb 21, 2025
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
Binary file removed en/images/archery-project.png
Binary file not shown.
1 change: 0 additions & 1 deletion en/meta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,3 @@ steps:
- title: Challenge
challenge: true
- title: What can you do now?

Binary file removed en/solutions/Hello 🌍🌎🌏.zip
Binary file not shown.
1 change: 1 addition & 0 deletions en/step_1.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,4 @@ Click on the **Run** button
</div>

--- /no-print ---

5 changes: 4 additions & 1 deletion en/step_2.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ In Python, `print()`{:.language-python} outputs strings (words or numbers) to th
Open the [Hello 🌍🌎🌏 starter project](https://editor.raspberrypi.org/en/projects/hello-world-starter){:target="_blank"}. The code editor will open in another browser tab.

![The code editor with project starter code on the left in the code area. On the right is the blank output area.](images/starter_project.png)

--- /task ---

--- task ---
Expand All @@ -30,8 +31,8 @@ line_highlights: 18
---
# Put code to run under here.
print(f'Hello')
--- /code ---

--- /code ---

--- /task ---

Expand All @@ -58,6 +59,7 @@ line_number_start: 17
---
# Put code to run under here
print(f'Hello {world}')

--- /code ---

The `f`{:.language-python} character inside the print lets you easily print variables along with strings of text.
Expand Down Expand Up @@ -86,6 +88,7 @@ line_highlights: 19
# Put code to run under here
print(f'Hello {world}')
print(f'Welcome to {python}')

--- /code ---

--- /task ---
Expand Down
1 change: 1 addition & 0 deletions en/step_3.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ print(f'{3 * 9}')
print(f'The date and time is {datetime.now()}')

--- /code ---

--- /task ---

--- task ---
Expand Down
16 changes: 16 additions & 0 deletions en/step_4.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ line_numbers: false
def add_one_and_one():
x = 1 + 1
print(x)

--- /code ---

The name of this function is `add_one_and_one`{:.language-python}.
Expand Down Expand Up @@ -41,7 +42,9 @@ def roll_dice():
print(f'You rolled a {4}')

# Put code to run under here

--- /code ---

--- /task ---

--- task ---
Expand All @@ -57,6 +60,7 @@ line_highlights: 25
---
print(f'The date and time is {datetime.now()}')
roll_dice()

--- /code ---

--- /task ---
Expand All @@ -68,6 +72,7 @@ roll_dice()
--- /task ---

--- task ---

Another module called `random`{:.language-python} can be used to create random numbers.
Change your code to use the `randint`{:.language-python} function to choose a random number between 1 and 6 for the dice roll.

Expand All @@ -81,12 +86,16 @@ line_highlights: 17
# Function definitions
def roll_dice():
print(f'You rolled a {randint(1, 6)}')

--- /code ---

--- /task ---

--- task ---

**Test:** Click the **Run** button.
Now when you run your code, a new random number between 1 and 6 will be chosen each time.

--- /task ---

In Python you can multiply strings such as emojis or whole words by a number, so they print out several times.
Expand All @@ -104,10 +113,13 @@ line_highlights: 17
# Function definitions
def roll_dice():
roll = randint(1,6)

--- /code ---

--- /task ---

--- task ---

Multiply the random number stored in `roll`{:.language-python} by the 🔥 emoji, and print the result.

--- code ---
Expand All @@ -121,10 +133,13 @@ line_highlights: 18
def roll_dice():
roll = randint(1,6)
print(f'You rolled a {roll} {fire * roll}')

--- /code ---

--- /task ---

--- task ---

**Test:** Click the **Run** button.
Your output code should look something like this:

Expand All @@ -136,4 +151,5 @@ Python 🐍 is good at maths!
The date and time is 2023-11-21 16:14:45.140000
You rolled a 4 🔥🔥🔥🔥
```

--- /task ---
9 changes: 7 additions & 2 deletions en/step_5.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
You can use `input()`{:.language-python} to ask the person using your program to enter text.

--- task ---

Change your function to ask the person using your program to enter how many sides on the dice, and save it as a variable.

--- code ---
Expand All @@ -18,11 +19,11 @@ def roll_dice():
print(f'That is a D {max}')
roll = randint(1,6)
print(f'You rolled a {roll} {fire * roll}')

--- /code ---

--- /task ---


--- task ---

**Test:** Click the **Run** button and type in a number of sides.
Expand All @@ -41,7 +42,8 @@ How many sides on your dice?:
That is a D 20
You rolled a 1 🔥
```
--- /task ---

--- /task ---

Inputs are always stored as text, but we need to use the input stored in `max` to specify the largest number that could be rolled.

Expand All @@ -63,11 +65,14 @@ def roll_dice():
print(f'That is a D {max}')
roll = randint(1, int(max))
print(f'You rolled a {roll} {fire * roll}')

--- /code ---

--- /task ---

--- task ---

**Test:** Click the **Run** button a few times. Check that the dice rolls a random number each time.

--- /task ---

2 changes: 2 additions & 0 deletions en/step_7.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
--- challenge ---

--- task ---

Practise adding more `print` lines to your code.

Here are some sentence starters that you can use:
Expand All @@ -18,6 +19,7 @@ roll_dice()
print(f'I ❤️ ...')
print(f'... makes me 😃')
print(f'I would like to make ... with {python}')

--- /code ---

Here is a list of some emojis you might like to use:
Expand Down
1 change: 1 addition & 0 deletions en/step_8.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ Click the **Run** button to view an example of this project.

Or, why not try out another [Python](https://projects.raspberrypi.org/en/projects?software%5B%5D=python) project.


Loading