did assignment
This commit is contained in:
parent
3d50af71e8
commit
f40f2327e1
27
Assignment_Week_2.py
Normal file
27
Assignment_Week_2.py
Normal file
@ -0,0 +1,27 @@
|
||||
"""
|
||||
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)
|
11
README.md
11
README.md
@ -1,2 +1,9 @@
|
||||
# Week_2_Assignment
|
||||
|
||||
# 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
|
||||
|
Loading…
x
Reference in New Issue
Block a user