Python tutorials

Using Python’s .__dict__ to Work With Attributes

Python’s .__dict__ is a special attribute in classes and instances that acts as a namespace, mapping attribute names to their corresponding values. You can use .__dict__ to inspect, modify, add, or delete attributes dynamically, which makes it a versatile tool for metaprogramming and debugging. In this tutorial, you’ll learn about using .__dict__ in various contexts, including classes, instances, and functions. You’ll also explore its role in inheritance with practical examples and comparisons to other tools for manipulating attributes. By the […]

Read more

Checking for Membership Using Python’s “in” and “not in” Operators

Python’s in and not in operators allow you to quickly check if a given value is or isn’t part of a collection of values. This type of check is generally known as a membership test in Python. Therefore, these operators are known as membership operators. By the end of this video course, you’ll understand that: The in operator in Python is a membership operator used to check if a value is part of a collection. You can write not in […]

Read more

Python News Roundup: April 2025

Last month brought significant progress toward Python 3.14, exciting news from PyCon US, notable community awards, and important updates to several popular Python libraries. In this news roundup, you’ll catch up on the latest Python 3.14.0a6 developments, discover which PEP has been accepted, celebrate record-breaking community support for PyCon travel grants, and explore recent updates to popular libraries. Let’s dive in! Python 3.14.0a6 Released on Pi Day The Python development team has rolled out the sixth alpha version of Python […]

Read more

How to Strip Characters From a Python String

By default, Python’s .strip() method removes whitespace characters from both ends of a string. To remove different characters, you can pass a string as an argument that specifies a set of characters to remove. The .strip() method is useful for tasks like cleaning user input, standardizing filenames, and preparing data for storage. By the end of this tutorial, you’ll understand that: The .strip() method removes leading and trailing whitespace but doesn’t remove whitespace from the middle of a string. You […]

Read more

Building a Code Image Generator With Python

If you’re active on social media, then you know that images and videos are popular forms of content. As a programmer, you mainly work with text, so sharing the content that you create on a daily basis may not seem intuitive. That’s where a code image generator comes in handy! A code image generator allows you to turn your code snippets into visually appealing images, so you can share your work without worrying about formatting issues, syntax highlighting inconsistencies, or […]

Read more

Python’s Bytearray: A Mutable Sequence of Bytes

Python’s bytearray is a mutable sequence of bytes that allows you to manipulate binary data efficiently. Unlike immutable bytes, bytearray can be modified in place, making it suitable for tasks requiring frequent updates to byte sequences. You can create a bytearray using the bytearray() constructor with various arguments or from a string of hexadecimal digits using .fromhex(). This tutorial explores creating, modifying, and using bytearray objects in Python. You’ll dive deeper into each aspect of bytearray, exploring its creation, manipulation, […]

Read more

Quiz: Using Python’s .__dict__ to Work With Attributes

Interactive Quiz ⋅ 9 QuestionsBy Leodanis Pozo Ramos Share In this quiz, you’ll test your understanding of Using Python’s .__dict__ to Work With Attributes. By working through this quiz, you’ll revisit how .__dict__ holds an object’s writable attributes, allowing for dynamic manipulation and introspection. You’ll also review how both vars() and .__dict__ let you inspect an object’s attributes, and the common use cases of .__dict__ in Python applications. The quiz contains 9 questions and there is no time limit. You’ll […]

Read more

Quiz: Dictionaries in Python

Interactive Quiz ⋅ 14 QuestionsBy Leodanis Pozo Ramos Share In this quiz, you’ll test your understanding of Dictionaries in Python. By working through this quiz, you’ll revisit how to create dictionaries using literals and the dict() constructor, how to use Python’s operators and built-in functions to manipulate them, and how they’re implemented as a hash map for fast key lookups. The quiz contains 14 questions and there is no time limit. You’ll get 1 point for each correct answer. At […]

Read more

Quiz: Python’s Instance, Class, and Static Methods Demystified

Interactive Quiz ⋅ 6 QuestionsBy Martin Breuss Share In this quiz, you’ll test your understanding of Instance, Class, and Static Methods in Python. By working through this quiz, you’ll revisit the differences between these methods and how to use them effectively in your Python code. The quiz contains 6 questions and there is no time limit. You’ll get 1 point for each correct answer. At the end of the quiz, you’ll receive a total score. The maximum score is 100%. […]

Read more

Quiz: Python Set Comprehensions: How and When to Use Them

Interactive Quiz ⋅ 5 QuestionsBy Leodanis Pozo Ramos Share In this quiz, you’ll test your understanding of Python Set Comprehensions: How and When to Use Them. Set comprehensions are a concise and quick way to create, transform, and filter sets in Python. They can significantly enhance your code’s conciseness and readability compared to using regular for loops to process your sets. The quiz contains 5 questions and there is no time limit. You’ll get 1 point for each correct answer. […]

Read more
1 2 3 189