Blog

python tutorials and learn python

Created with Sketch.

Python while else

Python while else Summary: in this tutorial, you’ll learn about the Python while else statement and how to use it effectively. Introduction to Python while else statement In Python, the while statement may have an optional else clause: while condition: # code block to run else: # else clause code block Code language: PHP (php)…
Read more

Python for else

Python for else Summary: in this tutorial, you’ll learn about the Python for else statement and how to use it effectively. Introduction to the Python for else statement In Python, the for statement can have an optional else clause, which you may not be familiar with especially if you’re coming from other languages such as…
Read more

Python try…except…else

Python try…except…else Summary: in this tutorial, you’ll learn how to use the Python try…except…else statement. Introduction to the Python try…except…else statement The try statement has an optional else clause with the following syntax: try: # code that may cause errors except: # code that handle exceptions else: # code that executes when no exception occurs…
Read more

Python try…except…finally

Python try…except…finally Summary: in this tutorial, you’ll learn about the Python try…except…finally statement. Introduction to Python try…catch…finally statement The try…except statement allows you to catch one or more exceptions in the try clause and handle each of them in the except clauses. The try…except statement also has an optional clause called finally: try: # code…
Read more

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