Practice Python Lists with Computer Science books
Practice Python Lists with Computer Science books Data Science Project
Python Collections

Practice Python Lists with Computer Science books

The objective of this project is to practice your Python list handling skills, including: adding and removing elements, combining lists, using membership operations and, most importantly, iterating them. We'll use a dataset containing a big collection of Computer Science books.
Start this project
Practice Python Lists with Computer Science booksPractice Python Lists with Computer Science books
Project Created by

Anurag Verma

Project Activities

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.

codevalidated

Find Unique Elements in a List

Implement the unique_list_elements function that takes a list as input and returns a new list with only the unique elements from the original list.

Example:

>>> 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.

codevalidated

Find Common Elements in Two Lists

Implement the 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]
codevalidated

Calculate Average of Numbers

Create the 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.

codevalidated

Sort Strings Alphabetically

Define the 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.

codevalidated

Square Numbers in a List

Create the 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.

codevalidated

Map String Lengths

Create the 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.

input

How many books are in `computer_science_books`

How many books are in the list computer_science_books?

Count unique books in the list.

codevalidated

Verify the Presence of a Specific Book

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_books then add it at the end of the list.

codevalidated

Replace an item from the list with another item

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

codevalidated

Find if there are duplicates

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 count_python_ml.

codevalidated

Remove all the duplicate books in the dataset.

Create a new list unique_books which contains only the unique books from the list computer_science_books.

codevalidated

Sort the books in alphabetical order

Sort the list computer_science_books in alphabetical order and update the list.

codevalidated

Create a new list `less_than_60` which will have books of less than 60 characters long.

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.

codevalidated

Which book has the shortest name and which book has the longest name.

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 longest_book.

If there are multiple books with the same length, store the first book in the variable which comes first by alphabetical order.

input

How many characters are there in the shortest name

How many characters are there in the shortest name?

Practice Python Lists with Computer Science booksPractice Python Lists with Computer Science books
Project Created by

Anurag Verma

What's up, friends! 👋 I'm a computer science student about to finish my last year of college. 🎓 I LOVE writing code! ❤️ It makes me so happy! 😄 Whether I'm goofing in notebooks 📓 or coding in Python 🐍, writing programs is a blast! 💥

What's up, friends! 👋 I'm a computer science student about to finish my last year of college. 🎓 I LOVE writing code! ❤️ It makes me so happy! 😄 Whether I'm goofing in notebooks 📓 or coding in Python 🐍, writing programs is a blast! 💥

This project is part of

Python Collections

Explore other projects