Python tutorials

Quiz: How Can You Structure Your Python Script?

Interactive Quiz ⋅ 11 QuestionsBy Bartosz Zaczyński Share In this quiz, you’ll test your understanding of the tutorial How Can You Structure Your Python Script? By working through this quiz, you’ll revisit best practices for organizing your Python scripts, including setting up the main entry point, using imports effectively, and writing code that can be reused as modules or run as standalone scripts. The quiz contains 11 questions and there is no time limit. You’ll get 1 point for each […]

Read more

Execute Your Python Scripts With a Shebang

In shell scripts, the shebang line (#!) specifies the path to the interpreter that should execute the file. You can place it at the top of your Python file to tell the shell how to run your script, allowing you to execute the script directly without typing python before the script name. The shebang is essential for Unix-like systems but ignored on Windows unless using specific compatibility layers. By the end of this video course, you’ll understand that: A shebang […]

Read more

How Can You Structure Your Python Script?

You may have begun your Python journey interactively, exploring ideas within Jupyter Notebooks or through the Python REPL. While that’s great for quick experimentation and immediate feedback, you’ll likely find yourself saving code into .py files. However, as your codebase grows, your Python script structure efficiency becomes increasingly important. Transitioning from interactive environments to structured scripts helps promote readability, enabling better collaboration and more robust development practices. This tutorial transforms messy scripts into well-organized, shareable code. Along the way, you’ll […]

Read more

Quiz: Control Flow Structures in Python

Interactive Quiz ⋅ 11 QuestionsBy Leodanis Pozo Ramos Share In this quiz, you’ll test your understanding of control flow structures in Python. Control flow dictates the order in which your code executes, letting you make choices, repeat work, and handle exceptions to build more flexible, reliable programs. For hands-on examples and a deeper dive, check out the tutorial Control Flow Structures in Python. The quiz contains 11 questions and there is no time limit. You’ll get 1 point for each […]

Read more

Control Flow Structures in Python

Python’s control flow structures allow you to dictate the order in which statements execute in your program. You can do this by using structures like conditionals, loops, and others. Normally, your code executes sequentially. You can modify this behavior using control flow structures that let you make decisions, run specific pieces of code in response to certain conditions, repeat a code block several times, and more. Knowing about control flow structures is a fundamental skill for you as a Python […]

Read more

The LEGB Rule & Understanding Python Scope

The concept of scope rules how variables and names are looked up in your code. It determines the visibility of a variable within the code. The scope of a name or variable depends on the place in your code where you create that variable. The Python scope concept is generally presented using a rule known as the LEGB rule. The letters in the acronym LEGB stand for Local, Enclosing, Global, and Built-in scopes. This summarizes not only the Python scope […]

Read more

Quiz: Marimo: A Reactive, Reproducible Notebook

Interactive Quiz ⋅ 10 QuestionsBy Ian Eyre Share Why not challenge yourself and see how much you know about marimo notebooks? Working your way through this quiz is a great way to reinforce and build on what you learned in the Marimo: A Reactive, Reproducible Notebook tutorial. You could try answering the questions without reading the tutorial first, but you’d miss out on a great learning experience! The quiz contains 10 questions and there is no time limit. You’ll get […]

Read more

Marimo: A Reactive, Reproducible Notebook

Marimo notebooks redefine the notebook experience by offering a reactive environment that addresses the limitations of traditional linear notebooks. With marimo, you can seamlessly reproduce and share content while benefiting from automatic cell updates and a correct execution order. Discover how marimo’s features make it an ideal tool for documenting research and learning activities. Before you can get started with marimo, you’ll need to install it. Fortunately, this is quick and easy to do: You use pip to install the […]

Read more

Loading Pydantic models from JSON without running out of memory

You have a large JSON file, and you want to load the data into Pydantic. Unfortunately, this uses a lot of memory, to the point where large JSON files are very difficult to read. What to do? Assuming you’re stuck with JSON, in this article we’ll cover: The high memory usage you get with Pydantic’s default JSON loading. How to reduce memory usage by switching to another JSON library. Going further by switching to dataclasses with slots. The problem: 20× […]

Read more

Quiz: Nested Loops in Python

Interactive Quiz ⋅ 5 QuestionsBy Philipp Acsany Share In this quiz, you’ll test your understanding of Nested Loops in Python. Nested loops in Python involve placing one loop inside another, enabling iteration over multiple sequences or repeated actions. They’re particularly useful for handling multidimensional data, generating patterns, and performing repetitive tasks with multiple layers of iteration. The quiz contains 5 questions and there is no time limit. You’ll get 1 point for each correct answer. At the end of the […]

Read more
1 2 3 4 193