Menu
×
   ❮     
HTML CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C C++ C# BOOTSTRAP REACT MYSQL JQUERY EXCEL XML DJANGO NUMPY PANDAS NODEJS DSA TYPESCRIPT ANGULAR ANGULARJS GIT POSTGRESQL MONGODB ASP AI R GO KOTLIN SASS VUE GEN AI SCIPY CYBERSECURITY DATA SCIENCE INTRO TO PROGRAMMING BASH RUST

Python Tutorial

Python HOME Python Intro Python Get Started Python Syntax Python Output Python Comments Python Variables Python Data Types Python Numbers Python Casting Python Strings Python Booleans Python Operators Python Lists Python Tuples Python Sets Python Dictionaries Python If...Else Python Match Python While Loops Python For Loops Python Functions Python Range Python Arrays Python Iterators Python Modules Python Dates Python Math Python JSON Python RegEx Python PIP Python Try...Except Python String Formatting Python None Python User Input Python VirtualEnv

Python Classes

Python OOP Python Classes/Objects Python __init__ Method Python self Parameter Python Class Properties Python Class Methods Python Inheritance Python Polymorphism Python Encapsulation Python Inner Classes

File Handling

Python File Handling Python Read Files Python Write/Create Files Python Delete Files

Python Modules

NumPy Tutorial Pandas Tutorial SciPy Tutorial Django Tutorial

Python Matplotlib

Matplotlib Intro Matplotlib Get Started Matplotlib Pyplot Matplotlib Plotting Matplotlib Markers Matplotlib Line Matplotlib Labels Matplotlib Grid Matplotlib Subplot Matplotlib Scatter Matplotlib Bars Matplotlib Histograms Matplotlib Pie Charts

Machine Learning

Getting Started Mean Median Mode Standard Deviation Percentile Data Distribution Normal Data Distribution Scatter Plot Linear Regression Polynomial Regression Multiple Regression Scale Train/Test Decision Tree Confusion Matrix Hierarchical Clustering Logistic Regression Grid Search Categorical Data K-means Bootstrap Aggregation Cross Validation AUC - ROC Curve K-nearest neighbors

Python DSA

Python DSA Lists and Arrays Stacks Queues Linked Lists Hash Tables Trees Binary Trees Binary Search Trees AVL Trees Graphs Linear Search Binary Search Bubble Sort Selection Sort Insertion Sort Quick Sort Counting Sort Radix Sort Merge Sort

Python MySQL

MySQL Get Started MySQL Create Database MySQL Create Table MySQL Insert MySQL Select MySQL Where MySQL Order By MySQL Delete MySQL Drop Table MySQL Update MySQL Limit MySQL Join

Python MongoDB

MongoDB Get Started MongoDB Create DB MongoDB Collection MongoDB Insert MongoDB Find MongoDB Query MongoDB Sort MongoDB Delete MongoDB Drop Collection MongoDB Update MongoDB Limit

Python Reference

Python Overview Python Built-in Functions Python String Methods Python List Methods Python Dictionary Methods Python Tuple Methods Python Set Methods Python File Methods Python Keywords Python Exceptions Python Glossary

Module Reference

Built-in Modules Random Module Requests Module Statistics Module Math Module cMath Module

Python How To

Remove List Duplicates Reverse a String Add Two Numbers

Python Examples

Python Examples Python Compiler Python Exercises Python Quiz Python Server Python Syllabus Python Study Plan Python Interview Q&A Python Bootcamp Python Certificate Python Training

Python Exercises


Test your Python skills with exercises from all categories:

Exercises

Tip: Sign in to track your progress - it's free.

0/99 done

Get Started3 exercises

Done

Syntax3 exercises

Done

Comments3 exercises

Done

Variables4 exercises

Done

Variable Names3 exercises

Done

Multiple Variable Values3 exercises

Done

Output Variable3 exercises

Done

Global Variable3 exercises

Done

Data Types8 exercises

Done

Numbers4 exercises

Done

Casting3 exercises

Done

Strings4 exercises

Done

Slicing Strings3 exercises

Done

Modify Strings5 exercises

Done

Concatenate Strings3 exercises

Done

Format Strings3 exercises

Done

Booleans6 exercises

Done

Arithmetic Operators5 exercises

Done

Assignment Operators4 exercises

Done

Comparison Operators4 exercises

Done

Logical Operators4 exercises

Done

Identity Operators3 exercises

Done

Membership Operators4 exercises

Done

Bitwise Operators3 exercises

Done

Operator Precedence3 exercises

Done

Lists4 exercises

Done

Access Lists4 exercises

Done

Change Lists3 exercises

Done

Add List Items4 exercises

Done

Remove List Items4 exercises

Done

Loop Lists3 exercises

Done

List Comprehension3 exercises

Done

Sort Lists3 exercises

Done

Copy Lists3 exercises

Done

Join Lists3 exercises

Done

Tuples3 exercises

Done

Access Tuples4 exercises

Done

Update Tuples3 exercises

Done

Unpack Tuples3 exercises

Done

Loop Tuples3 exercises

Done

Join Tuples3 exercises

Done

Sets4 exercises

Done

Access Sets3 exercises

Done

Add Set Items3 exercises

Done

Remove Set Items4 exercises

Done

Loop Sets3 exercises

Done

Join Sets3 exercises

Done

Frozenset3 exercises

Done

Dictionaries4 exercises

Done

Access Dictionaries3 exercises

Done

Change Dictionaries3 exercises

Done

Add Dictionary Items3 exercises

Done

Remove Dictionary Items4 exercises

Done

Loop Dictionaries4 exercises

Done

Copy Dictionaries3 exercises

Done

Nested Dictionaries3 exercises

Done

If6 exercises

Done

Elif4 exercises

Done

Else5 exercises

Done

Shorthand If3 exercises

Done

Logical6 exercises

Done

Nested If3 exercises

Done

Pass3 exercises

Done

Match3 exercises

Done

While Loops5 exercises

Done

For Loops5 exercises

Done

Functions3 exercises

Done

Args / Kwargs3 exercises

Done

Args / Kwargs3 exercises

Done

Decorators3 exercises

Done

Scope3 exercises

Done

Lambda4 exercises

Done

Range3 exercises

Done

Arrays3 exercises

Done

Iterators3 exercises

Done

Modules5 exercises

Done

Dates4 exercises

Done

Math4 exercises

Done

JSON3 exercises

Done

RegEx4 exercises

Done

PIP3 exercises

Done

Try Except3 exercises

Done

None3 exercises

Done

User Input3 exercises

Done

String Formatting4 exercises

Done

Virtual Environment3 exercises

Done

Classes4 exercises

Done

__init__ Method4 exercises

Done

Self Parameter3 exercises

Done

Class Properties3 exercises

Done

Class Methods5 exercises

Done

Inheritance3 exercises

Done

Polymorphism3 exercises

Done

Encapsulation3 exercises

Done

Inner Class3 exercises

Done

File Handling3 exercises

Done

Open File3 exercises

Done

Write to File3 exercises

Done

Remove File3 exercises

Done

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


Kickstart your career

Get certified by completing the course

Get certified w3schools CERTIFIED . 2025

×

Contact Sales

If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail:
sales@w3schools.com

Report Error

If you want to report an error, or if you want to make a suggestion, send us an e-mail:
help@w3schools.com

W3Schools is optimized for learning and training. Examples might be simplified to improve reading and learning. Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. While using W3Schools, you agree to have read and accepted our terms of use, cookie and privacy policy.

Copyright 1999-2025 by Refsnes Data. All Rights Reserved. W3Schools is Powered by W3.CSS.