First Python

Run Settings
LanguagePython
Language Version
Run Command
# def highest_even(li): # evens = [] # for item in li: # if item % 2 == 0: # evens.append(item) # return max(evens) # print(highest_even([10,2,3,4,8,11])) # def highest_even(li): # return max([num for num in li if num % 2 == 0], default=None) # print(highest_even([10,2,3,4,8,11])) # def test(a): # ''' # Info: this function tests and prints param a # ''' # print(a) # # test('!!!!') # # test('a') # help(test) # print(test.__doc__) # def checkDriverAge(age=0): # #age = input("What is your age?: ") # if int(age) < 18: # print("Sorry, you are too young to drive this car. Powering off") # elif int(age) > 18: # print("Powering On. Enjoy the ride!"); # elif int(age) == 18: # print("Congratulations on your first year of driving. Enjoy the ride!") # checkDriverAge(92) #1. Wrap the above code in a function called checkDriverAge(). Whenever you call this function, you will get prompted for age. # Notice the benefit in having checkDriverAge() instead of copying and pasting the function everytime? #2 Instead of using the input(). Now, make the checkDriverAge() function accept an argument of age, so that if you enter: #checkDriverAge(92); #it returns "Powering On. Enjoy the ride!" #also make it so that the default age is set to 0 if no argument is given. # def sum(num1, num2): # def another_func(n1, n2): # return n1 + n2 # return another_func(num1,num2) # total = sum(10,20) # print(total) # print([1.2,3].clear()) # Default Parameters # def say_hello(name='Darth Vader', emoji='⚔️👿💀'): # print(f'hellllooooo {name} {emoji}') # say_hello() # say_hello('Timmy') # say_hello('Elliot', '👿') #keyword arguments # def say_hello(name, emoji): # print(f'hellllooooo {name} {emoji}') # say_hello(emoji='\U0001f600', name = 'Bibi') #parameteres # def say_hello(name, emoji): # print(f'hellllooooo {name} {emoji}') # #arguments # positional arguments # say_hello('Elliot', '😛') # call, invoke # say_hello('Buddy', '\U0001F923') # call, invoke # picture = [ # [0,0,0,1,0,0,0], # [0,0,1,1,1,0,0], # [0,1,1,1,1,1,0], # [1,1,1,1,1,1,1], # [0,0,0,1,0,0,0], # [0,0,0,1,0,0,0] # ] # def show_tree(): # for image in picture: # for pixel in image: # if pixel: # print('*', end ='') # else: # print(' ', end ='') # print('') # for i in range(3): # show_tree() # # Exercise: Check for duplicates in list: # my_list = ['a', 'b', 'c', 'b', 'd', 'm', 'n', 'n'] # duplicates = [] # for value in my_list: # if my_list.count(value) > 1: # if value not in duplicates: # duplicates.append(value) # a = str(duplicates) # print(a) # res = ' '.join(duplicates) # print(res) # i=0 # while i < len(my_list): # j=i+1 # while j < len(my_list): # if my_list[i]==my_list[j]: # print(my_list[i], end = ' ') # j+=1 # i+=1
Editor Settings
Theme
Key bindings
Full width
Lines