Python if-else

Python if-else The else statement is associated with if statement. An else statement executes if the conditional expression in if the statement becomes false or a Zero value. If the conditional expression is false, then control transfers to the else …

Read morePython if-else

Python List

The list is one of the most versatile, mutable data-structures in Python. It can store heterogeneous data or different types of data. The list contains comma-separated values (item) within the square brackets. Creating a list in Python is simple as …

Read morePython List

Python list()

The list() class in Python creates a list object where the list object is a collection which is ordered and changeable. Syntax

Parameter Iterable: It is a required parameter which represents a sequence, collection or an iterator object Return It returns …

Read morePython list()

Python Keywords

Python Keywords Keywords are the reserved words that have special meanings to the compiler. They cannot be used as a variable. Keywords are the part of the syntax, for example:

Here return is a keyword, whereas, a and b …

Read morePython Keywords

Python if statement

Python if statement Decision making is an essential feature of any programming languages. Condition checking is the strength of decision making. Python provides many decision-making statements, such as: If statement If-else statement elif statement if statement The if statement is …

Read morePython if statement

Python elif

Python elif The elif statement is used to check multiple conditions and execute the specific block of statements depending upon the true condition among them. Syntax

The elif statement can be optional such as else. When the if expression …

Read morePython elif

Python for loop

 Python for loop A for loop in Python executes a block of code for a specified number of times, based on a given sequence. The for loop in Python is different than any other programming language like C or Pascal. …

Read morePython for loop

Python while loop

Loops are essential in Python or any other programming language, as they help to execute a block of code repetitively. Sometimes, situations arise where you would need to use a piece of code again and again, but you don’t want …

Read morePython while loop

Features of Python

Python is a powerful, easy to learn, popular programming language. It has effective data structures and its elegant syntax makes it user-friendly language. Below are the key features of Python: 1. Python is Easy When we say Python is ‘easy,’ …

Read moreFeatures of Python

PHP chop() Function

PHP chop() Function The chop() function in PHP removes whitespaces or other predefined characters from the right end of the specified string. Syntax

Parameter str(required)– This parameter specifies the string to check. charlist(optional)- This parameter represents which characters are …

Read morePHP chop() Function

Python Set difference() Method

Python Set difference() Method The set.difference() method in Python returns the set difference of two sets(A-B). Syntax

Parameter set- This argument represents a set (minuend) set1- This arguments represents a set(subtrahend) Return This method returns the difference of the …

Read morePython Set difference() Method

Python Set clear() Method

Python Set clear() Method The set.clear() method removes all the elements from the set. Syntax

Parameter NA Return None Example 1

Output

Example 2

Output Removing all the element using clear() method Set:  set() New set:  …

Read morePython Set clear() Method

Python Set add() Method

Python Set add() Method The set.add() method adds the specified element to a set. If the element is already present in the set, it doesn’t add it. Syntax

Parameter element- This parameter represents the element that is to be …

Read morePython Set add() Method

Python Set intersection() method

Python Set intersection() method The set.intersection() method in Python returns a new set with elements that are similar between two or more sets. Syntax

Parameter set1- This parameter represents the set to search for equal items. set2(optional)- This argument …

Read morePython Set intersection() method

Python Set discard() method

Python Set discard() method The set.discard() method in Python removes a specified element from the set (if present). Syntax

Parameter value- This parameter represents the element to be removed from the set. Return None Example 1

Output

Read morePython Set discard() method

Python Set difference_update() method

Python Set difference_update() method The set.difference_update() method in Python removes the items that exist in both sets. Syntax

Parameter set- This argument represents a set (minuend) set1- This arguments represents a set(subtrahend) Return None Example 1

Output

Read morePython Set difference_update() method

Python Set issubset() method

Python Set issubset() method The set.issubset() method in Python returns True if all items in the set exists in the specified set, otherwise it returns False. Syntax

Parameter set- This parameter represents the set to check whether it is …

Read morePython Set issubset() method

Python Set isdisjoint() method

Python Set isdisjoint() method The set.isdisjoint() method in Python returns a boolean value True if two sets are disjoint sets ( i.e. none of the elements are present in both sets), otherwise it returns False. Syntax

Parameter set- This …

Read morePython Set isdisjoint() method