Skip to content

Commit

Permalink
updated exercise 21
Browse files Browse the repository at this point in the history
  • Loading branch information
EvaEibl committed Aug 20, 2020
1 parent ac47511 commit 3f80607
Showing 1 changed file with 96 additions and 4 deletions.
100 changes: 96 additions & 4 deletions exercise_21_python_recap.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"metadata": {},
"source": [
"## Exercises\n",
"#### Print your name\n",
"#### 1. Print your name\n",
"\n",
"Save your name in all lower-case letters to a variable, and print a capitalized version of it. Protip: [Google for \"How to capitalize a string in python\"](http://www.google.com/search?q=how+to+capitalize+a+string+in+python). This works for almost any programming problem - someone will have had the same issue before!"
]
Expand All @@ -36,7 +36,90 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Functions, NumPy, and Matplotlib\n",
"#### 2. Print all the vowels in your name"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### 3. Print all the words in the string \"Hello how are you?\" separately on the screen "
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### 4. Dictionary\n",
"\n",
"Create a dictionary where names are linked to nationalities. Ask the user for its name and print \"This is *name*. She/ He is *nationality*\" or \"Sorry we could not find you in the database.\""
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### 5. Siblings\n",
"Ask the user for it’s name and number of siblings. Print on screen “*name* has no siblings.”, “*name* has 1 sibling.” or “*name* has *number of* siblings.” depending on the input.\n",
"Hint: Ask to separate input by commas"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### 6. Fibonacci sequence\n",
"Write a function that displays the n first terms of the Fibonacci sequence, defined by\n",
"\n",
"U_0 = 0\n",
"\n",
"U_1 = 1\n",
"\n",
"U_n+2 = U_n+1 + U_n\n",
"\n",
"Output: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ..."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### 7. Functions, NumPy, and Matplotlib\n",
"\n",
"A. Write a function that takes a NumPy array `x` and `a`, `b`, and `c` and returns\n",
"\n",
Expand All @@ -58,7 +141,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"#### 99 Bottles of Beer\n",
"#### 8. 99 Bottles of Beer\n",
"\n",
"*(stolen from http://www.ling.gu.se/~lager/python_exercises.html)*\n",
"\n",
Expand Down Expand Up @@ -86,7 +169,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Ceasar Cipher\n",
"#### 9. Ceasar Cipher\n",
"\n",
"*(stolen from http://www.ling.gu.se/~lager/python_exercises.html)*\n",
"\n",
Expand All @@ -111,6 +194,15 @@
"**BONUS:** Write an encoder!"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### 10. Sum of numbers\n",
"\n",
"Write a program that asks the user for a number n and prints the sum of the numbers 1 to n. But: only multiples of three or five are considered in the sum, e.g. 3, 5, 6, 9, 10, 12, 15 for n=17"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand Down

0 comments on commit 3f80607

Please sign in to comment.