Beginner Python Exercises w/ Solutions | HolyPython.com (original) (raw)
First batch of the exercises starts with print function as a warm up but quickly, it becomes all about data.
You can start exercising with making variable assignments and move on with the most fundamental data types in Python:
- integers
- floats
- strings
Exercise 1: print() function | (3) : Get your feet wet and have some fun with the universal first step of programming.
Exercise 2: Variables | (2) : Practice assigning data to variables with these Python exercises.
Exercise 3: Data Types | (4) : Integer (int), string (str) and float are the most basic and fundamental building blocks of data in Python.
Exercise 4: Type Conversion | (8) : Practice converting between basic data types of Python when applicable.
Exercise 5: Data Structures | (6) : Next stop is exercises of most commonly used Python Data Structures. Namely;
- Lists,
- Tuples,
- Dictionaries and
- Strings are placed under the microscope.
Exercise 6: Lists | (14) : It’s hard to overdo Python list exercises. They are fun and very fundamental so we prepared lots of them. You will also have the opportunity to practice various Python list methods.
Exercise 7: Tuples | (8) : Python Tuples Exercises with basic applications as well as common tuples methods
Exercise 8: Dictionaries | (11) : Practice with Python Dictionaries and some common dictionary methods.
Exercise 9: Strings | (14) : Basic string operations as well as many string methods can be practiced through 10+ Python String Exercises we have prepared for you.
Next batch consist of some builtin Python functions and Python methods. The difference between function and method in Python is that functions are more like standalone blocks of codes that take arguments while methods apply directly on a class of objects.
That’s why we can talk about list methods, string methods, dictionary methods in Python but functions can be used alone as long as appropriate arguments are passed in them.
Exercise 10: len() function | (5) : Python’s len function tells the length of an object. It’s definitely a must know and very useful in endless scenarios. Whether it’s manipulating strings or counting elements in a list, len function is constantly used in computer programming.
Exercise 11: .sort() method | (7) : Practice sort method in Beginner Python Exercises and later on you’ll have the opportunity practice sorted function in Intermediate Python Exercises.
Exercise 12: .pop() method | (3) : A list method pop can be applied to Python list objects. It’s pretty straightforward but actually easy to confuse. These exercises will help you understand pop method better.
Exercise 13: input() function | (6) : Input function is a fun and useful Python function that can be used to acquire input values from the user.
Exercise 14: range() function | (5) : You might want to take a real close look at range function because it can be very useful in numerous scenarios.
These range exercises offer an opportunity to get a good practice and become proficient with the usage of Python’s range function.
Exercise 15: Error Handling | (7) : Error Handling is a must know coding skill and Python has some very explanatory Error Codes that will make a coder’s life easier if he/she knows them!
Exercise 16: Defining Functions | (9) : Practicing user defined Python functions will take your programming skills to the next step. Writing functions are super useful and fun. It makes code reusable too.
Exercise 17: Python Slicing Notation | (8) : Python’s slicing notations are very interesting but can be confusing for beginner coders. These exercises will help you master them.
Exercise 18: Python Operators | (6) : Operators are another fundamental concept. We have prepared multiple exercises so they can be confident in using Python Operators.