Skip to content

Commit

Permalink
cleanup work
Browse files Browse the repository at this point in the history
  • Loading branch information
Kristian Rother committed Feb 10, 2024
1 parent 8a3a7aa commit 5a9844a
Show file tree
Hide file tree
Showing 6 changed files with 159 additions and 113 deletions.
9 changes: 2 additions & 7 deletions first_steps/for.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ Execute the following program. What happens?
print("You are great at programming!")
time.sleep(5)
--------------
Exercise 2: Counting
~~~~~~~~~~~~~~~~~~~~
Expand All @@ -43,12 +42,11 @@ Execute the following two lines:

.. code:: python3
for zahl in range(1, 7):
print(zahl)
for number in range(1, 7):
print(number)
Make the code print the numbers from 1 to 20.

--------------

Exercise 3: Prints
~~~~~~~~~~~~~~~~~~
Expand All @@ -65,7 +63,6 @@ Explain why the ``for``-loop is better than this code sniplet:
print(6)
print(7)
--------------
Exercise 4: Indentation
~~~~~~~~~~~~~~~~~~~~~~~
Expand All @@ -88,7 +85,6 @@ and
x = x * 2
print(x)
--------------
Exercise 5: Squares
~~~~~~~~~~~~~~~~~~~
Expand All @@ -105,7 +101,6 @@ Implement a ``for`` loop that produces the following output:
36
49

--------------

Exercise 6: More loops
~~~~~~~~~~~~~~~~~~~~~~
Expand Down
32 changes: 14 additions & 18 deletions first_steps/hello.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Hello World
===========

In this chapter you will:
~~~~~~~~~~~~~~~~~~~~~~~~~
-------------------------

==== ==============================================
area topic
Expand All @@ -18,7 +18,7 @@ area topic


Exercise 1: Your first Program
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
------------------------------

Create a new file in the **editor window** and enter the following
instructions:
Expand All @@ -31,10 +31,9 @@ instructions:
Execute the program by pressing the **“Execute”** button or pressing
**F5** in Spyder. What happens?

--------------

Exercise 2: Break the program!
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Exercise 2: Break the program
-----------------------------

When programming, it is inevitable that you make mistakes. Errors can be
simple typos or complicated errors in the logical structure. One of the
Expand All @@ -61,10 +60,9 @@ the error message:
How can you find out what is going on?

--------------

Exercise 3: input
~~~~~~~~~~~~~~~~~
-----------------

Which of the following ``input`` commands work? Try them one by one.

Expand All @@ -78,10 +76,9 @@ Which of the following ``input`` commands work? Try them one by one.
name = input()
--------------
Exercise 4: print
~~~~~~~~~~~~~~~~~
-----------------

Which of the following ``print`` commands work? Try them one by one.

Expand All @@ -97,10 +94,9 @@ Which of the following ``print`` commands work? Try them one by one.
print(name)
--------------
Exercise 5: Variable names
~~~~~~~~~~~~~~~~~~~~~~~~~~
--------------------------

Try which of the following names of Python variables can be used:

Expand All @@ -118,14 +114,14 @@ Try which of the following names of Python variables can be used:
darth.maul = 'sith'
--------------
Exercise 6: Three little bugs
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-----------------------------

The following program should output a song by Bob Marley.
It contains three bugs.
Find and fix them.
Copy the code into your editor.
Then find and fix the bugs.

.. code:: python3
Expand All @@ -136,18 +132,18 @@ Find and fix them.
text = "part1 + part2 + part3"
print(text
--------------
Exercise 7
~~~~~~~~~~
----------

Write a program that asks for your first and last name and outputs both.

----

Reflection questions
~~~~~~~~~~~~~~~~~~~~
--------------------

* What is a function in Python?
* How can you recognize a function?
* What can you put inside the brackets of the `print()` function?
* What are legal/illegal variable names?
* What can you do if your program does not work?
53 changes: 25 additions & 28 deletions first_steps/python_shell.rst
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,9 @@ window):

If you see a different number than 1 it is still the right place.

--------------

Exercise 1: Basic Arithmetics
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-----------------------------

Execute a few calculations in Python. Insert the missing symbols into
the gaps:
Expand All @@ -62,12 +61,13 @@ the gaps:

Enter the commands into the console and see what happens.

Do not enter the first part (``In [1]`` etc.). It appears automatically.
.. hint::

Do not enter the first part (``In [1]`` etc.). It appears automatically.

--------------

Exercise 2: Division
~~~~~~~~~~~~~~~~~~~~
--------------------

What is the difference between the following instructions?

Expand All @@ -80,10 +80,9 @@ What is the difference between the following instructions?
Enter them in the console and examine the result.

--------------

Exercise 3: Operators
~~~~~~~~~~~~~~~~~~~~~
---------------------

Which operations result in 8?

Expand All @@ -96,10 +95,9 @@ Which operations result in 8?
Enter the instructions and examine the result.

--------------

Exercise 4: Variables
~~~~~~~~~~~~~~~~~~~~~
---------------------

For saving numbers and results of calculations for later, you can store
them in **variables**.
Expand All @@ -112,16 +110,15 @@ Fill the gaps:
In [2]: cats = 7
In [3]: raccoons = 5
In [4]: rabbits
Out[4]: ...
Out[4]: ___
In [5]: cats + 1
Out[5]: ...
Out[5]: ___
In [6]: 3 * raccoons
Out[6]: ...
Out[6]: ___

--------------

Exercise 5: Modify Variables
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
----------------------------

The first instruction modifies the value of a variable from exercise 4.
Insert values and variables so that the result is correct:
Expand All @@ -130,19 +127,20 @@ Insert values and variables so that the result is correct:

In [7]: rabbits = rabbits + 1
In [8]: rabbits
Out[8]: ...
Out[8]: ___

In [9]: animals = ... + ... + ...
In [9]: animals = ___ + ___ + ___
In [10]: animals
Out[10]: 38

In the **Variable Explorer** in Spyder (top right) you can inspect the
content of each variable.
.. hint::

In the **Variable Explorer** in Spyder (top right) you can inspect
the content of each variable.

--------------

Exercise 6: Assignments
~~~~~~~~~~~~~~~~~~~~~~~
Exercise 6: Vaiable Assignments
-------------------------------

Which variable assignmments are correct? Enter the code and execute it
to see if it works.
Expand All @@ -154,14 +152,13 @@ to see if it works.
5 + 6 = y
seven = 3 * 4
--------------
Exercise 7: Rabbit Multiplication
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
---------------------------------

In April you have 10 rabbits:

.. code:: python3
.. code:: text
rabbits = 10
Expand All @@ -174,15 +171,15 @@ The rabbits constantly multiply. Every month, their number grows by

- assume that rabbits never die
- it is ok to calculate with fractions of rabbits
- it is ok to copy the same lines multiple times for each month
- it is ok to repeat the same lines multiple times for each month

.. |image0| image:: calculator.png

----

Reflection Questions
~~~~~~~~~~~~~~~~~~~~
--------------------

* Which arithmetic operators exist in Python?
* What is a variable?
* What does the `=` operator do?
* Do you have to initialize every variable before using it?
* How can you swap the values of two variables?
Loading

0 comments on commit 5a9844a

Please sign in to comment.