Logo

Python Basics Exercises

Introduction

This lesson contains additional practice material. Go through all of the problems one by one. Don't skip anything - practice makes perfect. After all, practice is the whole point of going through this course, and of this project generally.

Exercises

  1. Create a function largest_number with a list of numbers as a parameter and return the largest number found. Do not use the max() built-in method.
  2. Now create a similar function but for the smallest number and name it accordingly. From now on, we won't be telling you what to name your functions but make sure to do that meaningfully.
  3. Define a function that receives a list of numbers and returns a new list of even numbers. Do not modify the received list.
  4. Make a function that receives a list of numbers and filters odd numbers. Return a modified list that the function received as a parameter.
  5. Create a function that receives a string and returns a dictionary with keys as the string's each character and values as the number of times that character appears in the string. For example, passing "Apple" into the function would produce {'A': 1, 'p': 2, 'l': 1, 'e': 1}.
  6. Create a function that receives a string and returns a Boolean that indicates whether the received string is a palindrome.
  7. Define a function that received day, month, and year as parameters and returns a Boolean that indicates whether that date is valid. Do not use datetime or calendar modules.
Contribute to this lesson