You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
159 lines
3.4 KiB
Plaintext
159 lines
3.4 KiB
Plaintext
{
|
|
"cells": [
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "66f72396-0cf1-41cf-a486-2930d2ad1652",
|
|
"metadata": {},
|
|
"source": [
|
|
"# Shout\n",
|
|
"This function take a text and shouts it LOUD. It repeats the vowels for a specified number of times."
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 1,
|
|
"id": "9bd8860a-9967-49d5-a74a-b5de669dfe6d",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"def shout(text: str, volume: int = 5) -> str:\n",
|
|
" \"\"\"Repeat the vowels in a string for a specified number of times\"\"\"\n",
|
|
" shouted_text = ''\n",
|
|
" for c in text:\n",
|
|
" character = c\n",
|
|
" if c.lower() in ['a','e','i','o','u','y']:\n",
|
|
" character = character * volume\n",
|
|
" shouted_text = shouted_text + character\n",
|
|
" return shouted_text"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "d50511cb-a810-4fe1-a681-e5cb1392c0d0",
|
|
"metadata": {},
|
|
"source": [
|
|
"![Snake on a sbake](https://hub.xpub.nl/soupboat/~kamo/assets/goose.jpg)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "2c3e992a-317b-4433-8c3b-9efcedea575d",
|
|
"metadata": {
|
|
"tags": []
|
|
},
|
|
"source": [
|
|
"## Examples"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 2,
|
|
"id": "e3d7e97b-0089-4c29-a2c1-9ef823ff2e37",
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"data": {
|
|
"text/plain": [
|
|
"'heeeeelp'"
|
|
]
|
|
},
|
|
"execution_count": 2,
|
|
"metadata": {},
|
|
"output_type": "execute_result"
|
|
}
|
|
],
|
|
"source": [
|
|
"shout('help')"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "d3ce6961-68ff-4338-a71f-f8d77aa4f949",
|
|
"metadata": {},
|
|
"source": [
|
|
"The first parameter is the text you want to shout. It can be anything, like a terrorized cry or a drunk song at 4am outside the pub. \n",
|
|
"If you want to scream louder you can specify a second parameter for the volume. This is a number and by default is 5. It has to be positive but there are no limits to it."
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 3,
|
|
"id": "dd3f3a0b-3145-4914-8638-951bcdbd0774",
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"data": {
|
|
"text/plain": [
|
|
"'HEEEEEEEEEELP'"
|
|
]
|
|
},
|
|
"execution_count": 3,
|
|
"metadata": {},
|
|
"output_type": "execute_result"
|
|
}
|
|
],
|
|
"source": [
|
|
"shout('HELP', 10)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "d7e70281-0562-4fb0-8c07-b2ea7143b393",
|
|
"metadata": {},
|
|
"source": [
|
|
"You see, this is very a dangerous situation."
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 4,
|
|
"id": "9f685cab-278e-4b44-afd9-6e6012981442",
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"data": {
|
|
"text/plain": [
|
|
"'MG HLP'"
|
|
]
|
|
},
|
|
"execution_count": 4,
|
|
"metadata": {},
|
|
"output_type": "execute_result"
|
|
}
|
|
],
|
|
"source": [
|
|
"shout('OMG HELP', 0)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "0f668b5e-43bf-4321-b05b-5930d6eac152",
|
|
"metadata": {},
|
|
"source": [
|
|
"A muted scream"
|
|
]
|
|
}
|
|
],
|
|
"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.7.3"
|
|
}
|
|
},
|
|
"nbformat": 4,
|
|
"nbformat_minor": 5
|
|
}
|