From b3ea6edcd7579ccd2c3b5d7521b55a19b4cae9b8 Mon Sep 17 00:00:00 2001 From: paul-loedige Date: Thu, 20 Oct 2022 14:14:00 +0900 Subject: [PATCH] moved to jupyter notebook --- Assignment_Week_2.ipynb | 155 ++++++++++++++++++++++++++++++++++++++++ Assignment_Week_2.py | 27 ------- README.md | 9 --- 3 files changed, 155 insertions(+), 36 deletions(-) create mode 100644 Assignment_Week_2.ipynb delete mode 100644 Assignment_Week_2.py delete mode 100644 README.md diff --git a/Assignment_Week_2.ipynb b/Assignment_Week_2.ipynb new file mode 100644 index 0000000..98678a3 --- /dev/null +++ b/Assignment_Week_2.ipynb @@ -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 today’s 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 +} diff --git a/Assignment_Week_2.py b/Assignment_Week_2.py deleted file mode 100644 index a1f0920..0000000 --- a/Assignment_Week_2.py +++ /dev/null @@ -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) \ No newline at end of file diff --git a/README.md b/README.md deleted file mode 100644 index fad6191..0000000 --- a/README.md +++ /dev/null @@ -1,9 +0,0 @@ -# Week 2 Assignment -## Homework - - Write short python codes that modify lists using the functions/ methods mentioned in today’s 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