Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 1. Create a function that returns the average of a list of numbers
- def average(my_list):
- # your code
- print(average([1 , 2 , 3, 4 , 5])) --> 3
- 2. Create a function that returns the second maximum number of a list
- def sec_maximum(my_list):
- # your code
- print(sec_maximum([2 , 1 , 5, 2 , 3])) --> 3
- 2. Create a function that returns the second maximum number of a list
- def sec_maximum(my_list):
- # your code
- print(sec_maximum([2 , 1 , 5, 2 , 3])) --> 3
- 3. Write a Python function that takes two lists and prints True if they have at least one common member and False otherwise.
- def common(list_1, list_2):
- # your code
- print(common([2 , 1 , 5], [3 , 4 , 1])) --> True
- print(common([2 , 1 , 5], [3 , 4 , 6])) --> True
- 4. Write a Python function to convert a string of numbers separated by comma eg '1,2,3,4' to a list of numbers eg [1, 2, 3 , 4].
- def get_list(my_string):
- # your code
- print(get_list('1,2,3,4')) --> [1 , 2 , 3 , 4]
- 5. Write a Python function that returns a specified list after removing even numbers from it.
- def remove_evens(my_list):
- # your code
- print(remove_evens([2 , 1 , 5, 2 , 3])) --> [1 , 5 , 3]
- 6. Write a Python function to count the number of strings where the string length is 2 or more and the first and last character are same from a given list of strings.
- def good_strings(my_list):
- # your code
- print(good_strings(['abc', 'xyz', 'aba', '1221'])) --> 2
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement