Category: New Python tutorial

python tutorials and learn python

Created with Sketch.

Python try…except

Python try…except Summary: in this tutorial, you’ll learn how to use the Python try…except statement to handle exceptions gracefully. In Python, there’re two main kinds of errors: syntax errors and exceptions. Syntax errors When you write an invalid Python code, you’ll get a syntax error. For example: current = 1 if current < 10 current…
Read more

Python Disjoint Sets

Python Disjoint Sets Summary: in this tutorial, you’ll learn about disjoint sets and how to use the Python isdisjoint() method to check if two sets are disjoint. Introduction to Python disjoint sets Two sets are disjoint when they have no elements in common. In other words, two disjoint sets are sets whose intersection is an…
Read more

Python issuperset

Python issuperset Summary: in this tutorial, you’ll learn how to use the Python issuperset() method to check if a set is a superset of another. Introduction to Python issuperset method Suppose that you have two sets: A and B. Set A is a superset of set B if all elements of set B are elements…
Read more

Python issubset

Python issubset Summary: in this tutorial, you’ll learn about how to use the Python issubset() method to check if a set is a subset of another set. Introduction to the Python issubset() method Suppose that you have two sets A and B. Set A is a subset of set B if all elements of A…
Read more

Python Symmetric Difference

Python Symmetric Difference Summary: in this tutorial, you’ll learn how to find the symmetric difference of two or more sets in Python. Introduction to the symmetric difference of sets The symmetric difference of two sets is a set of elements that are in either set, but not in their intersection. Suppose that you have the…
Read more

Python Set Difference

Python Set Difference Summary: in this tutorial, you’ll learn about the Python Set difference and how to use it to find the difference between two or more sets. Introduction to the Python Set difference The difference between the two sets results in a new set that has elements from the first set which aren’t present…
Read more

Python Set Intersection

Python Set Intersection Summary: in this tutorial, you’ll learn about the Python set intersection and how to use it to intersect two or more sets. TL;DR In Python, you can use the set intersection() method or set intersection operator (&) to intersect two or more sets: new_set = set1.intersection(set2, set3) new_set = set1 & set2…
Read more

Python Set Union

Python Set Union Summary: in this tutorial, you’ll learn how to union two or more sets by using the Python set union() or set union operator (|). Introduction to the set union The union of two sets returns a new set that contains distinct elements from both sets. Suppose that you have the following sets:…
Read more

Python Set Comprehension

Python Set Comprehension Summary: in this tutorial, you’ll learn how to use the Python set comprehension to create a new set based on an existing one. Introduction to Python Set comprehension Suppose that you have the following set that consists of three tags: tags = {‘Django’, ‘Pandas’, ‘Numpy’} Code language: Python (python) To convert the…
Read more

Python Set

Python Set Summary: in this tutorial, you’ll learn about Python Set type and how to use it effectively. Introduction to the Python Set type A Python set is an unordered list of immutable elements. It means: Elements in a set are unordered. Elements in a set are unique. A set doesn’t allow duplicate elements. Elements…
Read more