Colab

  1. compute 10+90
  2. put the result
fox = "the quick brown fox jumped over the lazy dog"

fox.upper().endswith("lazy dog")

False
"DOG" == "dog"

False
mylist = ["one", "two", "three"]
result = " ".join(mylist)
print(result)

one two three
result

'one two three'
type(mylist)

list
type(result)

str
len(mylist)

3
len(result)

13
"sdklfjhasdlkfh"

'sdklfjhasdlkfh'
["f.xd,ghdflskjgh", 10, 100, 0.5, "hewllo"]

['f.xd,ghdflskjgh', 10, 100, 0.5, 'hewllo']
song = """Yeah yeah yeah yeah yeah
Yeah yeah yeah yeah yeah yeah
I think I did it again
I made you believe we're more than just friends
Oh baby
It might seem like a crush
But it doesn't mean that I'm serious
'Cause to lose all my senses
That is just so typically me
Oh baby, baby
Oops, I did it again
I played with your heart, got lost in the game
Oh baby, baby
Oops, you think I'm in love
That I'm sent from above
I'm not that innocent
"""

print(song)

Yeah yeah yeah yeah yeah
Yeah yeah yeah yeah yeah yeah
I think I did it again
I made you believe we're more than just friends
Oh baby
It might seem like a crush
But it doesn't mean that I'm serious
'Cause to lose all my senses
That is just so typically me
Oh baby, baby
Oops, I did it again
I played with your heart, got lost in the game
Oh baby, baby
Oops, you think I'm in love
That I'm sent from above
I'm not that innocent

words = song.split(' ')

len(words)

74
words[0]

'Yeah'
words[7] = "boom"
words[14] = "boom"
words[21] = "boom"
words[28] = "boom"
words[35] = "boom"

print(words)

['Yeah', 'yeah', 'yeah', 'yeah', 'yeah\nYeah', 'yeah', 'yeah', 'boom', 'yeah', 'yeah\nI', 'think', 'I', 'did', 'it', 'boom', 'made', 'you', 'believe', "we're", 'more', 'than', 'boom', 'friends\nOh', 'baby\nIt', 'might', 'seem', 'like', 'a', 'boom', 'it', "doesn't", 'mean', 'that', "I'm", "serious\n'Cause", 'boom', 'lose', 'all', 'my', 'senses\nThat', 'is', 'just', 'so', 'typically', 'me\nOh', 'baby,', 'baby\nOops,', 'I', 'did', 'it', 'again\nI', 'played', 'with', 'your', 'heart,', 'got', 'lost', 'in', 'the', 'game\nOh', 'baby,', 'baby\nOops,', 'you', 'think', "I'm", 'in', 'love\nThat', "I'm", 'sent', 'from', "above\nI'm", 'not', 'that', 'innocent\n']
songboom = " ".join(words)
print(songboom)

Yeah yeah yeah yeah yeah
Yeah yeah yeah boom yeah yeah
I think I did it boom made you believe we're more than boom friends
Oh baby
It might seem like a boom it doesn't mean that I'm serious
'Cause boom lose all my senses
That is just so typically me
Oh baby, baby
Oops, I did it again
I played with your heart, got lost in the game
Oh baby, baby
Oops, you think I'm in love
That I'm sent from above
I'm not that innocent

print(song.replace('i', '1').replace('e', '3').replace('s', '5'))

Y3ah y3ah y3ah y3ah y3ah
Y3ah y3ah y3ah y3ah y3ah y3ah
I th1nk I d1d 1t aga1n
I mad3 you b3l13v3 w3'r3 mor3 than ju5t fr13nd5
Oh baby
It m1ght 533m l1k3 a cru5h
But 1t do35n't m3an that I'm 53r1ou5
'Cau53 to lo53 all my 53n535
That 15 ju5t 5o typ1cally m3
Oh baby, baby
Oop5, I d1d 1t aga1n
I play3d w1th your h3art, got lo5t 1n th3 gam3
Oh baby, baby
Oop5, you th1nk I'm 1n lov3
That I'm 53nt from abov3
I'm not that 1nnoc3nt

"the quick brown fox jumped over the lazy dog".replace("the", "da")

'da quick brown fox jumped over da lazy dog'
{}

{}
[]

[]
cities = {
    "israel" :         "jerusalem"      ,
    "uk" : "london",
    "russia" : "moscow"
}

cities

{'israel': 'jerusalem', 'uk': 'london', 'russia': 'moscow'}
cities['israel']

'jerusalem'
cities["france"] = "paris"

print(cities)

{'israel': 'jerusalem', 'uk': 'london', 'russia': 'moscow', 'france': 'paris'}
cities['france']

'paris'
leet = {
    'i' : '1',
    'e' : '3',
    's' : '5'
}

synonyms = {
    "good" : ['great', 'amzing', 'wonderful', "not bad"],
    "sad" : ['blue', 'depressed', 'down', 'gloom']
}

synonyms['sad']

['blue', 'depressed', 'down', 'gloom']

create a dictionary that maps the name of cheeses to prices of 100mg of that cheese.

 gouda costs 4.99 
 Edam costs 2.45
 Camambert costs 7.75
 Bree costs 7.27

without using “head math”, compute the costs of gouda, edam and camambert together

cheese = {
    "gouda" : 4.99,
    "edam" : 2.45,
    "camambert" : 7.75,
    "bree" : 7.27
}

cheese["gouda"] + cheese['edam'] + cheese['camambert']

15.190000000000001
[cheese["gouda"] , cheese['edam'] , cheese['camambert']]

[4.99, 2.45, 7.75]
cheese.keys()

dict_keys(['gouda', 'edam', 'camambert', 'bree'])
cheese.values()

dict_values([4.99, 2.45, 7.75, 7.27])
cheese.items()

dict_items([('gouda', 4.99), ('edam', 2.45), ('camambert', 7.75), ('bree', 7.27)])
sorted(cheese.items(), key=lambda pair: pair[1])[0]

('edam', 2.45)
cheese.pop('gouda')

4.99
cheese

{'edam': 2.45, 'camambert': 7.75, 'bree': 7.27}
{
    
}