My Blog

    • Sample Page
Illustration of a bird flying.
  • What is a Python Set?

    A set in Python is an unordered group or collection data type that is iterable, changeable, and free of duplicate components. In Python, the set class represents the mathematical idea of a set.  The key advantage of using a set over a list is that it allows you to quickly determine if a particular member…

    February 25, 2023
  • Understanding Dictionary Methods in Python

    Python has some built-in methods that you can use in dictionaries. To return a copy of the dictionary. Code:  Output: {‘brand’: ‘Ford’, ‘model’: ‘Mustang’,’year’:1964} To return a dictionary with the keys and values supplied. Code:  Output:  [‘keys1’: 1, ‘keys2’: 1, ‘keys3’: 1] To return the value of the specified key. Code:  Output: {‘brand’: ‘Ford’, ‘model’:…

    February 25, 2023
  • How to Delete Elements from a Dictionary in Python?

    To remove elements from a Python dictionary, use one of the following methods: Using del() method The del keyword removes the item with a particular key name. Example: Output: {‘brand’: ‘Ford’, ‘year’: 1964} Using pop() method The item with the supplied key name is removed using the pop() method. Example:  Output: {‘brand’: ‘Ford’, ‘year’: 1964}…

    February 25, 2023
  • What is a Nested Dictionary in Python?

    Nested dictionaries are dictionaries that contain other dictionaries. Example:  Create a dictionary that contains three dictionaries: Output: {‘child1’: {‘name’: ‘Emil’, ‘year’: 2004}, ‘child2’: {‘name’: ‘Tobias’, ‘year’: 2007}, ‘child3’: {‘name’: ‘Linus’, ‘year’: 2011}} Video : https://youtu.be/xD_URwm5Pug

    February 25, 2023
  • How to Add an Element in Python Dictionary?

    You can change or add elements in a dictionary in Python.  By creating a new index key and providing a value to it, you can add an item to the dictionary. Example: Output: {‘brand’: ‘Ford’, ‘model’: ‘Mustang’, ‘year’: 1964, ‘color’: ‘red’} How to Update an Element in Python Dictionary? The dictionary will be updated with items…

    February 25, 2023
  • What are Dictionaries in Python?

    Dictionaries in Python are unordered sets of data values that can be used to store data values like a map. Unlike other data types, which can only carry a single value as an element, the dictionary can hold a key-value pair to make it more efficient. Accessing Elements From a Dictionary To access dictionary values…

    February 25, 2023
  • Understanding Tuple Methods in Python

    There are two types of Python tuple methods: 1. count() tuple method In this tuple method in Python, the frequency of a given value in a tuple is returned. Code: Output: 5 2. index() tuple method This tuple method is used to return the position of where a supplied value was discovered after searching the…

    February 25, 2023
  • How to Change or Delete Tuple Item Values in Python?

    Tuples are immutable, therefore you can’t remove or change items from them. However, you may use the same workaround we used to add and change tuple items.  Example: Output: (‘b’, ‘a’) Example: The del keyword can delete the tuple completely: this_tuple = (“c”, “b”, “a”) del this_tuple print(this_tuple) #this will raise an error because the…

    February 25, 2023
  • How to Concatenate Tuples in Python?

    For those wondering how to concatenate two tuples in Python, the + operator can be used to do it. Example: Output: (‘a’, ‘b’, ‘c’, 1, 2, 3)

    February 25, 2023
  • How to Unpack Tuples in Python?

    Normally, when we create a tuple, we attach values to it. A tuple is “packed” in this way. However, we can also extract the values and store them in variables. This is referred to as the unpacking of tuples in Python. Example: Output: cranberry blueberry apricot

    February 25, 2023
←Previous Page
1 … 3 4 5 6 7 … 113
Next Page→

My Blog

Proudly powered by WordPress