All our Data Science projects include bite-sized activities to test your knowledge and practice in an environment with constant feedback.
All our activities include solutions with explanations on how they work and why we chose them.
unique_list_elements function that takes a list as input and returns a new list with only the unique elements from the original list.
>>> unique_list_elements([2, 3, 2, 3, 4, 5, 6, 5, 6, 6]) [2, 3, 4, 5, 6]
Ensure the function handles the task correctly and provides the expected output for different input cases.
get_common function that takes two lists as input and returns a new list containing only the common elements present in both lists.
>>>input_list_1 = [1, 2, 3, 4, 5] >>>input_list_2 = [4, 5, 6, 7, 8] >>>get_common(input_list_1, input_list_2) [4, 5]
get_average function that accepts a list of numbers as input and calculates the average of those numbers.
>>>get_average([34, 21, 78, 96, 12, 15]) 45.333333333333336
Ensure the function accurately computes the average of various input lists, providing the correct result for each case.
sort_alphabets function, which accepts a list of strings as input and generates a new list with the strings sorted in alphabetical order.
>>>sort_alphabets(['e', 'd', 'f', 'a', 'c', 'b']) ['a', 'b', 'c', 'd', 'e', 'f']
Verify that the function properly sorts the strings in alphabetical order when provided with different input lists.
square_list function that takes a list of numbers as input and generates a new list with each number squared.
>>>square_list([1, 3, 5, 7, 9]) [1, 9, 25, 49, 81]
Ensure the function correctly squares each number in the input list and provides the expected output for different input cases.
map_len function, which accepts a list of strings as input and returns a new list where each element represents the length of the corresponding string in the input list.
An Example of the function:
>>>count_len(['af', 'jk', 'lpoil', 'ptyuh']) [2, 2, 5, 5]
Ensure the function correctly calculates the length of each string in the input list and provides the expected output for different sets of strings.
How many books are in the list
Count unique books in the list.
Check if the well-known Computer Science book
Algorithms to Live By The Computer Science of Human Decisions by Brian Christian is in the dataset.
If it is not in the list
computer_science_booksthen add it at the end of the list.
Replace the Book
"Pattern Recognition and Machine Learning by Christopher M. Bishop" with
"Pattern Recognition and Machine Learning 2006 2nd Edition by Christopher M. Bishop".
NOTE: You have to replace all the instances, may be there are duplicate entries
Count the occurrences of
"Python Machine Learning by Sebastian Raschka and Vahid Mirjalili" to check if there are any duplicate elements in the dataset. Store the count in the variable
Create a new list
unique_books which contains only the unique books from the list
Sort the list
computer_science_books in alphabetical order and update the list.
Create a new list
less_than_60 which will have books of less than 60 characters long.
Don't worry about the duplicates in the list.
Find the book which has the shortest name and the book which has the longest name. Store the book with the shortest name in the variable
shortest_book and the book with the longest name in the variable
If there are multiple books with the same length, store the first book in the variable which comes first by alphabetical order.
How many characters are there in the shortest name?