3
3+4*5
'hello' + 'world'
'hello'.upper()
'hello'.endswith('bye')
'hello'.endswith('llo')
'hello'.endswith('hello')
'hello'.endswith('!')
greeting = 'hello'
while greeting.islower():
greeting = input('say hi: ')
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)
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()
def (thelist):
print()
for cheese in thelist:
print(cheese, end=',\n')
print()
lineprint(premium)
lineprint(x)
lineprint(soccer)
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
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')
print(y)
x = len([1,2,3])
x
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()
david = "ecstatic"
make_david_happy()
print('so now david is', david)