Safa Mulani

An enthusiast in every forthcoming wonders!

Python Set Union

Union basically represents all the distinct elements of the corresponding sets altogether. Python Set union() method finds the union of the sets and represents a new set which contains all the items from the corresponding input sets. Note: If a set contains an element that appears more than once, then the output represented contains only […]

Python Set Union Read More »

Python Add to Dictionary

Python Dictionary basically contains elements in the form of key-value pairs. It is an unordered collection of items. Creation of Dictionary: Output: How to Add to Dictionary in Python By using update() method By using _setitem_() method By using subscript notation By using “*” operator 1. By Using update() Method The update() method enables the

Python Add to Dictionary Read More »

Python Set Intersection

Python Set Intersection basically finds and returns elements common among the sets. Syntax: set1.intersection(set2) is equivalent to set1 ∩ set2. Arguments: Accepts one or more sets as an argument. Return Value: Returns a set as output which contains elements common to all the sets. Ways to achieve Set Intersection in Python Either of the following

Python Set Intersection Read More »

Python print() function

Python print() function basically prints the given input or object to the output screen or the corresponding stream file. Syntax: Python print() function Arguments: Arguments Description Required/Optional object(s) An object or input string Required sep=’value‘ Specification on how the objects are to be separated.Default separator value is ‘ ‘ Optional end=’end_value’ Specifies what is to

Python print() function Read More »

Python input() function

It often happens that the developers/programmers need to accept the input from the user to process further with the application. Python provides a built-in-method to accept the input from the user. Python input() function accepts the input from the user. Python’s builtins.py contains the Python input() function. Syntax: The prompt is optional in the input()

Python input() function Read More »

Python zip() Function

Python zip() function stores data inside it. This function accepts iterable elements as input and returns an iterable as the output. If no iterable elements are provided to the python zip function, it returns an empty iterator. It thus aggregates elements from the iterables and returns iterables of tuples. Python Zip() Function Syntax: Python zip()

Python zip() Function Read More »

Python Reverse List

Python provides multiple ways to reverse the elements in a list. Python Reverse List Elements The following techniques can be used to reverse a Python List: By using the reversed() function By using the reverse() function By using Slicing technique By using for loop and range() function 1. reversed() function The reversed() method creates a

Python Reverse List Read More »

Python File Handling

What is Python File Handling? File handling is basically the management of the files on a file system. Every operating system has its own way to store files. Python File handling is useful to work with files in our programs. We don’t have to worry about the underlying operating system and its file system rules

Python File Handling Read More »

Python import Statement

Python import statement enables the user to import particular modules in the corresponding program. It resembles the #include header_file in C/C++. As soon as the interpreter encounters the import statement in a particular code, it searches for the same in the local scope and imports the module, if present in the search path. It searches

Python import Statement Read More »

Python Namedtuple

A sequence of immutable objects is a Tuple. Namedtuple enables the user to provide names to the elements in the Tuple. So, it provides the user with the option to access the elements either by index or by the designated name. Thus, it increases the readability of the code. Syntax: typename: It depicts the name

Python Namedtuple Read More »