diff --git a/404.html b/404.html index e00e9c9aa..aca875eaf 100644 --- a/404.html +++ b/404.html @@ -134,4 +134,4 @@ } } }) -
\ No newline at end of file +
\ No newline at end of file diff --git a/404/index.html b/404/index.html index 3d1ad8c86..26b5a6ba7 100644 --- a/404/index.html +++ b/404/index.html @@ -134,4 +134,4 @@ } } }) -
\ No newline at end of file +
\ No newline at end of file diff --git a/all-exercises/index.html b/all-exercises/index.html index 4b6a6aa70..58e69d4f7 100644 --- a/all-exercises/index.html +++ b/all-exercises/index.html @@ -136,4 +136,4 @@ } } }) -
\ No newline at end of file +
\ No newline at end of file diff --git a/credits/index.html b/credits/index.html index b39f1cc9b..90e2e661e 100644 --- a/credits/index.html +++ b/credits/index.html @@ -134,4 +134,4 @@ } } }) -

Kiitokset ja materiaalista

Kurssin on tehnyt Helsingin yliopiston Agile Education Research -tutkimusryhmä.

Kurssimateriaali

Kurssimateriaalin ja tehtävien tekijät ovat Erkki Kaila, Antti Laaksonen ja Matti Luukkainen. Muutama kurssin tehtävistä on Arto Hellaksen (né Vihavainen) käsialaa.

Kurssin materiaali on lisensoitu Creative Commons BY-NC-SA 4.0 -lisenssillä, joten voit käyttää ja levittää sitä vapaasti, kunhan alkuperäisten tekijöiden nimiä ei poisteta. Jos teet muutoksia materiaaliin ja haluat levittää muunneltua versiota, se täytyy lisensoida samalla lisenssillä. Materiaalien käyttö kaupalliseen tarkoitukseen on ilman erillistä lupaa kielletty.

Kurssilla käytössä oleva teknologia

Kurssisivuston ovat tehneet Henrik Nygren ja Antti Leinonen. Helsingin yliopiston Agile Education Research -tutkimusryhmä on luonut kurssilla käytetyn ohjelmointitehtävien palautusympäristön (Test My Code) ja sen liitännäiset ohjelmointiympäristöihin, kurssimateriaalissa olevan kyselyjärjestelmän ja muut toiminnot.

\ No newline at end of file +

Kiitokset ja materiaalista

Kurssin on tehnyt Helsingin yliopiston Agile Education Research -tutkimusryhmä.

Kurssimateriaali

Kurssimateriaalin ja tehtävien tekijät ovat Erkki Kaila, Antti Laaksonen ja Matti Luukkainen. Muutama kurssin tehtävistä on Arto Hellaksen (né Vihavainen) käsialaa.

Kurssin materiaali on lisensoitu Creative Commons BY-NC-SA 4.0 -lisenssillä, joten voit käyttää ja levittää sitä vapaasti, kunhan alkuperäisten tekijöiden nimiä ei poisteta. Jos teet muutoksia materiaaliin ja haluat levittää muunneltua versiota, se täytyy lisensoida samalla lisenssillä. Materiaalien käyttö kaupalliseen tarkoitukseen on ilman erillistä lupaa kielletty.

Kurssilla käytössä oleva teknologia

Kurssisivuston ovat tehneet Henrik Nygren ja Antti Leinonen. Helsingin yliopiston Agile Education Research -tutkimusryhmä on luonut kurssilla käytetyn ohjelmointitehtävien palautusympäristön (Test My Code) ja sen liitännäiset ohjelmointiympäristöihin, kurssimateriaalissa olevan kyselyjärjestelmän ja muut toiminnot.

\ No newline at end of file diff --git a/error_messages/index.html b/error_messages/index.html index aa4af1ca8..12fb75849 100644 --- a/error_messages/index.html +++ b/error_messages/index.html @@ -169,4 +169,4 @@

