Python Exercises
Exercises
Test your Python skills with exercises from all categories:
Get Started
Syntax
Comments
Variables
Variable Names
Multiple Variable Values
Output Variable
Global Variable
Data Types
Numbers
Casting
Strings
Slicing Strings
Modify Strings
Concatenate Strings
Format Strings
Booleans
Operators
Lists
Access Lists
Change Lists
Add List Items
Remove List Items
Loop Lists
List Comprehension
Sort Lists
Copy Lists
Join Lists
Tuples
Access Tuples
Update Tuples
Unpack Tuples
Loop Tuples
Join Tuples
Sets
Access Sets
Add Set Items
Remove Set Items
Loop Sets
Join Sets
Dictionaries
Access Dictionaries
Change Dictionaries
Add Dictionary Items
Remove Dictionary Items
Loop Dictionaries
Copy Dictionaries
Nested Dictionaries
If Else
While Loops
For Loops
Functions
Lambda
Arrays
Classes
Inheritance
Iterators
Polymorphism
Scope
Modules
Dates
Math
JSON
RegEx
PIP
Try Except
User Input
String Formatting
File Handling
Open File
Write to File
Remove File
Log in to track your progress
If you haven't already, sign up to become a W3Schooler, and get points for every exercise you complete.
As a logged on W3Schools user you will have access to many features like having your own web page, track your learning progress, receive personal guided paths, and more.
The Exercise
The exercises are a mix of "multiple choice" and "fill in the blanks" questions. There are between 3 and 9 questions in each catergory. The answer can be found in the corresponding tutorial chapter. If you're stuck, or answer wrong, you can try again or hit the "Show Answer" button to see the correct answer.