Python for Loops
π Python for Loops The for loop in Python is used to iterate over a sequence (like a list, tuple, string, or range) and execute a block of code for each item. Β 1. Basic...
π Python for Loops The for loop in Python is used to iterate over a sequence (like a list, tuple, string, or range) and execute a block of code for each item. Β 1. Basic...
π Python while Loops The while loop in Python is used to repeatedly execute a block of code as long as a condition is True. Β 1. Basic While Loop count = 1 while count...
π Python match Statement The match statement allows you to check a value against multiple patterns and execute code for the first matching pattern. Β 1. Basic Match Statement
1 2 3 4 5 6 7 8 9 10 11 | day = "Monday" match day: case "Monday": print("Start of the week") case "Friday": print("Last working day") case "Saturday" | "Sunday": print("Weekend!") case _: print("Midweek day") |
β Output: Start of...
π Python If Statement The if statement is used to control the flow of a program based on conditions. Β 1. Basic If Statement age = 18 if age >= 18: print(“You are an adult.”)...
π Python Dictionaries β Full Tutorial A dictionary in Python is an unordered, changeable, and indexed collection that stores key-value pairs. Keys must be unique and immutable (strings, numbers, tuples). Values can be of...
π Python Sets β Complete Tutorial A set in Python is a collection of unordered, mutable, and unique items. β Key Characteristics of Sets Feature Description Unordered Items do not have a fixed position...
π Python Tuples A Python TuplesΒ is a collection of ordered, unchangeable (immutable) items. Tuples are written using parentheses (): my_tuple = (“Apple”, “Banana”, “Cherry”) β 1. Creating a Tuple fruits = (“Apple”, “Banana”, “Cherry”)...
π Python Lists β Full Tutorial A Python ListsΒ is an ordered, changeable (mutable) collection that can store multiple items of different data types. Lists are written using square brackets []: my_list = [“Apple”, “Banana”,...
π Python Operators Operators in Python are used to perform operations on variables and values. Python has 7 types of operators: Arithmetic Operators Assignment Operators Comparison (Relational) Operators Logical Operators Identity Operators Membership Operators...
π Python Booleans (True / False) Booleans represent truth values in Python. There are only two Boolean values: True False β Note: The first letter must be capital (True, not true). β Boolean Type...