print(my_age//2) # error: the variable my_age has not been converted into an integer

TypeError: cannot concatenate 'str' and 'int' objects on line [line number]

-

See above.

\ No newline at end of file +

See above.

\ No newline at end of file diff --git a/exam-adv/index.html b/exam-adv/index.html index b63bc3a25..b4d8361c3 100644 --- a/exam-adv/index.html +++ b/exam-adv/index.html @@ -191,4 +191,4 @@
  • Your programming task submissions will be checked with a plagiarism detector. Any cheating detected leads to a failed exam at minimum, but may also lead to expulsion from the course.
  • The programming tasks in the exam will be similar to the programming tasks in the course material. The best way to prepare for the exam is to revisit the course material.
  • Your course results will be emailed to you after the exam, along with instructions for registering your course credits.
  • -
    \ No newline at end of file +
    \ No newline at end of file diff --git a/exam-intro/index.html b/exam-intro/index.html index 4bc7ecf05..036e1aa72 100644 --- a/exam-intro/index.html +++ b/exam-intro/index.html @@ -189,4 +189,4 @@
  • Your programming task submissions will be checked with a plagiarism detector. Any cheating detected leads to a failed exam at minimum, but may also lead to expulsion from the course.
  • The programming tasks in the exam will be similar to the programming tasks in the course material. The best way to prepare for the exam is to revisit the course material.
  • Your course results will be emailed to you after the exam, along with instructions for registering your course credits.
  • -
    \ No newline at end of file +
    \ No newline at end of file diff --git a/exam/index.html b/exam/index.html index 8014ffe96..0cfc80ec9 100644 --- a/exam/index.html +++ b/exam/index.html @@ -189,4 +189,4 @@
  • Your programming task submissions will be checked with a plagiarism detector. Any cheating detected leads to a failed exam at minimum, but may also lead to expulsion from the course.
  • The programming tasks in the exam will be similar to the programming tasks in the course material. The best way to prepare for the exam is to revisit the course material.
  • Your course results will be emailed to you after the exam, along with instructions for registering your course credits.
  • -
    \ No newline at end of file +
    \ No newline at end of file diff --git a/faq/index.html b/faq/index.html index 834304d22..00ed833fd 100644 --- a/faq/index.html +++ b/faq/index.html @@ -170,4 +170,4 @@

    I'm currently receiving unemployment benefits in Finland. Can I still take this course?

    -

    Please take this up with your employment services office (TE-toimisto). Unfortunately, not all employment services offices treat this course in the same way. Some offices have withdrawn benefits for simply participating in the course, even if the participant is not aiming for a right to study or official study credits. On the other hand, some offices have even recommended this course without withdrawing benefits.

    \ No newline at end of file +

    Please take this up with your employment services office (TE-toimisto). Unfortunately, not all employment services offices treat this course in the same way. Some offices have withdrawn benefits for simply participating in the course, even if the participant is not aiming for a right to study or official study credits. On the other hand, some offices have even recommended this course without withdrawing benefits.

    \ No newline at end of file diff --git a/grading-and-exams/index.html b/grading-and-exams/index.html index 5cb353866..f5bd98c51 100644 --- a/grading-and-exams/index.html +++ b/grading-and-exams/index.html @@ -152,7 +152,7 @@
  • Saturday 17.08.2024
  • Saturday 26.10.2024
  • Saturday 14.12.2024
  • -

    Taking a programming exam

    Once you have completed the required number of exercises for either of the courses, you may take the relevant course exam at any of the times listed above. Specifically, you must have received at least 25% of the exercise points for each of the seven parts on the course by 8 AM on the morning of the exam. If you are taking the advanced course exam, round 14 must be fully completed. If any of the seven points totals falls short of this limit, your exam submission will not be graded.

    Submissions are assessed separately for the Introduction to Programming course (parts 1-7) and the Advanced Course in Programming (parts 8-14).

    You may take part in any number of the exams listed above. The highest grade achieved will be your final grade.

    Information about exam arrangements

    All times are local time in Helsinki, Finland, UTC+03:00

    Taking a programming exam

    Once you have completed the required number of exercises for either of the courses, you may take the relevant course exam at any of the times listed above. Specifically, you must have received at least 25% of the exercise points for each of the seven parts on the course by 8 AM on the morning of the exam. If you are taking the advanced course exam, part 14 must be fully completed. If any of the seven points totals falls short of this limit, your exam submission will not be graded.

    Submissions are assessed separately for the Introduction to Programming course (parts 1-7) and the Advanced Course in Programming (parts 8-14).

    You may take part in any number of the exams listed above. The highest grade achieved will be your final grade.

    Information about exam arrangements

    All times are local time in Helsinki, Finland, UTC+03:00

    Please fill in this questionnaire before getting started with this section. You will get one exercise point for answering.

    Loading...
    :
    Loading...

    Log in to view the quiz

    Variables are needed for various purposes in programming. You can use variables to store any information that will be needed later in the program's execution.

    In Python programming variables are created like so:

    variable_name = ...

    Here ... means the value stored in the variable.

    For example, when you used the input command to read a string from the user, you stored the string in a variable and then used the variable later in your program:

    name = input("What is your name? ")
    +

    Please fill in this questionnaire before getting started with this section. You will get one exercise point for answering.

    Loading...
    :
    Loading...

    Log in to view the quiz

    Variables are needed for various purposes in programming. You can use variables to store any information that will be needed later in the program's execution.

    In Python programming variables are created like so:

    variable_name = ...

    Here ... means the value stored in the variable.

    For example, when you used the input command to read a string from the user, you stored the string in a variable and then used the variable later in your program:

    name = input("What is your name? ")
     print("Hi, " + name)
    Sample output

    What is your name? Ghosty Hi, Ghosty

    The value stored in a variable can also be defined using other variables:

    given_name = "Paul"
     family_name = "Python"
    @@ -277,4 +277,4 @@
     number3 = 3.62
     
     mean = (number1 + number2 + number3) / 3
    -print(f"Mean: {mean}")
    Sample output

    Mean: 1.6233333333333333

    You have reached the end of this section! Continue to the next section:

    You can check your current points from the blue blob in the bottom-right corner of the page.

    \ No newline at end of file +print(f"Mean: {mean}")
    Sample output

    Mean: 1.6233333333333333

    You have reached the end of this section! Continue to the next section:
    4. Arithmetic operations

    You can check your current points from the blue blob in the bottom-right corner of the page.

    \ No newline at end of file diff --git a/part-1/4-arithmetic-operations/index.html b/part-1/4-arithmetic-operations/index.html index cba21ff88..a3c5c61ed 100644 --- a/part-1/4-arithmetic-operations/index.html +++ b/part-1/4-arithmetic-operations/index.html @@ -328,4 +328,4 @@ print("Hi " + name + "!") age = int(input("What is your age? ")) -# program continues...
    You have reached the end of this section! Continue to the next section:
    5. Conditional statements

    You can check your current points from the blue blob in the bottom-right corner of the page.

    \ No newline at end of file +# program continues...
    You have reached the end of this section! Continue to the next section:
    5. Conditional statements

    You can check your current points from the blue blob in the bottom-right corner of the page.

    \ No newline at end of file diff --git a/part-1/5-conditional-statements/index.html b/part-1/5-conditional-statements/index.html index 0b3935827..32d3c4f28 100644 --- a/part-1/5-conditional-statements/index.html +++ b/part-1/5-conditional-statements/index.html @@ -316,4 +316,4 @@ print("a is less than 5")
    Sample output

    True a is less than 5

    The Python keywords True and False can also be used directly. In the following example the print command is executed every time, because the value of the condition is True:

    condition = True
     if condition:
    -    print("This is printed every time.")
    Sample output

    This is printed every time.

    A program like this is not very useful, but later on during the course you will see examples of Boolean variables coming in very handy.

    Please respond to a quick questionnaire on this week's materials. The questionnaire is worth one exercise point.

    Loading...
    :
    Loading...

    Log in to view the quiz

    You have reached the end of this section!

    You can check your current points from the blue blob in the bottom-right corner of the page.

    \ No newline at end of file + print("This is printed every time.")
    Sample output

    This is printed every time.

    A program like this is not very useful, but later on during the course you will see examples of Boolean variables coming in very handy.

    Please respond to a quick questionnaire on this week's materials. The questionnaire is worth one exercise point.

    Loading...
    :
    Loading...

    Log in to view the quiz

    You have reached the end of this section!

    You can check your current points from the blue blob in the bottom-right corner of the page.

    \ No newline at end of file diff --git a/part-1/index.html b/part-1/index.html index 2ed38f975..fc3d69026 100644 --- a/part-1/index.html +++ b/part-1/index.html @@ -152,4 +152,4 @@ } })
    \ No newline at end of file +
    Loading...
    \ No newline at end of file diff --git a/part-10/1-class-hierarchies/index.html b/part-10/1-class-hierarchies/index.html index d25fbd3d4..f6f178a46 100644 --- a/part-10/1-class-hierarchies/index.html +++ b/part-10/1-class-hierarchies/index.html @@ -387,4 +387,4 @@ print(bonus) print(bonus2)
    Sample output

    0.7225 -0.7586250000000001

    Loading
    Loading
    Loading
    Loading
    You have reached the end of this section! Continue to the next section:
    2. Access modifiers

    You can check your current points from the blue blob in the bottom-right corner of the page.

    \ No newline at end of file +0.7586250000000001

    Loading
    Loading
    Loading
    Loading
    You have reached the end of this section! Continue to the next section:
    2. Access modifiers

    You can check your current points from the blue blob in the bottom-right corner of the page.

    \ No newline at end of file diff --git a/part-10/2-access-modifiers/index.html b/part-10/2-access-modifiers/index.html index 440bf7e1c..efc0d5ef8 100644 --- a/part-10/2-access-modifiers/index.html +++ b/part-10/2-access-modifiers/index.html @@ -311,4 +311,4 @@ if __name__ == "__main__": jp = Footballer("peter pythons", "pyper", "forward") print(jp) -
    Sample output

    Footballer - name: Peter Pythons, nickname: Pyper, position: forward

    Loading
    Loading
    You have reached the end of this section! Continue to the next section:
    3. Object oriented programming techniques

    You can check your current points from the blue blob in the bottom-right corner of the page.

    \ No newline at end of file +
    Sample output

    Footballer - name: Peter Pythons, nickname: Pyper, position: forward

    Loading
    Loading
    You have reached the end of this section! Continue to the next section:
    3. Object oriented programming techniques

    You can check your current points from the blue blob in the bottom-right corner of the page.

    \ No newline at end of file diff --git a/part-10/3-oo-programming-techniques/index.html b/part-10/3-oo-programming-techniques/index.html index bfa2d4c14..94867f24f 100644 --- a/part-10/3-oo-programming-techniques/index.html +++ b/part-10/3-oo-programming-techniques/index.html @@ -442,4 +442,4 @@ for book in shelf: print(book.name)
    Sample output

    The Life of Python The Old Man and the C -A Good Cup of Java

    Loading
    You have reached the end of this section! Continue to the next section:
    4. Developing a larger application

    You can check your current points from the blue blob in the bottom-right corner of the page.

    \ No newline at end of file +A Good Cup of Java

    Loading
    You have reached the end of this section! Continue to the next section:
    4. Developing a larger application

    You can check your current points from the blue blob in the bottom-right corner of the page.

    \ No newline at end of file diff --git a/part-10/4-application-development/index.html b/part-10/4-application-development/index.html index 3eee06cb0..72b0d70de 100644 --- a/part-10/4-application-development/index.html +++ b/part-10/4-application-development/index.html @@ -501,4 +501,4 @@ storage_service = CloudHandler("amazon-cloud", "username", "passwrd") application = PhoneBookApplication(storage_service) -application.execute()

    As you have seen before, using techniques like this carries a price tag, as there is more code to write, so a programmer needs to consider whether that is an acceptable tradeoff.

    The technique outlined above is called dependency injection. As the name implies, the idea is to provide any dependency required by an object from outside the object. It is a very useful tool in a programmer's toolbox, as it makes it easier to implement new features in programs and facilitates automatic testing. This theme will be further explored on the aforementioned courses Software Development Methods and Software Engineering.

    Please respond to a quick questionnaire on this part of the course.

    Loading...
    :
    Loading...

    Log in to view the quiz

    You have reached the end of this section!

    You can check your current points from the blue blob in the bottom-right corner of the page.

    \ No newline at end of file +application.execute()

    As you have seen before, using techniques like this carries a price tag, as there is more code to write, so a programmer needs to consider whether that is an acceptable tradeoff.

    The technique outlined above is called dependency injection. As the name implies, the idea is to provide any dependency required by an object from outside the object. It is a very useful tool in a programmer's toolbox, as it makes it easier to implement new features in programs and facilitates automatic testing. This theme will be further explored on the aforementioned courses Software Development Methods and Software Engineering.

    Please respond to a quick questionnaire on this part of the course.

    Loading...
    :
    Loading...

    Log in to view the quiz

    You have reached the end of this section!

    You can check your current points from the blue blob in the bottom-right corner of the page.

    \ No newline at end of file diff --git a/part-10/index.html b/part-10/index.html index 4951dc0f6..db4f18615 100644 --- a/part-10/index.html +++ b/part-10/index.html @@ -152,4 +152,4 @@ } })
    \ No newline at end of file +
    Loading...
    \ No newline at end of file diff --git a/part-11/1-list-comprehensions/index.html b/part-11/1-list-comprehensions/index.html index 8d62084f0..2788dca3d 100644 --- a/part-11/1-list-comprehensions/index.html +++ b/part-11/1-list-comprehensions/index.html @@ -270,4 +270,4 @@ if __name__ == "__main__": test_list = ["hi", 3, True, "there", -123.344, "toodlepip", 2, False] lengths = string_lengths(test_list) - print(lengths)
    Sample output

    [2, -1, -1, 5, -1, 9, -1, -1]

    Loading
    You have reached the end of this section! Continue to the next section:
    2. More comprehensions

    You can check your current points from the blue blob in the bottom-right corner of the page.

    \ No newline at end of file + print(lengths)
    Sample output

    [2, -1, -1, 5, -1, 9, -1, -1]

    Loading
    You have reached the end of this section! Continue to the next section:
    2. More comprehensions

    You can check your current points from the blue blob in the bottom-right corner of the page.

    \ No newline at end of file diff --git a/part-11/2-more-comprehensions/index.html b/part-11/2-more-comprehensions/index.html index d59585e9d..276e32a8b 100644 --- a/part-11/2-more-comprehensions/index.html +++ b/part-11/2-more-comprehensions/index.html @@ -340,4 +340,4 @@ if __name__ == "__main__": numbers = [-2, 3, 2, 1, 4, -10, 5, 1, 6] factorials = {number : factorial(number) for number in numbers if number > 0} - print(factorials)
    Sample output

    {3: 6, 2: 2, 1: 1, 4: 24, 5: 120, 6: 720}

    Loading
    Loading
    You have reached the end of this section! Continue to the next section:
    3. Recursion

    You can check your current points from the blue blob in the bottom-right corner of the page.

    \ No newline at end of file + print(factorials)
    Sample output

    {3: 6, 2: 2, 1: 1, 4: 24, 5: 120, 6: 720}

    Loading
    Loading
    You have reached the end of this section! Continue to the next section:
    3. Recursion

    You can check your current points from the blue blob in the bottom-right corner of the page.

    \ No newline at end of file diff --git a/part-11/3-recursion/index.html b/part-11/3-recursion/index.html index 0597e6506..18afd49af 100644 --- a/part-11/3-recursion/index.html +++ b/part-11/3-recursion/index.html @@ -313,4 +313,4 @@ print(binary_search(target, 15, 0, len(target)-1))
    Sample output

    True True False -False

    The binary_search function takes four arguments: the target list, the item being searched for, and the left and right edges of the search area. When the function is first called, the search area covers the entire target list. The left edge is at index 0 and the right edge is at index len(target)-1. The function calculates the central index and checks that position on the list. Either the item was found, or the search continues to the smaller or greater half of the target list.

    Let's compare this to a simple linear search. In a linear search, the search area is traversed from the beginning onwards, until either the item is found, or we run out of search area. The number of steps needed to cover the entire search area grows linearly at the same pace as the size of the search area. Each search step covers only one search candidate from the beginning of the search area. Let's assume the item searched for is not found. If the search area is a million items long, we would have to take a million search steps to make sure the item is not in the search area.

    In a binary search, on the other hand, the number of steps needed grows logarithmically. Let's assume again that the item searched for is not found. The search area is cut in half with each step, as we know that the item is either smaller or greater than the current search candidate at the centre. 2 to the power of 20 (2^20) is already well over 1 million, so it will take at most 20 steps to cover the entire search area with a binary search. So, when we are dealing with sorted search areas, as we often are when dealing with computers and materials that are meant to be automatically processed, a binary search is much more efficient than a linear search.

    You have reached the end of this section! Continue to the next section:
    4. More recursion examples

    You can check your current points from the blue blob in the bottom-right corner of the page.

    \ No newline at end of file +False

    The binary_search function takes four arguments: the target list, the item being searched for, and the left and right edges of the search area. When the function is first called, the search area covers the entire target list. The left edge is at index 0 and the right edge is at index len(target)-1. The function calculates the central index and checks that position on the list. Either the item was found, or the search continues to the smaller or greater half of the target list.

    Let's compare this to a simple linear search. In a linear search, the search area is traversed from the beginning onwards, until either the item is found, or we run out of search area. The number of steps needed to cover the entire search area grows linearly at the same pace as the size of the search area. Each search step covers only one search candidate from the beginning of the search area. Let's assume the item searched for is not found. If the search area is a million items long, we would have to take a million search steps to make sure the item is not in the search area.

    In a binary search, on the other hand, the number of steps needed grows logarithmically. Let's assume again that the item searched for is not found. The search area is cut in half with each step, as we know that the item is either smaller or greater than the current search candidate at the centre. 2 to the power of 20 (2^20) is already well over 1 million, so it will take at most 20 steps to cover the entire search area with a binary search. So, when we are dealing with sorted search areas, as we often are when dealing with computers and materials that are meant to be automatically processed, a binary search is much more efficient than a linear search.

    You have reached the end of this section! Continue to the next section:
    4. More recursion examples

    You can check your current points from the blue blob in the bottom-right corner of the page.

    \ No newline at end of file diff --git a/part-11/4-more-recursion-examples/index.html b/part-11/4-more-recursion-examples/index.html index a460d031d..581b11a98 100644 --- a/part-11/4-more-recursion-examples/index.html +++ b/part-11/4-more-recursion-examples/index.html @@ -286,4 +286,4 @@ if value > root.value: return find_node(root.right_child, value) - return find_node(root.left_child, value)
    Loading

    Revisiting the times before recursion

    Let's finish off this part of the material with a slightly larger exercise concentrating on object oriented programming principles. We do not recommend using recursion in this series of tasks, but list comprehension techniques will come in useful.

    Loading
    Loading

    Please respond to a quick questionnaire on this part of the course.

    Loading...
    :
    Loading...

    Log in to view the quiz

    You have reached the end of this section!

    You can check your current points from the blue blob in the bottom-right corner of the page.

    \ No newline at end of file + return find_node(root.left_child, value)
    Loading

    Revisiting the times before recursion

    Let's finish off this part of the material with a slightly larger exercise concentrating on object oriented programming principles. We do not recommend using recursion in this series of tasks, but list comprehension techniques will come in useful.

    Loading
    Loading

    Please respond to a quick questionnaire on this part of the course.

    Loading...
    :
    Loading...

    Log in to view the quiz

    You have reached the end of this section!

    You can check your current points from the blue blob in the bottom-right corner of the page.

    \ No newline at end of file diff --git a/part-11/index.html b/part-11/index.html index b4f700b66..e41bded87 100644 --- a/part-11/index.html +++ b/part-11/index.html @@ -152,4 +152,4 @@ } })
    \ No newline at end of file +
    Loading...
    \ No newline at end of file diff --git a/part-12/1-functions-as-arguments/index.html b/part-12/1-functions-as-arguments/index.html index 55c3e6a13..417bbc52c 100644 --- a/part-12/1-functions-as-arguments/index.html +++ b/part-12/1-functions-as-arguments/index.html @@ -378,4 +378,4 @@ copy_lines("first.txt", "second.txt", lambda line: "Python" in line) # Copy all lines which do not end in a full stop - copy_lines("first.txt", "second.txt", lambda line: line[-1] != ".")

    The function definition contains a default value for the keyword parameter criterion: lambda x: True. This anonymous function always returns True regardless of the input. So, the default behaviour is to copy all lines. As usual, if a value is given for a parameter with a default value, the new value replaces the default value.

    Loading
    You have reached the end of this section! Continue to the next section:
    2. Generators

    You can check your current points from the blue blob in the bottom-right corner of the page.

    \ No newline at end of file + copy_lines("first.txt", "second.txt", lambda line: line[-1] != ".")

    The function definition contains a default value for the keyword parameter criterion: lambda x: True. This anonymous function always returns True regardless of the input. So, the default behaviour is to copy all lines. As usual, if a value is given for a parameter with a default value, the new value replaces the default value.

    Loading
    You have reached the end of this section! Continue to the next section:
    2. Generators

    You can check your current points from the blue blob in the bottom-right corner of the page.

    \ No newline at end of file diff --git a/part-12/2-generators/index.html b/part-12/2-generators/index.html index ddb9a06f8..50a26a6c4 100644 --- a/part-12/2-generators/index.html +++ b/part-12/2-generators/index.html @@ -252,4 +252,4 @@ ghi hij ijk -jkl

    Loading
    You have reached the end of this section! Continue to the next section:
    3. Functional programming

    You can check your current points from the blue blob in the bottom-right corner of the page.

    \ No newline at end of file +jkl

    Loading
    You have reached the end of this section! Continue to the next section:
    3. Functional programming

    You can check your current points from the blue blob in the bottom-right corner of the page.

    \ No newline at end of file diff --git a/part-12/3-functional-programming/index.html b/part-12/3-functional-programming/index.html index bd7e1f3a6..baad4547f 100644 --- a/part-12/3-functional-programming/index.html +++ b/part-12/3-functional-programming/index.html @@ -413,4 +413,4 @@ sum_of_numbers = reduce(lambda reduced_sum, item: reduced_sum + item, my_list) -print(sum_of_numbers)

    If the initial value is left out, reduce takes the first item in the list as the initial value and starts reducing from the second item onwards.

    NB: if the items in the series are of a different type than the intended reduced result, the thrd argument is mandatory. The example with the bank accounts would not work without the initial value. That is, trying this

    balances_total = reduce(balance_sum_helper, accounts)

    would produce an error:

    TypeError: unsupported operand type(s) for +: 'BankAccount' and 'int'

    In the above case, when reduce tries to execute the balance_sum_helper function for the first time, the arguments it uses are the two first items in the list, which are both of type BankAccount. Specifically, the value assigned to the parameter balance_sum is the first item in the list. The balance_sum_helper function tries to add an integer value to it, but adding an integer directly to a BankAccount object is not a supported operation.

    Loading
    You have reached the end of this section! Continue to the next section:
    4. Regular expressions

    You can check your current points from the blue blob in the bottom-right corner of the page.

    \ No newline at end of file +print(sum_of_numbers)

    If the initial value is left out, reduce takes the first item in the list as the initial value and starts reducing from the second item onwards.

    NB: if the items in the series are of a different type than the intended reduced result, the thrd argument is mandatory. The example with the bank accounts would not work without the initial value. That is, trying this

    balances_total = reduce(balance_sum_helper, accounts)

    would produce an error:

    TypeError: unsupported operand type(s) for +: 'BankAccount' and 'int'

    In the above case, when reduce tries to execute the balance_sum_helper function for the first time, the arguments it uses are the two first items in the list, which are both of type BankAccount. Specifically, the value assigned to the parameter balance_sum is the first item in the list. The balance_sum_helper function tries to add an integer value to it, but adding an integer directly to a BankAccount object is not a supported operation.

    Loading
    You have reached the end of this section! Continue to the next section:
    4. Regular expressions

    You can check your current points from the blue blob in the bottom-right corner of the page.

    \ No newline at end of file diff --git a/part-12/4-regular-expressions/index.html b/part-12/4-regular-expressions/index.html index 4bf041773..e2fef15e4 100644 --- a/part-12/4-regular-expressions/index.html +++ b/part-12/4-regular-expressions/index.html @@ -288,4 +288,4 @@ Please type in a string: jarjar the hut Not found. Please type in a string: jabba the smut -Not found.

    Loading

    Grand finale

    To finish off this part of the material, let's work some more on objects and classes by building a slightly more extensive program. This exercise does not necessarily involve regular expressions, but the sections on functions as arguments and list comprehensions will likely be useful.

    You may also find the example set in part 10 helpful.

    Loading

    Please respond to a quick questionnaire on this part of the course.

    Loading...
    :
    Loading...

    Log in to view the quiz

    You have reached the end of this section!

    You can check your current points from the blue blob in the bottom-right corner of the page.

    \ No newline at end of file +Not found.

    Loading

    Grand finale

    To finish off this part of the material, let's work some more on objects and classes by building a slightly more extensive program. This exercise does not necessarily involve regular expressions, but the sections on functions as arguments and list comprehensions will likely be useful.

    You may also find the example set in part 10 helpful.

    Loading

    Please respond to a quick questionnaire on this part of the course.

    Loading...
    :
    Loading...

    Log in to view the quiz

    You have reached the end of this section!

    You can check your current points from the blue blob in the bottom-right corner of the page.

    \ No newline at end of file diff --git a/part-12/index.html b/part-12/index.html index a25f66efe..85a6ad253 100644 --- a/part-12/index.html +++ b/part-12/index.html @@ -152,4 +152,4 @@ } })
    \ No newline at end of file +
    Loading...
    \ No newline at end of file diff --git a/part-13/1-pygame/index.html b/part-13/1-pygame/index.html index 6ba330922..1287e4346 100644 --- a/part-13/1-pygame/index.html +++ b/part-13/1-pygame/index.html @@ -267,4 +267,4 @@ window.blit(robot, (300, 0)) window.blit(robot, (100, 200))

    The window should look like this as a result:

    Here we set the location of the image so that it lies at the centre of the window:

    width = robot.get_width()
     height = robot.get_height()
    -window.blit(robot, (320-width/2, 240-height/2))

    The window should now look like this:

    The method get_width returns the width of the image, and the method get_height returns its height, both in pixels. The centre of the window is at half its width and height, so at (320, 240), which we can use to calculate a suitable location for the top left corner of the image, so that it lies exactly at the centre.

    Loading
    Loading
    Loading
    Loading
    You have reached the end of this section! Continue to the next section:
    2. Animation

    You can check your current points from the blue blob in the bottom-right corner of the page.

    \ No newline at end of file +window.blit(robot, (320-width/2, 240-height/2))

    The window should now look like this:

    The method get_width returns the width of the image, and the method get_height returns its height, both in pixels. The centre of the window is at half its width and height, so at (320, 240), which we can use to calculate a suitable location for the top left corner of the image, so that it lies exactly at the centre.

    Loading
    Loading
    Loading
    Loading
    You have reached the end of this section! Continue to the next section:
    2. Animation

    You can check your current points from the blue blob in the bottom-right corner of the page.

    \ No newline at end of file diff --git a/part-13/2-animation/index.html b/part-13/2-animation/index.html index 9ae6027b5..3ccf8c1e3 100644 --- a/part-13/2-animation/index.html +++ b/part-13/2-animation/index.html @@ -258,4 +258,4 @@ angle += 0.01 clock.tick(60)

    Running the above code should look like this:

    Rotation in a relatively precise circle is achieved with the help of some basic trigonometric functions. The varible angle contains the angle of the robots location in relation to the centre of the window and the horizontal line running through it. The sine and cosine functions from the Python math library are used to calculate the coordinates of the robot's location:

            x = 320+math.cos(angle)*100-robot.get_width()/2
    -        y = 240+math.sin(angle)*100-robot.get_height()/2

    The robot rotates around a circle of radius 100 around the centre of the window. The hypotenuse in this scenario is the radius of the circle. The cosine function gives the length of the adjacent side of a right triangle in relation to the hypotenuse, which means that it gives us the x coordinate of the location. The sine function gives the length of the opposite side, i.e. the y coordinate. The location is then adjusted for the size of the image, so that the centre of the circle is at the centre of the window.

    With each iteration the size of the angle is incremented by 0.01:llä. As we are using radians, a full circle is 2π, which equals about 6.28. It takes about 628 iterations for the robot to go a full circle, and at 60 iterations per second this takes just over 10 seconds.

    Loading
    Loading
    Loading
    Loading
    Loading
    Loading
    You have reached the end of this section! Continue to the next section:
    3. Events

    You can check your current points from the blue blob in the bottom-right corner of the page.

    \ No newline at end of file + y = 240+math.sin(angle)*100-robot.get_height()/2

    The robot rotates around a circle of radius 100 around the centre of the window. The hypotenuse in this scenario is the radius of the circle. The cosine function gives the length of the adjacent side of a right triangle in relation to the hypotenuse, which means that it gives us the x coordinate of the location. The sine function gives the length of the opposite side, i.e. the y coordinate. The location is then adjusted for the size of the image, so that the centre of the circle is at the centre of the window.

    With each iteration the size of the angle is incremented by 0.01:llä. As we are using radians, a full circle is 2π, which equals about 6.28. It takes about 628 iterations for the robot to go a full circle, and at 60 iterations per second this takes just over 10 seconds.

    Loading
    Loading
    Loading
    Loading
    Loading
    Loading
    You have reached the end of this section! Continue to the next section:
    3. Events

    You can check your current points from the blue blob in the bottom-right corner of the page.

    \ No newline at end of file diff --git a/part-13/3-events/index.html b/part-13/3-events/index.html index 7b310ca68..9f6a6c891 100644 --- a/part-13/3-events/index.html +++ b/part-13/3-events/index.html @@ -347,4 +347,4 @@ window.blit(robot, (robot_x, robot_y)) pygame.display.flip() - clock.tick(60)

    The program's execution should look more or less like this:

    Loading
    Loading
    You have reached the end of this section! Continue to the next section:
    4. More pygame techniques

    You can check your current points from the blue blob in the bottom-right corner of the page.

    \ No newline at end of file + clock.tick(60)

    The program's execution should look more or less like this:

    Loading
    Loading
    You have reached the end of this section! Continue to the next section:
    4. More pygame techniques

    You can check your current points from the blue blob in the bottom-right corner of the page.

    \ No newline at end of file diff --git a/part-13/4-more-pygame-techniques/index.html b/part-13/4-more-pygame-techniques/index.html index 2bb5bfefd..bee359cc0 100644 --- a/part-13/4-more-pygame-techniques/index.html +++ b/part-13/4-more-pygame-techniques/index.html @@ -222,4 +222,4 @@ while True: for event in pygame.event.get(): if event.type == pygame.QUIT: - exit()

    Running the above code should look like this:

    Here the method pygame.font.SysFont creates a font object, which uses the system font Arial in size 24. The the method render creates an image of the specified text in the given colour. This image is drawn on the window with the blit method, just as before.

    NB: different systems will have different fonts available. If the system this program is exeuted on doesn't have the Arial font, even though Arial is a very common font available on most systems, the default system font is used instead. If you need to have a specific font available for your game, you can include the font file in the game directory and specify its location for the pygame.font.Font method.

    Exercises

    Here are some more advanced exercises for practicing what you have learned in this part of the course material.

    Loading
    Loading

    Please respond to a quick questionnaire on this part of the course.

    Loading...
    :
    Loading...

    Log in to view the quiz

    You have reached the end of this section!

    You can check your current points from the blue blob in the bottom-right corner of the page.

    \ No newline at end of file + exit()

    Running the above code should look like this:

    Here the method pygame.font.SysFont creates a font object, which uses the system font Arial in size 24. The the method render creates an image of the specified text in the given colour. This image is drawn on the window with the blit method, just as before.

    NB: different systems will have different fonts available. If the system this program is exeuted on doesn't have the Arial font, even though Arial is a very common font available on most systems, the default system font is used instead. If you need to have a specific font available for your game, you can include the font file in the game directory and specify its location for the pygame.font.Font method.

    Exercises

    Here are some more advanced exercises for practicing what you have learned in this part of the course material.

    Loading
    Loading

    Please respond to a quick questionnaire on this part of the course.

    Loading...
    :
    Loading...

    Log in to view the quiz

    You have reached the end of this section!

    You can check your current points from the blue blob in the bottom-right corner of the page.

    \ No newline at end of file diff --git a/part-13/index.html b/part-13/index.html index 38bcecafc..5b26190a6 100644 --- a/part-13/index.html +++ b/part-13/index.html @@ -152,4 +152,4 @@ } })
    \ No newline at end of file +
    Loading...
    \ No newline at end of file diff --git a/part-14/1-game-project/index.html b/part-14/1-game-project/index.html index 02d6e26ba..41939e74b 100644 --- a/part-14/1-game-project/index.html +++ b/part-14/1-game-project/index.html @@ -408,4 +408,4 @@

    The main loop.display.flip()

    At this stage the only event actually handled by the game is closing the game window, e.g. from the exit button. The game then exits by calling the Python exit function.

    Each time draw_window method is called the entire game grid is matrix is traversed, and the image corresponding to each square in the grid is drawn in the correct location.

    -

    NB: the coordinates x and y are used in two different ways in the game. When dealing with the indexes of a two-dimensional list, it is logical to give the y coordinate first, as the y refers to the number of the row while x is the number of the column. On the other hand, when using pygame methods, x is usually passed first, as it quite often is when dealing with graphics, and also in mathematical contexts.

    You have reached the end of this section! Continue to the next section:

    You can check your current points from the blue blob in the bottom-right corner of the page.

    \ No newline at end of file +

    NB: the coordinates x and y are used in two different ways in the game. When dealing with the indexes of a two-dimensional list, it is logical to give the y coordinate first, as the y refers to the number of the row while x is the number of the column. On the other hand, when using pygame methods, x is usually passed first, as it quite often is when dealing with graphics, and also in mathematical contexts.

    You have reached the end of this section! Continue to the next section:

    You can check your current points from the blue blob in the bottom-right corner of the page.

    \ No newline at end of file diff --git a/part-14/2-robot-and-boxes/index.html b/part-14/2-robot-and-boxes/index.html index f131f9d23..a6b37ed6b 100644 --- a/part-14/2-robot-and-boxes/index.html +++ b/part-14/2-robot-and-boxes/index.html @@ -255,4 +255,4 @@

    Refactoring?The number 3 meant a box just previously, but now it is subtracted from the value of a square on the grid. This works in the context of our numbering scheme, as it changes a box (3) into a normal floor square (0), or a target square with a box (5) into an empty target square (2), but understanding this requiares a primer in the numbering scheme used.

    We could make it easier for anyone reading the code by refactoring our implementation. That means improving the structure and readability of the code. One way to achieve this would be to use the names of the squares instead of the numbers 0 to 6, even though this would still not explain how and why numbers can be added and subtracted while maintaining the integrity of the grid.

    Making the program code truly accessible would likely require much more fundamentally transformative refactoring. For example, we could keep the structure of the game map in one location, and store the locations of the robot and the boxes in some separate data structure. The downside of this would be that this would likely result in a lot more code, and the internal structure of the game would become much more complicated.

    -

    Refactoring and code quality is a subject for some subsequent courses, such as Software Development Methods and Software Engineering.

    You have reached the end of this section! Continue to the next section:

    You can check your current points from the blue blob in the bottom-right corner of the page.

    \ No newline at end of file +

    Refactoring and code quality is a subject for some subsequent courses, such as Software Development Methods and Software Engineering.

    You have reached the end of this section! Continue to the next section:

    You can check your current points from the blue blob in the bottom-right corner of the page.

    \ No newline at end of file diff --git a/part-14/3-finishing-the-game/index.html b/part-14/3-finishing-the-game/index.html index 1b44348ac..3c535d6fe 100644 --- a/part-14/3-finishing-the-game/index.html +++ b/part-14/3-finishing-the-game/index.html @@ -248,4 +248,4 @@

    Your game on GitHub?GitHub is a popular place for many kinds of programming projects. It can be used to store the source code and other materials of all your own programming projects as well, and your program will then be maintained through git version control, and it can be easily shared with others. You will become very familiar with git and GitHub if you continue on to other mooc.fi programming courses.

    How many moves are required?

    The grid in this game is quite small, but the game is not all that easy. The first challenge is simply passing the game, but the next stage is trying to do so with as few moves as possible. How short is the shortest path to a solution?

    -

    Looking for the shortest possible solution is not an easy task at all, but there are computational solutions to this as well. They are one of the subjects of the Data Structures and Algorithms course.

    You have reached the end of this section! Continue to the next section:

    You can check your current points from the blue blob in the bottom-right corner of the page.

    \ No newline at end of file +

    Looking for the shortest possible solution is not an easy task at all, but there are computational solutions to this as well. They are one of the subjects of the Data Structures and Algorithms course.

    You have reached the end of this section! Continue to the next section:

    You can check your current points from the blue blob in the bottom-right corner of the page.

    \ No newline at end of file diff --git a/part-14/4-your-own-game/index.html b/part-14/4-your-own-game/index.html index f730550db..51f689777 100644 --- a/part-14/4-your-own-game/index.html +++ b/part-14/4-your-own-game/index.html @@ -255,9 +255,9 @@

    Peer reviewHow well is it programmed? Is the code readable, and does it make appropriate use of classes and functions?

    A good review usually points out both good features and some suggestions for improvements.

    -
    Loading...
    :
    Loading...

    Log in to view the quiz

    +
    Loading...
    :
    Loading...

    Log in to view the quiz

    Questionnaires to finish off

    First, please respond to a quick questionnaire on this part of the course.

    -
    Loading...
    :
    Loading...

    Log in to view the quiz

    +
    Loading...
    :
    Loading...

    Log in to view the quiz

    Please also respond to the course feedback questionnaire. The questionnaire results help us improve the course.

    -
    Loading...
    :
    Loading...

    Log in to view the quiz

    You have reached the end of this section!

    You can check your current points from the blue blob in the bottom-right corner of the page.

    \ No newline at end of file +
    Loading...
    :
    Loading...

    Log in to view the quiz

    You have reached the end of this section!

    You can check your current points from the blue blob in the bottom-right corner of the page.

    \ No newline at end of file diff --git a/part-14/index.html b/part-14/index.html index bb416ea52..a9c28bc6b 100644 --- a/part-14/index.html +++ b/part-14/index.html @@ -152,4 +152,4 @@ } })
    \ No newline at end of file +
    Loading...
    \ No newline at end of file diff --git a/part-2/1-programming-terminology/index.html b/part-2/1-programming-terminology/index.html index 44675d0fc..f29e4a69a 100644 --- a/part-2/1-programming-terminology/index.html +++ b/part-2/1-programming-terminology/index.html @@ -309,4 +309,4 @@ Daily wages: 120.0 euros

    It seems the value stored in daily_wages is correct at first: hourly_wage = 20.0 and hours = 6, and 20.0 * 6 = 120.0. The command which is supposed to double the figure doesn't do so, however, so there must be a problem with the command. And indeed the command

    daily_wages * 2

    does double the value, but it doesn't store the new value anywhere. Let's change it so it also stores the new value:

    daily_wages *= 2

    Running the program again reveals that the printout at the end is now also correct:

    Sample output

    condition: True wages before: 120 wages after doubling: 240 -Daily wages: 240.0 euros

    When the program has been fixed, remember to remove all debugging print statements and other code added for debugging purposes.

    This example was quite simple, and in such a short program one could probably figure out the bugs just by reading the code carefully. However, using debugging print statements is often a quick way to get a feeling for where the problem might lie. Print statements can be used to figure out which parts of the program seem to work correctly, so bug tracking efforts can be concentrated on the sections of code which are the most likely culprits.

    Debugging print statements are only one tool for debugging programs. We will come back to this subject later on during this course. You should now get into the habit of using debugging print statements to look for mistakes in your code. Programming professionals cannot get by without using them, so it is a very useful tool for beginners as well.

    You have reached the end of this section! Continue to the next section:

    You can check your current points from the blue blob in the bottom-right corner of the page.

    \ No newline at end of file +Daily wages: 240.0 euros

    When the program has been fixed, remember to remove all debugging print statements and other code added for debugging purposes.

    This example was quite simple, and in such a short program one could probably figure out the bugs just by reading the code carefully. However, using debugging print statements is often a quick way to get a feeling for where the problem might lie. Print statements can be used to figure out which parts of the program seem to work correctly, so bug tracking efforts can be concentrated on the sections of code which are the most likely culprits.

    Debugging print statements are only one tool for debugging programs. We will come back to this subject later on during this course. You should now get into the habit of using debugging print statements to look for mistakes in your code. Programming professionals cannot get by without using them, so it is a very useful tool for beginners as well.

    You have reached the end of this section! Continue to the next section:

    You can check your current points from the blue blob in the bottom-right corner of the page.

    \ No newline at end of file diff --git a/part-2/2-else-elif/index.html b/part-2/2-else-elif/index.html index 891d8b81c..6196546ac 100644 --- a/part-2/2-else-elif/index.html +++ b/part-2/2-else-elif/index.html @@ -261,4 +261,4 @@ It's Hogmanay Thanks and bye.

    Notice the previous example has no else branch. If the user inputs a date which is not mentioned in any of the if or elif branches, or inputs a date in a different format, none of the three branches of the conditional statement is executed.

    Sample output

    Holiday calendar What is the date today? Dec 25 -Thanks and bye.

    You have reached the end of this section! Continue to the next section:

    You can check your current points from the blue blob in the bottom-right corner of the page.

    \ No newline at end of file +Thanks and bye.

    You have reached the end of this section! Continue to the next section:

    You can check your current points from the blue blob in the bottom-right corner of the page.

    \ No newline at end of file diff --git a/part-2/3-combining-conditions/index.html b/part-2/3-combining-conditions/index.html index 5d9798b83..e0e61bf7e 100644 --- a/part-2/3-combining-conditions/index.html +++ b/part-2/3-combining-conditions/index.html @@ -284,4 +284,4 @@ elif number > 0 and number % 2 != 0: print("The number is odd") else: - print("The number is negative or zero")

    Neither approach is intrinsically better than the other, but in different situations one or the other may seem more logical. In this particular example most people tend to find the first version with nesting to be more intuitive.

    You have reached the end of this section! Continue to the next section:

    You can check your current points from the blue blob in the bottom-right corner of the page.

    \ No newline at end of file + print("The number is negative or zero")

    Neither approach is intrinsically better than the other, but in different situations one or the other may seem more logical. In this particular example most people tend to find the first version with nesting to be more intuitive.

    You have reached the end of this section! Continue to the next section:

    You can check your current points from the blue blob in the bottom-right corner of the page.

    \ No newline at end of file diff --git a/part-2/4-simple-loops/index.html b/part-2/4-simple-loops/index.html index 5d431bb72..5d839525e 100644 --- a/part-2/4-simple-loops/index.html +++ b/part-2/4-simple-loops/index.html @@ -357,4 +357,4 @@ attempts += 1 codes += code + ", " # ...

    The helper variable is initialized to an empty string, that is, a string with no characters in it:

    codes = ""

    With each iteration the string gets longer, as the code the user typed in is added, along with a comma:

        code = input("Please type in your PIN: ")
    -    codes += code + ", "

    If the user types in the codes 1111 2222 1234, at the end of the program's execution the value of codes would be

    Sample output

    1111, 2222, 1234,

    Please respond to a quick questionnaire on this week's materials.

    Loading...
    :
    Loading...

    Log in to view the quiz

    You have reached the end of this section!

    You can check your current points from the blue blob in the bottom-right corner of the page.

    \ No newline at end of file + codes += code + ", "

    If the user types in the codes 1111 2222 1234, at the end of the program's execution the value of codes would be

    Sample output

    1111, 2222, 1234,

    Please respond to a quick questionnaire on this week's materials.

    Loading...
    :
    Loading...

    Log in to view the quiz

    You have reached the end of this section!

    You can check your current points from the blue blob in the bottom-right corner of the page.

    \ No newline at end of file diff --git a/part-2/index.html b/part-2/index.html index 74dcd8df5..4953a9ed3 100644 --- a/part-2/index.html +++ b/part-2/index.html @@ -152,4 +152,4 @@ } })
    \ No newline at end of file +
    Loading...
    \ No newline at end of file diff --git a/part-3/1-loops-with-conditions/index.html b/part-3/1-loops-with-conditions/index.html index f0a5ff5ea..c1a995c6a 100644 --- a/part-3/1-loops-with-conditions/index.html +++ b/part-3/1-loops-with-conditions/index.html @@ -293,4 +293,4 @@ verdict += f"the grade {grade} " verdict += f"from the course {course}" -print(verdict)
    Sample output

    You have received the grade 4 from the course Introduction to Programming

    In the previous exercise you calculated the sum of consecutive numbers by always adding a new value inside a loop.

    The exact same idea applies to strings as well: you can add new parts to a string within a loop. This technique should be useful in the following exercise.

    You have reached the end of this section! Continue to the next section:

    You can check your current points from the blue blob in the bottom-right corner of the page.

    \ No newline at end of file +print(verdict)
    Sample output

    You have received the grade 4 from the course Introduction to Programming

    In the previous exercise you calculated the sum of consecutive numbers by always adding a new value inside a loop.

    The exact same idea applies to strings as well: you can add new parts to a string within a loop. This technique should be useful in the following exercise.

    You have reached the end of this section! Continue to the next section:

    You can check your current points from the blue blob in the bottom-right corner of the page.

    \ No newline at end of file diff --git a/part-3/2-working-with-strings/index.html b/part-3/2-working-with-strings/index.html index 6d48a8463..081404b34 100644 --- a/part-3/2-working-with-strings/index.html +++ b/part-3/2-working-with-strings/index.html @@ -337,4 +337,4 @@ Not found What are you looking for? pen Found it at the index 3 -...

    You have reached the end of this section! Continue to the next section:

    You can check your current points from the blue blob in the bottom-right corner of the page.

    \ No newline at end of file +...

    You have reached the end of this section! Continue to the next section:

    You can check your current points from the blue blob in the bottom-right corner of the page.

    \ No newline at end of file diff --git a/part-3/3-more-loops/index.html b/part-3/3-more-loops/index.html index a4e1cd4c0..d20650c50 100644 --- a/part-3/3-more-loops/index.html +++ b/part-3/3-more-loops/index.html @@ -315,4 +315,4 @@ 0 1 2 3 0 1 2 0 1 -0

    In this program the outer loop uses the helper variable number, which decreases by 1 with each iteration until it reaches 0. The helper variable i is set to 0 just before the inner loop is entered, each time the outer loop repeats.

    The inner loop uses the helper variable i, which increases by 1 with each iteration of the inner loop. The inner loop repeats until i is equal to number, and prints out each value of i on the same line, separated by a space character. When the inner loop finishes, the print command in the outer loop starts a new line.

    Now remember that with each iteration of the outer loop the value of number decreases, so the amount of times the inner loop repeats also decreases. With each repetition the line of numbers gets shorter, and thus we get the pyramid shape.

    Nested loops can get confusing fast, but understanding the way they work is essential. You may well find the Python Tutor visualisation tool helpful in understanding how this example works. Copy the above code into the code window of the tool and follow the formation of the printout and the changing values of the helper variables as the execution progresses.

    You have reached the end of this section! Continue to the next section:

    You can check your current points from the blue blob in the bottom-right corner of the page.

    \ No newline at end of file +0

    In this program the outer loop uses the helper variable number, which decreases by 1 with each iteration until it reaches 0. The helper variable i is set to 0 just before the inner loop is entered, each time the outer loop repeats.

    The inner loop uses the helper variable i, which increases by 1 with each iteration of the inner loop. The inner loop repeats until i is equal to number, and prints out each value of i on the same line, separated by a space character. When the inner loop finishes, the print command in the outer loop starts a new line.

    Now remember that with each iteration of the outer loop the value of number decreases, so the amount of times the inner loop repeats also decreases. With each repetition the line of numbers gets shorter, and thus we get the pyramid shape.

    Nested loops can get confusing fast, but understanding the way they work is essential. You may well find the Python Tutor visualisation tool helpful in understanding how this example works. Copy the above code into the code window of the tool and follow the formation of the printout and the changing values of the helper variables as the execution progresses.

    You have reached the end of this section! Continue to the next section:

    You can check your current points from the blue blob in the bottom-right corner of the page.

    \ No newline at end of file diff --git a/part-3/4-defining-functions/index.html b/part-3/4-defining-functions/index.html index 52a6a1a2c..ca268b60c 100644 --- a/part-3/4-defining-functions/index.html +++ b/part-3/4-defining-functions/index.html @@ -275,4 +275,4 @@ hello("Steve") hello("Betty")
    Sample output

    Hello Betty -Hello Betty

    No matter how many different arguments we call the function with, it will always print out the value "Betty" stored in the global variable.

    Please respond to a quick questionnaire on this week's materials.

    Loading...
    :
    Loading...

    Log in to view the quiz

    You have reached the end of this section!

    You can check your current points from the blue blob in the bottom-right corner of the page.

    \ No newline at end of file +Hello Betty

    No matter how many different arguments we call the function with, it will always print out the value "Betty" stored in the global variable.

    Please respond to a quick questionnaire on this week's materials.

    Loading...
    :
    Loading...

    Log in to view the quiz

    You have reached the end of this section!

    You can check your current points from the blue blob in the bottom-right corner of the page.

    \ No newline at end of file diff --git a/part-3/index.html b/part-3/index.html index 5f14463f3..0a8c5eedb 100644 --- a/part-3/index.html +++ b/part-3/index.html @@ -152,4 +152,4 @@ } })
    \ No newline at end of file +
    Loading...
    \ No newline at end of file diff --git a/part-4/1-vscode/index.html b/part-4/1-vscode/index.html index 3aea4a612..0b3cfd4e9 100644 --- a/part-4/1-vscode/index.html +++ b/part-4/1-vscode/index.html @@ -313,4 +313,4 @@ 4 1 9 -

    You can include several breakpoints in your program code. When execution has halted, you can start it again by clicking on the blue triangle. Execution proceeds until it reaches the next breakpoint.

    The built-in visual debugger is a good alternative to debugging print statements. It is up to you which you choose to employ more in the future. Each programmer has their own preferences, but it's always a good idea to try different options before settling on any single solution.

    You have reached the end of this section! Continue to the next section:

    You can check your current points from the blue blob in the bottom-right corner of the page.

    \ No newline at end of file +

    You can include several breakpoints in your program code. When execution has halted, you can start it again by clicking on the blue triangle. Execution proceeds until it reaches the next breakpoint.

    The built-in visual debugger is a good alternative to debugging print statements. It is up to you which you choose to employ more in the future. Each programmer has their own preferences, but it's always a good idea to try different options before settling on any single solution.

    You have reached the end of this section! Continue to the next section:

    You can check your current points from the blue blob in the bottom-right corner of the page.

    \ No newline at end of file diff --git a/part-4/2-more-functions/index.html b/part-4/2-more-functions/index.html index 2c68a4ffc..08f5ada41 100644 --- a/part-4/2-more-functions/index.html +++ b/part-4/2-more-functions/index.html @@ -322,4 +322,4 @@ print(message) times -= 1

    This tells anyone using the function that the argument stored in message is supposed to be a string, and the argument stored in times is supposed to be an integer.

    Similarly, the return value of a function can be hinted at in the function definition:

    def ask_for_name() -> str:
         name = input("Mikä on nimesi? ")
    -    return name

    This tells the user of the function that the function is supposed to return a string.

    NB: Type hinting is literally just hinting about the type of the argument or the return value. It is not a guarantee of type, and definitely not a safeguard against type errors. If a function receives an argument or returns a value of the wrong type, the function is still executed, but it might not work correctly.

    You have reached the end of this section! Continue to the next section:

    You can check your current points from the blue blob in the bottom-right corner of the page.

    \ No newline at end of file + return name

    This tells the user of the function that the function is supposed to return a string.

    NB: Type hinting is literally just hinting about the type of the argument or the return value. It is not a guarantee of type, and definitely not a safeguard against type errors. If a function receives an argument or returns a value of the wrong type, the function is still executed, but it might not work correctly.

    You have reached the end of this section! Continue to the next section:

    You can check your current points from the blue blob in the bottom-right corner of the page.

    \ No newline at end of file diff --git a/part-4/3-lists/index.html b/part-4/3-lists/index.html index 1a44ae68d..0f288719c 100644 --- a/part-4/3-lists/index.html +++ b/part-4/3-lists/index.html @@ -368,4 +368,4 @@ weights = input_numbers() print("Heights:") -heights = input_numbers()
    Loading
    Loading
    Loading

    There are many more ways to use lists in Python. The Python documentation is a good place to start if you want to know more.

    You have reached the end of this section! Continue to the next section:

    You can check your current points from the blue blob in the bottom-right corner of the page.

    \ No newline at end of file +heights = input_numbers()
    Loading
    Loading
    Loading

    There are many more ways to use lists in Python. The Python documentation is a good place to start if you want to know more.

    You have reached the end of this section! Continue to the next section:

    You can check your current points from the blue blob in the bottom-right corner of the page.

    \ No newline at end of file diff --git a/part-4/4-definite-iteration/index.html b/part-4/4-definite-iteration/index.html index cb21037d8..f32f640d0 100644 --- a/part-4/4-definite-iteration/index.html +++ b/part-4/4-definite-iteration/index.html @@ -251,4 +251,4 @@ if item is better than best: best = item -# We now have the best one figured out!

    The details of the final program code depend on the type of the items in the list, and also on the criteria for choosing the best (or worst) item. Sometimes you may need more than one helper variable.

    Let's practice this method a little.

    Loading
    Loading
    Loading
    You have reached the end of this section! Continue to the next section:

    You can check your current points from the blue blob in the bottom-right corner of the page.

    \ No newline at end of file +# We now have the best one figured out!

    The details of the final program code depend on the type of the items in the list, and also on the criteria for choosing the best (or worst) item. Sometimes you may need more than one helper variable.

    Let's practice this method a little.

    Loading
    Loading
    Loading
    You have reached the end of this section! Continue to the next section:

    You can check your current points from the blue blob in the bottom-right corner of the page.

    \ No newline at end of file diff --git a/part-4/5-print-statement-formatting/index.html b/part-4/5-print-statement-formatting/index.html index ec4fb66ae..d733f6d68 100644 --- a/part-4/5-print-statement-formatting/index.html +++ b/part-4/5-print-statement-formatting/index.html @@ -206,4 +206,4 @@ age = 48 city = "Palo Alto" greeting = f"Hi {name}, you are {age} years of age" -print(greeting + f", and you live in {city}")
    Sample output

    Hi Larry, you are 48 years of age, and you live in Palo Alto

    You can think of an f-string as a sort of function, which creates a normal string based on the "arguments" within the curly brackets.

    Loading
    You have reached the end of this section! Continue to the next section:

    You can check your current points from the blue blob in the bottom-right corner of the page.

    \ No newline at end of file +print(greeting + f", and you live in {city}")
    Sample output

    Hi Larry, you are 48 years of age, and you live in Palo Alto

    You can think of an f-string as a sort of function, which creates a normal string based on the "arguments" within the curly brackets.

    Loading
    You have reached the end of this section! Continue to the next section:

    You can check your current points from the blue blob in the bottom-right corner of the page.

    \ No newline at end of file diff --git a/part-4/6-strings-and-lists/index.html b/part-4/6-strings-and-lists/index.html index 61904b7b9..7f1d8fe62 100644 --- a/part-4/6-strings-and-lists/index.html +++ b/part-4/6-strings-and-lists/index.html @@ -338,4 +338,4 @@ print(analysis_result) # run the main function -main()
    Loading

    Please respond to a quick questionnaire on this week's materials.

    Loading...
    :
    Loading...

    Log in to view the quiz

    You have reached the end of this section!

    You can check your current points from the blue blob in the bottom-right corner of the page.

    \ No newline at end of file +main()
    Loading

    Please respond to a quick questionnaire on this week's materials.

    Loading...
    :
    Loading...

    Log in to view the quiz

    You have reached the end of this section!

    You can check your current points from the blue blob in the bottom-right corner of the page.

    \ No newline at end of file diff --git a/part-4/index.html b/part-4/index.html index ce3515ade..e32980c5a 100644 --- a/part-4/index.html +++ b/part-4/index.html @@ -152,4 +152,4 @@ } })
    \ No newline at end of file +
    Loading...
    \ No newline at end of file diff --git a/part-5/1-more-lists/index.html b/part-5/1-more-lists/index.html index 9792087e3..000e118cb 100644 --- a/part-5/1-more-lists/index.html +++ b/part-5/1-more-lists/index.html @@ -422,4 +422,4 @@ _ _ 7 8 _ 3 9 _ _ _ _ 1 _ _ _ _ _ 3 3 _ _ _ _ _ _ _ 2 -

    Any common game with a gameboard layout can be modelled in a similar fashion. Among others, chess, Minesweeper, Battleship or Mastermind are all based on a two-dimensional grid. For sudoku, it is natural to use numbers to represent the game state, but for other games, different methods may be better.

    Loading
    Loading
    Loading
    Loading
    Loading
    You have reached the end of this section! Continue to the next section:

    You can check your current points from the blue blob in the bottom-right corner of the page.

    \ No newline at end of file +

    Any common game with a gameboard layout can be modelled in a similar fashion. Among others, chess, Minesweeper, Battleship or Mastermind are all based on a two-dimensional grid. For sudoku, it is natural to use numbers to represent the game state, but for other games, different methods may be better.

    Loading
    Loading
    Loading
    Loading
    Loading
    You have reached the end of this section! Continue to the next section:

    You can check your current points from the blue blob in the bottom-right corner of the page.

    \ No newline at end of file diff --git a/part-5/2-references/index.html b/part-5/2-references/index.html index 4387dea70..0129f4d9f 100644 --- a/part-5/2-references/index.html +++ b/part-5/2-references/index.html @@ -379,4 +379,4 @@ numbers = [1, 4, 2, 5, 3, 6, 4, 7] print(second_smallest(numbers)) print(numbers)
    Sample output

    2 -[1, 4, 2, 5, 3, 6, 4, 7]

    The function sorted returns a new, sorted copy of the list, so looking for the second smallest item no longer messes with the order of the original list.

    It is generally considered a good programming practice to avoid causing side effects with functions. Side effects can make it more difficult to verify that the program functions as intended in all situations.

    Functions free of side effects are also called pure functions. Especially when adhering to a functional programming style, this is a common ideal to follow. We will explore this topic further in Advanced Course in Programming, which is the course following this one.

    You have reached the end of this section! Continue to the next section:

    You can check your current points from the blue blob in the bottom-right corner of the page.

    \ No newline at end of file +[1, 4, 2, 5, 3, 6, 4, 7]

    The function sorted returns a new, sorted copy of the list, so looking for the second smallest item no longer messes with the order of the original list.

    It is generally considered a good programming practice to avoid causing side effects with functions. Side effects can make it more difficult to verify that the program functions as intended in all situations.

    Functions free of side effects are also called pure functions. Especially when adhering to a functional programming style, this is a common ideal to follow. We will explore this topic further in Advanced Course in Programming, which is the course following this one.

    You have reached the end of this section! Continue to the next section:

    You can check your current points from the blue blob in the bottom-right corner of the page.

    \ No newline at end of file diff --git a/part-5/3-dictionary/index.html b/part-5/3-dictionary/index.html index 5d2815d89..4c73fbceb 100644 --- a/part-5/3-dictionary/index.html +++ b/part-5/3-dictionary/index.html @@ -325,4 +325,4 @@ print("The average height is", combined_height / len(people))
    Sample output

    Pippa Python Peter Pythons Pedro Python -The average height is 173.0

    Loading
    Loading

    At this point in the course, you can choose to participate in a research study related to learning programming. Participation is voluntary and individual participants cannot be identified from the data gathered in the study. You can freely quit the experiment at any point. Click here to begin the study!

    You have reached the end of this section! Continue to the next section:

    You can check your current points from the blue blob in the bottom-right corner of the page.

    \ No newline at end of file +The average height is 173.0

    Loading
    Loading

    At this point in the course, you can choose to participate in a research study related to learning programming. Participation is voluntary and individual participants cannot be identified from the data gathered in the study. You can freely quit the experiment at any point. Click here to begin the study!

    You have reached the end of this section! Continue to the next section:

    You can check your current points from the blue blob in the bottom-right corner of the page.

    \ No newline at end of file diff --git a/part-5/4-tuple/index.html b/part-5/4-tuple/index.html index 79668679f..a6863cba8 100644 --- a/part-5/4-tuple/index.html +++ b/part-5/4-tuple/index.html @@ -235,4 +235,4 @@ print("key:", key) print("value:", value)

    Tuples are at work here, too. The method my_dictionary.items() returns each key-value pair as a tuple, where the first item is the key and the second item is the value.

    Another common use case for tuples is swapping the values of two variables:

    number1, number2 = number2, number1

    The assignment statement above swaps the values stored in the variables number1 and number2. The result is identical to what is achieved with the following bit of code, using a helper variable:

    helper_var = number1
     number1 = number2
    -number2 = helper_var
    Loading
    Loading

    Please respond to a quick questionnaire on this week's materials.

    Loading...
    :
    Loading...

    Log in to view the quiz

    You have reached the end of this section!

    You can check your current points from the blue blob in the bottom-right corner of the page.

    \ No newline at end of file +number2 = helper_var
    Loading
    Loading

    Please respond to a quick questionnaire on this week's materials.

    Loading...
    :
    Loading...

    Log in to view the quiz

    You have reached the end of this section!

    You can check your current points from the blue blob in the bottom-right corner of the page.

    \ No newline at end of file diff --git a/part-5/index.html b/part-5/index.html index 86df31470..9bcd67780 100644 --- a/part-5/index.html +++ b/part-5/index.html @@ -152,4 +152,4 @@ } })
    \ No newline at end of file +
    Loading...
    \ No newline at end of file diff --git a/part-6/1-reading-files/index.html b/part-6/1-reading-files/index.html index e25d4b1d2..464fb5fe3 100644 --- a/part-6/1-reading-files/index.html +++ b/part-6/1-reading-files/index.html @@ -423,4 +423,4 @@ '080488-123X': 3300, '290274-044S': 4350, '010479-007Z': 2500 -}

    The for loop at the end of the program combines the names of the employees with their respective salaries.

    The program also takes care of situations where the employee's pic is not present in the salary file.

    Remember, the order in which items are stored in a dictionary does not matter, as the keys are processed based on hash values.

    Loading
    Loading
    Loading
    Loading
    Loading
    Loading
    You have reached the end of this section! Continue to the next section:

    You can check your current points from the blue blob in the bottom-right corner of the page.

    \ No newline at end of file +}

    The for loop at the end of the program combines the names of the employees with their respective salaries.

    The program also takes care of situations where the employee's pic is not present in the salary file.

    Remember, the order in which items are stored in a dictionary does not matter, as the keys are processed based on hash values.

    Loading
    Loading
    Loading
    Loading
    Loading
    Loading
    You have reached the end of this section! Continue to the next section:

    You can check your current points from the blue blob in the bottom-right corner of the page.

    \ No newline at end of file diff --git a/part-6/2-writing-files/index.html b/part-6/2-writing-files/index.html index 70ad26fb2..84d647ad0 100644 --- a/part-6/2-writing-files/index.html +++ b/part-6/2-writing-files/index.html @@ -278,4 +278,4 @@ weekly_points = read_weekly_points("weekly_points.csv") print(get_grade("Paula", weekly_points)) -
    Sample data

    3

    If we determine a certain functionality in the program needs fixing, in a well designed program the change will affect only some select sections of code, and it will be easier to determine where the changes should be made. For example, if we wanted to change the grade boundaries, we'd only need to implement the change in the function for determining the grade, and it would work also in all the other functions utilizing this function. If the code for this single functionality was implemented in multiple places, there would be a definite risk that we would not remember to change all the instances when changing the functionality.

    Loading
    Loading
    Loading
    You have reached the end of this section! Continue to the next section:

    You can check your current points from the blue blob in the bottom-right corner of the page.

    \ No newline at end of file +
    Sample data

    3

    If we determine a certain functionality in the program needs fixing, in a well designed program the change will affect only some select sections of code, and it will be easier to determine where the changes should be made. For example, if we wanted to change the grade boundaries, we'd only need to implement the change in the function for determining the grade, and it would work also in all the other functions utilizing this function. If the code for this single functionality was implemented in multiple places, there would be a definite risk that we would not remember to change all the instances when changing the functionality.

    Loading
    Loading
    Loading
    You have reached the end of this section! Continue to the next section:

    You can check your current points from the blue blob in the bottom-right corner of the page.

    \ No newline at end of file diff --git a/part-6/3-errors/index.html b/part-6/3-errors/index.html index 7d32e8249..2d08d6ff9 100644 --- a/part-6/3-errors/index.html +++ b/part-6/3-errors/index.html @@ -293,4 +293,4 @@ print(factorial(-1)) File "test.py", line 3, in factorial raise ValueError("The input was negative: " + str(n)) -ValueError: The input was negative: -1
    Loading
    Loading
    You have reached the end of this section! Continue to the next section:

    You can check your current points from the blue blob in the bottom-right corner of the page.

    \ No newline at end of file +ValueError: The input was negative: -1
    Loading
    Loading
    You have reached the end of this section! Continue to the next section:

    You can check your current points from the blue blob in the bottom-right corner of the page.

    \ No newline at end of file diff --git a/part-6/4-scope-of-variables/index.html b/part-6/4-scope-of-variables/index.html index e3c8ff7e2..547fe9558 100644 --- a/part-6/4-scope-of-variables/index.html +++ b/part-6/4-scope-of-variables/index.html @@ -306,4 +306,4 @@ print(analysis_result) # run the main function -main()

    Please respond to a quick questionnaire on this week's materials.

    Loading...
    :
    Loading...

    Log in to view the quiz

    You have reached the end of this section!

    You can check your current points from the blue blob in the bottom-right corner of the page.

    \ No newline at end of file +main()

    Please respond to a quick questionnaire on this week's materials.

    Loading...
    :
    Loading...

    Log in to view the quiz

    You have reached the end of this section!

    You can check your current points from the blue blob in the bottom-right corner of the page.

    \ No newline at end of file diff --git a/part-6/index.html b/part-6/index.html index e3a94d017..891e656ec 100644 --- a/part-6/index.html +++ b/part-6/index.html @@ -152,4 +152,4 @@ } })
    \ No newline at end of file +
    Loading...
    \ No newline at end of file diff --git a/part-7/1-modules/index.html b/part-7/1-modules/index.html index d371304ce..ea3db4e35 100644 --- a/part-7/1-modules/index.html +++ b/part-7/1-modules/index.html @@ -230,4 +230,4 @@
  • https://docs.python.org/3/library/math.html
  • We can also have a look at the contents of the module with the function dir:

    import math
     
    -print(dir(math))

    The function returns a list of names defined by the module. These may be, for example, names of classes, constant values or functions:

    Sample output

    ['__doc__', '__name__', '__package__', 'acos', 'acosh', 'asin', 'asinh', 'atan', 'atan2', 'atanh', 'ceil', 'copysign', 'cos', 'cosh', 'degrees', 'e', 'erf', 'erfc', 'exp', 'expm1', 'fabs', 'factorial', 'floor', 'fmod', 'frexp', 'fsum', 'gamma', 'hypot', 'isinf', 'isnan', 'ldexp', 'lgamma', 'log', 'log10', 'log1p', 'modf', 'pi', 'pow', 'radians', 'sin', 'sinh', 'sqrt', 'tan', 'tanh', 'trunc']

    Loading
    Loading
    You have reached the end of this section! Continue to the next section:

    You can check your current points from the blue blob in the bottom-right corner of the page.

    \ No newline at end of file +print(dir(math))

    The function returns a list of names defined by the module. These may be, for example, names of classes, constant values or functions:

    Sample output

    ['__doc__', '__name__', '__package__', 'acos', 'acosh', 'asin', 'asinh', 'atan', 'atan2', 'atanh', 'ceil', 'copysign', 'cos', 'cosh', 'degrees', 'e', 'erf', 'erfc', 'exp', 'expm1', 'fabs', 'factorial', 'floor', 'fmod', 'frexp', 'fsum', 'gamma', 'hypot', 'isinf', 'isnan', 'ldexp', 'lgamma', 'log', 'log10', 'log1p', 'modf', 'pi', 'pow', 'radians', 'sin', 'sinh', 'sqrt', 'tan', 'tanh', 'trunc']

    Loading
    Loading
    You have reached the end of this section! Continue to the next section:

    You can check your current points from the blue blob in the bottom-right corner of the page.

    \ No newline at end of file diff --git a/part-7/2-randomness/index.html b/part-7/2-randomness/index.html index 31dd4a910..6a9d57551 100644 --- a/part-7/2-randomness/index.html +++ b/part-7/2-randomness/index.html @@ -231,4 +231,4 @@ seed(1337) # this will always produce the same "random" number -print(randint(1, 100))

    If we have functions which rely on randomization, and we set seed value, the function will produce the same result each time it is executed. The result may be different with different Python versions, but in essence randomness is lost by setting a seed value. This can be a useful feature when testing a program, for example.

    Loading
    Loading
    Loading
    Loading
    You have reached the end of this section! Continue to the next section:

    You can check your current points from the blue blob in the bottom-right corner of the page.

    \ No newline at end of file +print(randint(1, 100))

    If we have functions which rely on randomization, and we set seed value, the function will produce the same result each time it is executed. The result may be different with different Python versions, but in essence randomness is lost by setting a seed value. This can be a useful feature when testing a program, for example.

    Loading
    Loading
    Loading
    Loading
    You have reached the end of this section! Continue to the next section:

    You can check your current points from the blue blob in the bottom-right corner of the page.

    \ No newline at end of file diff --git a/part-7/3-times-and-dates/index.html b/part-7/3-times-and-dates/index.html index 626c2b5a4..a3f5046e0 100644 --- a/part-7/3-times-and-dates/index.html +++ b/part-7/3-times-and-dates/index.html @@ -282,4 +282,4 @@ print("You were born in the previous millennium") else: print("You were born during this millennium")
    Sample output

    Please type in your birthday in the format dd.mm.yyyy: 5.11.1986 -You were born in the previous millennium

    Loading
    You have reached the end of this section! Continue to the next section:

    You can check your current points from the blue blob in the bottom-right corner of the page.

    \ No newline at end of file +You were born in the previous millennium

    Loading
    You have reached the end of this section! Continue to the next section:

    You can check your current points from the blue blob in the bottom-right corner of the page.

    \ No newline at end of file diff --git a/part-7/4-data-processing/index.html b/part-7/4-data-processing/index.html index 478309de8..ff6618dee 100644 --- a/part-7/4-data-processing/index.html +++ b/part-7/4-data-processing/index.html @@ -227,4 +227,4 @@
  • https://docs.python.org/3/library/
  • In addition to the standard library, the internet is full of freely available Python modules for different purposes. Some commonly used modules are listed here:

    Loading
    You have reached the end of this section! Continue to the next section:

    You can check your current points from the blue blob in the bottom-right corner of the page.

    \ No newline at end of file +
    Loading
    You have reached the end of this section! Continue to the next section:

    You can check your current points from the blue blob in the bottom-right corner of the page.

    \ No newline at end of file diff --git a/part-7/5-creating-modules/index.html b/part-7/5-creating-modules/index.html index 2a5996ed2..c49e970c8 100644 --- a/part-7/5-creating-modules/index.html +++ b/part-7/5-creating-modules/index.html @@ -292,4 +292,4 @@ print(words.last_word(my_string)) print(words.number_of_words(my_string))
    Sample output

    Sheila seashore -6

    In the exercises on this course, whenever you were asked to write functions, you were usually also expected to wrap test cases in an if __name__ == "__main__" block exactly like the one above. Now you know why.

    Loading

    Please respond to a quick questionnaire on this week's materials.

    Loading...
    :
    Loading...

    Log in to view the quiz

    You have reached the end of this section! Continue to the next section:

    You can check your current points from the blue blob in the bottom-right corner of the page.

    \ No newline at end of file +6

    In the exercises on this course, whenever you were asked to write functions, you were usually also expected to wrap test cases in an if __name__ == "__main__" block exactly like the one above. Now you know why.

    Loading

    Please respond to a quick questionnaire on this week's materials.

    Loading...
    :
    Loading...

    Log in to view the quiz

    You have reached the end of this section! Continue to the next section:

    You can check your current points from the blue blob in the bottom-right corner of the page.

    \ No newline at end of file diff --git a/part-7/6-more-features/index.html b/part-7/6-more-features/index.html index 7abf1fb18..31bebd824 100644 --- a/part-7/6-more-features/index.html +++ b/part-7/6-more-features/index.html @@ -234,4 +234,4 @@ print("The sum of the arguments is", sum(my_args)) testing(1, 2, 3, 4, 5)
    Sample output

    You passed 5 arguments -The sum of the arguments is 15

    Loading

    Please respond to the course feedback questionnaire. The questionnaire results help us improve the course.

    Loading...
    :
    Loading...

    Log in to view the quiz

    You have reached the end of this section!

    You can check your current points from the blue blob in the bottom-right corner of the page.

    \ No newline at end of file +The sum of the arguments is 15

    Loading

    Please respond to the course feedback questionnaire. The questionnaire results help us improve the course.

    Loading...
    :
    Loading...

    Log in to view the quiz

    You have reached the end of this section!

    You can check your current points from the blue blob in the bottom-right corner of the page.

    \ No newline at end of file diff --git a/part-7/index.html b/part-7/index.html index dbb444250..d4b61e27f 100644 --- a/part-7/index.html +++ b/part-7/index.html @@ -152,4 +152,4 @@ } })
    \ No newline at end of file +
    Loading...
    \ No newline at end of file diff --git a/part-8/1-objects-and-methods/index.html b/part-8/1-objects-and-methods/index.html index 0524aac87..57722808e 100644 --- a/part-8/1-objects-and-methods/index.html +++ b/part-8/1-objects-and-methods/index.html @@ -260,4 +260,4 @@ my_list.pop(0) print(my_list)
    Sample output

    [1, 2, 3, 5, 1] -[2, 3, 5, 1]

    Loading
    Loading
    You have reached the end of this section! Continue to the next section:

    You can check your current points from the blue blob in the bottom-right corner of the page.

    \ No newline at end of file +[2, 3, 5, 1]

    Loading
    Loading
    You have reached the end of this section! Continue to the next section:

    You can check your current points from the blue blob in the bottom-right corner of the page.

    \ No newline at end of file diff --git a/part-8/2-classes-and-objects/index.html b/part-8/2-classes-and-objects/index.html index af4455d89..e2f27d115 100644 --- a/part-8/2-classes-and-objects/index.html +++ b/part-8/2-classes-and-objects/index.html @@ -256,4 +256,4 @@ The month: 12

    The day of the week the date falls on is available through the method isoweekday:

    weekday = my_date.isoweekday()

    This is a method call, so there are parentheses after the name of the method. Leaving the parentheses out does not cause an error, but the results are weird:

    weekday =  my_date.isoweekday
     print("The day of the week:", weekday)
    Sample output

    The day of the week: <built-in method isoweekday of datetime.date object at 0x10ed66450>

    The month of a date object is a variable, so the value attached can be accessed with a reference.

    my_month = my_date.month

    Notice there are no parentheses here. Adding parentheses would cause an error:

    my_month = my_date.month()
    Sample output
    Traceback (most recent call last): File "", line 1, in -TypeError: 'int' object is not callable
    Loading
    Loading
    You have reached the end of this section! Continue to the next section:

    You can check your current points from the blue blob in the bottom-right corner of the page.

    \ No newline at end of file +TypeError: 'int' object is not callable
    Loading
    Loading
    You have reached the end of this section! Continue to the next section:

    You can check your current points from the blue blob in the bottom-right corner of the page.

    \ No newline at end of file diff --git a/part-8/3-defining-classes/index.html b/part-8/3-defining-classes/index.html index 861cbf34e..a6a941043 100644 --- a/part-8/3-defining-classes/index.html +++ b/part-8/3-defining-classes/index.html @@ -305,4 +305,4 @@ deposit_money_on_account(peters_account, 500) print(peters_account.balance)
    Sample output

    0 -500

    Loading
    Loading
    Loading
    You have reached the end of this section! Continue to the next section:

    You can check your current points from the blue blob in the bottom-right corner of the page.

    \ No newline at end of file +500

    Loading
    Loading
    Loading
    You have reached the end of this section! Continue to the next section:

    You can check your current points from the blue blob in the bottom-right corner of the page.

    \ No newline at end of file diff --git a/part-8/4-defining-methods/index.html b/part-8/4-defining-methods/index.html index ca55b24f2..eaf04bee0 100644 --- a/part-8/4-defining-methods/index.html +++ b/part-8/4-defining-methods/index.html @@ -342,4 +342,4 @@ self.balance += superbonus def __str__(self): - return f"BonusCard(name={self.name}, balance={self.balance})"
    Loading
    Loading
    You have reached the end of this section! Continue to the next section:

    You can check your current points from the blue blob in the bottom-right corner of the page.

    \ No newline at end of file + return f"BonusCard(name={self.name}, balance={self.balance})"
    Loading
    Loading
    You have reached the end of this section! Continue to the next section:

    You can check your current points from the blue blob in the bottom-right corner of the page.

    \ No newline at end of file diff --git a/part-8/5-more-examples-of-classes/index.html b/part-8/5-more-examples-of-classes/index.html index 72d6a7878..54f1495f2 100644 --- a/part-8/5-more-examples-of-classes/index.html +++ b/part-8/5-more-examples-of-classes/index.html @@ -282,4 +282,4 @@ date studying 1 -0

    Loading

    Please respond to a quick questionnaire on this week's materials.

    Loading...
    :
    Loading...

    Log in to view the quiz

    You have reached the end of this section!

    You can check your current points from the blue blob in the bottom-right corner of the page.

    \ No newline at end of file +0

    Loading

    Please respond to a quick questionnaire on this week's materials.

    Loading...
    :
    Loading...

    Log in to view the quiz

    You have reached the end of this section!

    You can check your current points from the blue blob in the bottom-right corner of the page.

    \ No newline at end of file diff --git a/part-8/index.html b/part-8/index.html index 3a1b0c96e..927acff68 100644 --- a/part-8/index.html +++ b/part-8/index.html @@ -152,4 +152,4 @@ } })
    \ No newline at end of file +
    Loading...
    \ No newline at end of file diff --git a/part-9/1-objects-and-references/index.html b/part-9/1-objects-and-references/index.html index ad7e4c79e..23b463d2a 100644 --- a/part-9/1-objects-and-references/index.html +++ b/part-9/1-objects-and-references/index.html @@ -544,4 +544,4 @@ # this would cause an error, as Person must be enclosed in quotation marks def older_than(self, another: Person): - return self.year_of_birth < another.year_of_birth:
    Loading
    You have reached the end of this section! Continue to the next section:

    You can check your current points from the blue blob in the bottom-right corner of the page.

    \ No newline at end of file + return self.year_of_birth < another.year_of_birth:
    Loading
    You have reached the end of this section! Continue to the next section:

    You can check your current points from the blue blob in the bottom-right corner of the page.

    \ No newline at end of file diff --git a/part-9/2-objects-as-attributes/index.html b/part-9/2-objects-as-attributes/index.html index 17f15b0b5..e14a44481 100644 --- a/part-9/2-objects-as-attributes/index.html +++ b/part-9/2-objects-as-attributes/index.html @@ -308,4 +308,4 @@ if player is not None: print(f"Goals by Charlie: {player.goals}") else: - print(f"Charlie doesn't play in Campus Allstars :(")
    Sample output

    Charlie doesn't play in Campus Allstars :(

    Loading
    You have reached the end of this section! Continue to the next section:

    You can check your current points from the blue blob in the bottom-right corner of the page.

    \ No newline at end of file + print(f"Charlie doesn't play in Campus Allstars :(")
    Sample output

    Charlie doesn't play in Campus Allstars :(

    Loading
    You have reached the end of this section! Continue to the next section:

    You can check your current points from the blue blob in the bottom-right corner of the page.

    \ No newline at end of file diff --git a/part-9/3-encapsulation/index.html b/part-9/3-encapsulation/index.html index 1cb3a1e31..5b3fa65a9 100644 --- a/part-9/3-encapsulation/index.html +++ b/part-9/3-encapsulation/index.html @@ -344,4 +344,4 @@
  • Today I ate porridge
  • Today I learned object oriented programming
  • Today I went to bed early
  • -
    Loading
    You have reached the end of this section! Continue to the next section:

    You can check your current points from the blue blob in the bottom-right corner of the page.

    \ No newline at end of file +
    Loading
    You have reached the end of this section! Continue to the next section:

    You can check your current points from the blue blob in the bottom-right corner of the page.

    \ No newline at end of file diff --git a/part-9/4-scope-of-methods/index.html b/part-9/4-scope-of-methods/index.html index 9f749c462..50161d0bf 100644 --- a/part-9/4-scope-of-methods/index.html +++ b/part-9/4-scope-of-methods/index.html @@ -246,4 +246,4 @@ print(hand1) hand2 = deck.deal(5) print(hand2)

    As the hands are randomly generated, the following is only an example of what could be printed out:

    Sample output

    [('spades', 7), ('spades', 11), ('hearts', 7), ('diamonds', 3), ('spades', 4)] -[('clubs', 8), ('spades', 12), ('diamonds', 13), ('clubs', 11), ('spades', 10)]

    Private methods are generally less common than private attributes. As a rule of thumb, a method should be hidden whenever the client has no need to directly access it. This is especially the case when it is possible that the client could adversely affect the integrity of the object by calling the method.

    Loading
    You have reached the end of this section! Continue to the next section:

    You can check your current points from the blue blob in the bottom-right corner of the page.

    \ No newline at end of file +[('clubs', 8), ('spades', 12), ('diamonds', 13), ('clubs', 11), ('spades', 10)]

    Private methods are generally less common than private attributes. As a rule of thumb, a method should be hidden whenever the client has no need to directly access it. This is especially the case when it is possible that the client could adversely affect the integrity of the object by calling the method.

    Loading
    You have reached the end of this section! Continue to the next section:

    You can check your current points from the blue blob in the bottom-right corner of the page.

    \ No newline at end of file diff --git a/part-9/5-class-attributes/index.html b/part-9/5-class-attributes/index.html index 3c84cdabd..2895e206c 100644 --- a/part-9/5-class-attributes/index.html +++ b/part-9/5-class-attributes/index.html @@ -358,4 +358,4 @@ return True
    registration = Registration("Mary Motorist", "Volvo", "1992", "abc-123")
     
     if Registration.license_plate_valid("xyz-789"):
    -    print("This is a valid license plate!")
    Sample output

    This is a valid license plate!

    The validity of a license plate can be checked even without creating a single instance of the class, for example with Registration.license_plate_valid("xyz-789"). The same method is called within the constructor of the class. NB: even within the constructor this method is accessed through the name of the class, not self!

    Loading
    You have reached the end of this section! Continue to the next section:

    You can check your current points from the blue blob in the bottom-right corner of the page.

    \ No newline at end of file + print("This is a valid license plate!")
    Sample output

    This is a valid license plate!

    The validity of a license plate can be checked even without creating a single instance of the class, for example with Registration.license_plate_valid("xyz-789"). The same method is called within the constructor of the class. NB: even within the constructor this method is accessed through the name of the class, not self!

    Loading
    You have reached the end of this section! Continue to the next section:

    You can check your current points from the blue blob in the bottom-right corner of the page.

    \ No newline at end of file diff --git a/part-9/6-more-examples-with-classes/index.html b/part-9/6-more-examples-with-classes/index.html index a9d29a57d..2077a477a 100644 --- a/part-9/6-more-examples-with-classes/index.html +++ b/part-9/6-more-examples-with-classes/index.html @@ -385,4 +385,4 @@ print(student1.completed_courses) print(student2.completed_courses)
    Sample output

    ['ItP', 'ACiP'] -[]

    The Grand Finale

    Even though the following exercise finishes off this part of the material, the techniques required to solve it were all covered already in the section named objects as attributes. Specifically, you are not required to use the @property decorator or default values for parameters in this exercise. This exercise is very similar to the exercises a box of presents and the shortest person in the room.

    Important information regarding the next exercise

    Please note that there is an issue resulting from an update in Python, which conflicts with the inbuilt library and the original file name for this exercise. If you experience any issues, we recommend redownloading the exercise folder. Once you have obtained the new local test files, you can use either "code.py" or "code_1.py" as the file name. While using Visual Studio Code, you may receive notifications about problems in the test file. However, these notifications can be safely ignored, as they are caused by the test's inability to import from either the "code.py" or "code_1.py" files.

    Loading

    Please respond to a quick questionnaire on this week's materials.

    Loading...
    :
    Loading...

    Log in to view the quiz

    You have reached the end of this section!

    You can check your current points from the blue blob in the bottom-right corner of the page.

    \ No newline at end of file +[]

    The Grand Finale

    Even though the following exercise finishes off this part of the material, the techniques required to solve it were all covered already in the section named objects as attributes. Specifically, you are not required to use the @property decorator or default values for parameters in this exercise. This exercise is very similar to the exercises a box of presents and the shortest person in the room.

    Important information regarding the next exercise

    Please note that there is an issue resulting from an update in Python, which conflicts with the inbuilt library and the original file name for this exercise. If you experience any issues, we recommend redownloading the exercise folder. Once you have obtained the new local test files, you can use either "code.py" or "code_1.py" as the file name. While using Visual Studio Code, you may receive notifications about problems in the test file. However, these notifications can be safely ignored, as they are caused by the test's inability to import from either the "code.py" or "code_1.py" files.

    Loading

    Please respond to a quick questionnaire on this week's materials.

    Loading...
    :
    Loading...

    Log in to view the quiz

    You have reached the end of this section!

    You can check your current points from the blue blob in the bottom-right corner of the page.

    \ No newline at end of file diff --git a/part-9/index.html b/part-9/index.html index f43c6b4b0..be4ba5337 100644 --- a/part-9/index.html +++ b/part-9/index.html @@ -152,4 +152,4 @@ } })
    \ No newline at end of file +
    Loading...
    \ No newline at end of file diff --git a/report-issue/index.html b/report-issue/index.html index 3a6b800d9..58cfcd3e9 100644 --- a/report-issue/index.html +++ b/report-issue/index.html @@ -134,4 +134,4 @@ } } }) -

    How to report an issue in the material


    You can report a mistake you found on the issues tab of the course's Github project. Github is a service where projects, software and source code can be managed and shared to others.

    Reporting an issue requires a Github account. If you don't have an account yet, you can create it here

    Before you open a new issue, please check here for an already opened issue regarding the mistake you found.


    How to compose the issue

    1. Press the button above.
    2. Please include a short and informative title in your issue report, for example "A typo in Part 1 in the description of exercise 30".
    3. Write a more detailed description of the issue in the comment section, for example "In Part 1 exercise 30, the sample output contains a typo. The previous code includes a line System.out.println("Enter a number");, but the sample output has the text "Exit a number"".
    4. Finally, press the green button "Submit new issue".

    We might ask some clarifying questions if we are unable to fix the issue without your help. Github should send an email notification regarding these questions to the email address linked to your Github account.

    Thank you for helping us improve our materials!

    \ No newline at end of file +

    How to report an issue in the material


    You can report a mistake you found on the issues tab of the course's Github project. Github is a service where projects, software and source code can be managed and shared to others.

    Reporting an issue requires a Github account. If you don't have an account yet, you can create it here

    Before you open a new issue, please check here for an already opened issue regarding the mistake you found.


    How to compose the issue

    1. Press the button above.
    2. Please include a short and informative title in your issue report, for example "A typo in Part 1 in the description of exercise 30".
    3. Write a more detailed description of the issue in the comment section, for example "In Part 1 exercise 30, the sample output contains a typo. The previous code includes a line System.out.println("Enter a number");, but the sample output has the text "Exit a number"".
    4. Finally, press the green button "Submit new issue".

    We might ask some clarifying questions if we are unable to fix the issue without your help. Github should send an email notification regarding these questions to the email address linked to your Github account.

    Thank you for helping us improve our materials!

    \ No newline at end of file diff --git a/sign-in/index.html b/sign-in/index.html index c986dad8d..b641caae2 100644 --- a/sign-in/index.html +++ b/sign-in/index.html @@ -140,4 +140,4 @@ } } }) -
    \ No newline at end of file +
    \ No newline at end of file diff --git a/sign-up/index.html b/sign-up/index.html index 922947504..2bcf6258d 100644 --- a/sign-up/index.html +++ b/sign-up/index.html @@ -140,4 +140,4 @@ } } }) -

    Create new account

    This course uses mooc.fi accounts. If you have previously done mooc.fi -courses, you can log in with your existing account. On this page you can create a new account, which works on majority of mooc.fi courses and services.
    \ No newline at end of file +

    Create new account

    This course uses mooc.fi accounts. If you have previously done mooc.fi -courses, you can log in with your existing account. On this page you can create a new account, which works on majority of mooc.fi courses and services.
    \ No newline at end of file diff --git a/support-and-assistance/index.html b/support-and-assistance/index.html index c6c557b69..97ee70179 100644 --- a/support-and-assistance/index.html +++ b/support-and-assistance/index.html @@ -224,4 +224,4 @@

    Discord

    Discord is a communication platform which allows both text-based and voice/video chats. You can find out more about the platform on the Discord website.

    The course channels are available through this link. See especially the ohjelmoinnin_mooc_english and the ohjelmoinnin_mooc_voice channels for support in English.

    -

    Instructor will be on standby on the course channels in Discord at guidance time. Instructor will also reply to questions sent via private messages. Discord also has a discussion about the course outside of the guidance hours, so it’s worth joining!

    \ No newline at end of file +

    Instructor will be on standby on the course channels in Discord at guidance time. Instructor will also reply to questions sent via private messages. Discord also has a discussion about the course outside of the guidance hours, so it’s worth joining!

    \ No newline at end of file