Hey -- the homework was previously formatted wrong here (but not on the slides). Sorry about that!
Homework:
Resources:
Slides: https://docs.google.com/presentation/d/15pk3Pma_64ogttIfLwt8pv3Dqg2kr5vKQpiftlM-9T8/edit?usp=sharing
Code: https://replit.com/join/pyvaiysnho-shrav816
Contact:
shravyassathish@gmail.com (mentor)
mailtoarnavpandey@gmail.com (TA)
Make sure to "Add a comment" with your code to the homework in order to submit your homework assignment!
Recordings for the class have been sent out through email :)
invatationnames = ['bessy', 'Aaron', 'kate','Avery','sam'] for a in invatationnames: if a.startswith("A"): a = ("yay" + a) print(a)
listofnum = [2, 4, 6, 8]
print(listofnum[0::2]
1. a) dog, cat, pigeon b) dog c) cat, squirrel 2. list = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0] list.reverse() print(list) 3. random = [1, 2, 3, 4, 8, 65, 6, 7] print(random[::2]) 4. names = ["Abc", "dog", "random", "A", "bye", "Am", "bob", "hello"] for i in names: if i.startswith("A"): i = ("Yay!" + i) print(i)
Stella: 1a) 'dog', 'cat', 'pigeon' b) 'dog' c) 'cat', 'squirrel' 2)list=['hi','its','me'] list.reverse() print(list) 3)list=['baguette','crossaint','jelly','fooood'] print(list(0::2)) 4)names=['Agnes','Taylor','Alana','Harry','Wednesday'] for i in names: if 'a' in i.lower: print('Yay!',end='') print(i)
1a) "dog", "cat", "pigeon"
1b) "dog"
1c) "cat", "squirrel"
2) rev = [1, 2, 3]
rev.reverse()
print(rev)
3) alt = [1, 3, 10, 5]
print(alt[0::2])
4) names = ["Hannah", "Lily", "Olivia", "Tyler"]
for i in names:
if "a" in i.lower():
print("Yay! ", end = "")
print(i)
1.
a. "dog", "cat","pigeon"
b. "dog"
c. "cat", "sqirrel"
2.
reverse = [1, 2, 3, 4, 5]
reverse.reverse()
print(reverse)
3.
alternate = [1, 5, 2, 4, 3]
print(alternate[0::2])
4.
names = ["Richard", "Anna", "Sophie", "Henry"]
for i in names:
if "a" in i.lower():
print("Yay! ", end = "")
print (i)
1. a. ['dog', 'cat', 'pigeon'] b. ['dog'] c. ['cat', 'squirrel'] 2. HairyOtter = ['Avada Kedavra', 'Wingardium Leviosa','Accio', 'Silenco', 'Expecto Patronum'] HairyOtter.reverse() print(HairyOtter) 3. HairyOtter = ['Avada Kedavra', 'Wingardium Leviosa','Accio', 'Silenco', 'Expecto Patronum'] print(HairyOtter[::2]) 4. HairyOtterspell = ['Avada Kedavra', 'Wingardium Leviosa','Accio', 'Silenco', 'Expecto Patronum'] for i in names: if i.startswith("A"): i = ("Yay!" + i) print(i)print(HairyOtterspell)
# 1. >>> ["dog", "cat"] >>> ["dog"] >>> ["cat", "squirrel"] # 2. list0 = ["Red", "Orange", "Yellow", "Green", "Blue", "Indigo", "Violet"] list0.reverse() print(list0) # 2.5 list0.reverse() # just so I can copy list0 to list1 # 3. list1 = list0 print(list1[::2]) # 4. names = ["Ava", "Bob", "Kevin", "Brian", "Adam"] for i in range(len(names)): index = names[i].find('A') if index == 0: names[i] = "Yay! " + names[i] print(names)