Files
learn-python3/notebooks/beginner/exercises/09_recap1_exercise.ipynb
2023-04-24 13:13:43 +03:00

112 lines
2.7 KiB
Plaintext

{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# 1. Super vowels\n",
"Implement `super_vowels` function which takes a string as an argument and returns a modified version of that string. In the return value of `super_vowels`, all vowels should be in upper case whereas all consonants should be in lower case. The vowels are listed in the `VOWELS` variable."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"editable": false
},
"outputs": [],
"source": [
"VOWELS = [\"a\", \"e\", \"i\", \"o\", \"u\"]"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Your implementation here"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"editable": false
},
"outputs": [],
"source": [
"assert super_vowels(\"hi wassup!\") == \"hI wAssUp!\"\n",
"assert super_vowels(\"HOw aRE You?\") == \"hOw ArE yOU?\""
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# 2. Playing board\n",
"Implement `get_playing_board` function which takes an integer as an argument. The function should return a string which resemples a playing board (e.g. a chess board). The board should contain as many rows and columns as requested by the interger argument. See the cell below for examples of desired behavior.\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Your implementation here"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"editable": false
},
"outputs": [],
"source": [
"board_of_5 = \" * * \\n\" \"* * *\\n\" \" * * \\n\" \"* * *\\n\" \" * * \\n\"\n",
"\n",
"board_of_10 = (\n",
" \" * * * * *\\n\"\n",
" \"* * * * * \\n\"\n",
" \" * * * * *\\n\"\n",
" \"* * * * * \\n\"\n",
" \" * * * * *\\n\"\n",
" \"* * * * * \\n\"\n",
" \" * * * * *\\n\"\n",
" \"* * * * * \\n\"\n",
" \" * * * * *\\n\"\n",
" \"* * * * * \\n\"\n",
")\n",
"\n",
"assert get_playing_board(5) == board_of_5\n",
"assert get_playing_board(10) == board_of_10\n",
"\n",
"print(get_playing_board(50))"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.0"
}
},
"nbformat": 4,
"nbformat_minor": 2
}