This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Example 1 | |
drinks = ["espresso", "chai", "decaf", "drip"] | |
caffeine = [64, 40, 0, 120] | |
zipped_drinks = zip(drinks, caffeine) | |
drinks_to_caffeine = {key:value for key, value in zipped_drinks} | |
print(drinks_to_caffeine) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Write your function here | |
def reversed_list(lst1, lst2): | |
for index in range(len(lst1)): | |
if lst1[index] != lst2[len(lst2) - 1 - index]: | |
return False | |
return True | |
#Uncomment the lines below when your function is done |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# print the value for every position with an odd index. | |
#Write your function here | |
def odd_indices(lst): | |
new_list = [] | |
for idx in lst: | |
if lst.index(idx) % 2 != 0: | |
new_list.append(idx) | |
return(new_list) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Write your function here | |
def middle_element(lst): | |
if len(lst) % 2 == 0: | |
sum = lst[int(len(lst)/2)] + lst[int(len(lst) / 2) - 1] | |
return sum / 2 | |
else: | |
return lst[int(len(lst)/2)] | |
#Uncomment the line below when your function is done |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Write your function here | |
def more_frequent_item(lst, item1, item2): | |
if lst.count(item1) >= lst.count(item2): | |
return item1 | |
else: | |
return item2 | |
#Uncomment the line below when your function is done | |
print(more_frequent_item([2, 3, 3, 2, 3, 2, 3, 2, 3], 2, 3)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Write your function here | |
def double_index(lst, index): | |
if index >= len(lst): | |
return lst | |
newlst = lst[0:index] | |
newlst.append(lst[index]*2) | |
return newlst + lst[index+1:] | |
#Uncomment the line below when your function is done |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Write your function here | |
def remove_middle(lst, start, end): | |
vals = lst | |
for num in range(start, end): | |
del vals[num] | |
return vals | |
#Uncomment the line below when your function is done | |
print(remove_middle([4, 8, 15, 16, 23, 42], 1, 3)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Write your function here | |
def every_three_nums(start): | |
cnt = start | |
nums = [start] | |
while cnt < 100: | |
cnt += 3 | |
nums.append(cnt) | |
return nums |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
kumusta sa visita hapon ikaw, maganda? | |
ay meron, ganda [sila] pero pobre sa ako. pobre sa ako. | |
ma saktan sa puso? | |
ay sakit. | |
sa princess ma'aas ako. | |
bitaw, ikaw mas matanda y ma baho ko. | |
seguro, y sobre sa pangit mo. | |
sabe sa hapon y studia? | |
hindi naman. wala sa ko. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ito lenguas sa pilipinas. meronong ito? | |
tagalog: national dialect [1] | |
hindi: no | |
sabe: know | |
kumusta, magandang umaga: greeting (ex. someone from Japan/ha'pon: ohayoo gozaimasu) | |
hapon: evening (end of day) | |
pangit <> ganda | |
wa: slang wala [3] |
NewerOlder