Colab

3

3
3+4*5

23
'hello' + 'world'

'helloworld'
'hello'.upper()

'HELLO'
'hello'.endswith('bye')

False
'hello'.endswith('llo')

True
'hello'.endswith('hello')

True
'hello'.endswith('!')

False
greeting = 'hello'

while greeting.islower():
    greeting = input('say hi: ')

say hi: hi
say hi: hello
say hi: Hello
if greeting.isupper():
    print('too loud')

premium = []
cheeses = ['Edam', 'Brie', 'Camambert']
for cheese in cheeses:
    new_cheese = 'premium ' + cheese
    premium.append(new_cheese)

x = [10, 20, 0, 50, 50, 100]
soccer = ['maccabi ta', 'chelsea', 'real madrid', 'maccabi natanya', 'liverpool']

print(premium)
print(x)
print(soccer)

['premium Edam', 'premium Brie', 'premium Camambert']
[10, 20, 0, 50, 50, 100]
['maccabi ta', 'chelsea', 'real madrid', 'maccabi natanya', 'liverpool']
print()
for cheese in premium:
    print(cheese, end=',\n')
print()    

print()
for cheese in x:
    print(cheese, end=',\n')
print()

print()
for cheese in soccer:
    print(cheese, end=',\n')
print()



premium Edam,
premium Brie,
premium Camambert,


10,
20,
0,
50,
50,
100,


maccabi ta,
chelsea,
real madrid,
maccabi natanya,
liverpool,

def (thelist):
    print()
    for cheese in thelist:
        print(cheese, end=',\n')
    print()


lineprint(premium)
lineprint(x)
lineprint(soccer)


premium Edam,
premium Brie,
premium Camambert,


10,
20,
0,
50,
50,
100,


maccabi ta,
chelsea,
real madrid,
maccabi natanya,
liverpool,

def printadd(x, y):
    print(x+y)
    
printadd(10, 5)
printadd('hello', ' world')
printadd([1,2], [3])

# write a function print_longer_list that receives two lists as parameters
# and prints only the longer list  
#    lets use len() function, and an if/else statement


15
hello world
[1, 2, 3]
def print_longer_list(list1, list2):
    if len(list1) <= len(list2):
        print(list2)
    else:
        print(list1)

x = print_longer_list(range(30), range(10, 20))
y = print_longer_list('encyclopedia', 'hello')        

range(0, 30)
encyclopedia
print(y)

None
x = len([1,2,3])

x

3
def get_longer_list(list1, list2):
    if len(list1) <= len(list2):
        return list2
    else:
        return list1
    
x = get_longer_list(range(30), range(10, 20))
y = get_longer_list('encyclopedia', 'hello') 
z = get_longer_list([1,2,3,4,5,6], 'hello') 

def make_david_happy():
     
    print('i made david', david)

make_david_happy()

i made david happy
david = "ecstatic"
make_david_happy()
print('so now david is', david)

i made david happy
so now david is ecstatic