moved to jupyter notebook

This commit is contained in:
paul-loedige 2022-10-20 14:14:00 +09:00
parent f40f2327e1
commit b3ea6edcd7
3 changed files with 155 additions and 36 deletions

155
Assignment_Week_2.ipynb Normal file
View File

@ -0,0 +1,155 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Intelligent World Informatics LectureV: Assignment Week 2\n",
"- Author: Paul Lödige (ploedige@g.ecc.u-tokyo.ac.jp)\n",
"- Student ID: 37-229753\n",
"## Assignment\n",
" - Write short python codes that modify lists using the functions/ methods mentioned in todays lecture \n",
" - Anything is okay\n",
" - Create list, add items, remove items, sort items, list copy, etc.\n",
" - Take screenshots of the code and the printed result\n",
" - Put them inside a single-page PDF.\n",
" - Upload into ITC-LMS\n",
" - A submission link will be created"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"string = \"this is a test string\""
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"t\n",
"s\n",
"s\n",
"t\n",
"s\n",
"t\n",
"s\n",
"t\n",
"r\n",
"n\n"
]
}
],
"source": [
"\n",
"# loop through every letter of the string and print it if it comes after \"m\"\n",
"for letter in string:\n",
" if letter.upper() > 'M':\n",
" print(letter)"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"['this', 'is', 'a', 'test', 'string']\n"
]
}
],
"source": [
"\n",
"# split the string into a list of words\n",
"words = string.split()\n",
"print (words)"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"['this', 'is', 'a', 'test', 'string']\n",
"['string', 'test', 'a', 'is', 'this']\n",
"['a', 'is', 'string', 'test', 'this']\n",
"['this', 'is', 'a', 'test', 'string']\n"
]
}
],
"source": [
"\n",
"# copy the list of words and replace and manipulate one of them\n",
"words2 = words.copy()\n",
"print (words)\n",
"words.reverse()\n",
"print (words)\n",
"words.sort()\n",
"print(words)\n",
"print(words2)"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"['a', 'is', 'string', 'test', 'this', 'more tests']\n"
]
}
],
"source": [
"\n",
"# add items to the words list\n",
"words.append(\"more tests\")\n",
"print(words)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3.10.8 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.8"
},
"orig_nbformat": 4,
"vscode": {
"interpreter": {
"hash": "e7370f93d1d0cde622a1f8e1c04877d8463912d04d973331ad4851f04de6915a"
}
}
},
"nbformat": 4,
"nbformat_minor": 2
}

View File

@ -1,27 +0,0 @@
"""
author: Paul Lödige (ploedige@g.ecc.u-tokyo.ac.jp)
"""
string = "this is a test string"
# loop through every letter of the string and print it if it comes after "m"
for letter in string:
if letter.upper() > 'M':
print(letter)
# split the string into a list of words
words = string.split()
print (words)
# copy the list of words and replace and manipulate one of them
words2 = words.copy()
print (words)
words.reverse()
print (words)
words.sort()
print(words)
print(words2)
# add items to the words list
words.append("more tests")
print(words)

View File

@ -1,9 +0,0 @@
# Week 2 Assignment
## Homework
- Write short python codes that modify lists using the functions/ methods mentioned in todays lecture
- Anything is okay
- Create list, add items, remove items, sort items, list copy, etc.
- Take screenshots of the code and the printed result
- Put them inside a single-page PDF.
- Upload into ITC-LMS
- A submission link will be created