29 May 2023 Juliano Luiz Faccioni How to Append to a String in Python Find out how to append to a string in Python and concatenate strings in this article. We compare the different string appending methods and discuss which one you should use in each situation. Strings are one of the most basic data types in Python. But even experienced Python programmers may be confused about how to append text to the end of a string; unlike lists, strings do not have an append() method. Read more 6 Mar 2023 Juliano Luiz Faccioni How to Write the Python if Statement in one Line Have you ever heard of writing a Python if statement in a single line? Here, we explore multiple ways to do exactly that, including using conditional expressions in Python. The if statement is one of the most fundamental statements in Python. In this article, we learn how to write the Python if in one line. The if is a key piece in writing Python code. It allows developers to control the flow and logic of their code based on information received at runtime. Read more 23 Jan 2023 Juliano Luiz Faccioni A Guide to the Python csv Module What are CSV files, and how can you use Python alongside them? Learn how to use the csv module to read and work with CSV files in Python. You have probably seen tabular data before: it’s simply rows and columns containing some data. (Think of a table in an article or an Excel spreadsheet.) CSV files are one of the most common types of tables used by data scientists, but they can be daunting if you don’t know exactly how they work or how to use them alongside Python. Read more 26 Dec 2022 Juliano Luiz Faccioni How to Filter a Python Dictionary Learn how to build your own filters with multiple conditions, then use them to filter Python dictionaries by any combination of keys and values. Python dictionaries are extremely versatile. They can hold a variety of data types and are used to model many different real-world objects and relations. It is no surprise, then, that we want to perform specific operations (like filtering) on Python dictionaries. Filtering a dictionary in Python can be especially tricky because they can be filtered by key, values, or both, using an arbitrary number of conditions. Read more 30 Nov 2022 Juliano Luiz Faccioni How to Loop Over Multiple Lists in Python Learn how to loop over multiple lists side-by-side in Python – one element at a time. These techniques will work even if the lists have different lengths! Looping over lists is one of the most basic skills in Python. In some situations, you may find yourself having to loop over multiple lists side-by-side, taking one element from each list and performing an operation with it. If you’re new to Python, it is not always obvious how to do that or what caveats and best practices exist for this task. Read more 23 Nov 2022 Juliano Luiz Faccioni Python Scripts vs. Jupyter Notebooks: Pros and Cons Learn the ins and outs of Python scripts and Jupyter Notebooks, including when to use each one. There are many tools available to Python developers. Since this language’s early days, Python scripts have been the canonical way of writing and sharing Python code. But in the past few years, Jupyter Notebooks have gained considerable recognition among data scientists as a powerful tool for testing ideas and sharing results. But what exactly sets Jupyter Notebooks apart from Python scripts? Read more 29 Oct 2022 Juliano Luiz Faccioni A Brief Guide to Python Exceptions Confused about programming errors? In this article, you’ll learn what Python exceptions are, how to deal with them, and how to leverage them when writing and organizing your code. Errors are very common in programming. In Python, we use the term “exception” for errors that happen during code execution. Be it a typo, a coding distraction, or because the code reached an invalid state, it is inevitable: the more you write Python programs, the more you will have to face and handle Python exceptions. Read more 28 Sep 2022 Juliano Luiz Faccioni An Overview of Python List Methods Learn how to modify lists in Python using list methods – specialized operations that give you tons of flexibility. Python lists have a lot of functionality that you can leverage in your scripts. This includes common sequence operations like adding elements to a list, reordering elements, and counting the number of times a given element appears in a list. Collectively, these operations are called list methods. In this article, we will go through an overview of Python’s main list methods. Read more 7 Sep 2022 Juliano Luiz Faccioni How to Reverse a Range in Python Find out how to reverse a range in Python and learn more about the range(), reversed(), and sorted() functions. Early in your Python journey, you’ll start working with sequences and ranges. At some point, you may wonder ‘How would I get these values in the reverse order?’. If you think about it, we reverse ranges constantly: when we sort files in our computer from ascending to descending order, we effectively reverse their original order. Read more 8 Aug 2022 Juliano Luiz Faccioni Python Set Operations Explained With Examples Having a hard time wrapping your head around set operations in Python? This article will help you visualize and understand Python set operations! Python sets are useful data structures when you need to create and compare groups of elements. These tasks can be performed with set operations like union and intersection. However, using Python set operations may not be a straightforward task when you’re first starting out with Python itself. Read more «« « 1 2 » »»