110 lines
2.3 KiB
Plaintext
110 lines
2.3 KiB
Plaintext
{
|
|
"cells": [
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 10,
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"name": "stdout",
|
|
"output_type": "stream",
|
|
"text": [
|
|
" good programmers\n",
|
|
"Most of the good programmers do programming not because they expect to g\n",
|
|
"Most of the good programmers do programming not because they expect to get paid or get adulation by the public, but because it is fun\n",
|
|
"Most\n",
|
|
"the\n",
|
|
"programmers\n",
|
|
"programming\n",
|
|
"because\n",
|
|
"expect\n",
|
|
"get\n",
|
|
"or\n",
|
|
"adulation\n",
|
|
"the\n",
|
|
"but\n",
|
|
"it\n",
|
|
"fun\n",
|
|
"program.\n"
|
|
]
|
|
}
|
|
],
|
|
"source": [
|
|
"# Task 1\n",
|
|
"quote = \"Most of the good programmers do programming \"+ \\\n",
|
|
"\"not because they expect to get \"+ \\\n",
|
|
"\"paid or get adulation by the public, \"+ \\\n",
|
|
"\"but because it is fun to program.\"\n",
|
|
"# A\n",
|
|
"print(quote[11:11+17])\n",
|
|
"# B\n",
|
|
"print(quote[0:len(quote) // 2])\n",
|
|
"# C\n",
|
|
"print(quote[0:len(quote)-12])\n",
|
|
"\n",
|
|
"# D\n",
|
|
"splits = quote.split(\" \")\n",
|
|
"for i in range(0,len(splits),2):\n",
|
|
" print(splits[i])"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 37,
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"name": "stdout",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"8\n",
|
|
"get\n",
|
|
"None\n"
|
|
]
|
|
}
|
|
],
|
|
"source": [
|
|
"# Task 2\n",
|
|
"\n",
|
|
"#A\n",
|
|
"import random\n",
|
|
"\n",
|
|
"print(random.randint(1,10))\n",
|
|
"\n",
|
|
"# B\n",
|
|
"print(random.choice(splits))\n",
|
|
"\n",
|
|
"# C\n",
|
|
"print(random.shuffle(splits))"
|
|
]
|
|
}
|
|
],
|
|
"metadata": {
|
|
"kernelspec": {
|
|
"display_name": "Python 3.10.5 64-bit",
|
|
"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.10.5"
|
|
},
|
|
"orig_nbformat": 4,
|
|
"vscode": {
|
|
"interpreter": {
|
|
"hash": "369f2c481f4da34e4445cda3fffd2e751bd1c4d706f27375911949ba6bb62e1c"
|
|
}
|
|
}
|
|
},
|
|
"nbformat": 4,
|
|
"nbformat_minor": 2
|
|
}
|