Posts

Showing posts from December, 2020

What is the use of file handling in Python?

Python provides us with an important feature for reading data from the file and writing data into a file Mostly, in programming languages, all the values or data are stored in some variables which are volatile in nature.  Because data will be stored into those variables during run-time only and will be lost once the program execution is completed.  Hence it is better to save these data permanently using files.  Best Python Training Institute in Gurgaon... 0.1.1 How Python Handle Files?  If you are working in a large software application where they process a large number of data, then we cannot expect those data to be stored in a variable as the variables are volatile in nature.  Hence when are you about to handle such situations, the role of files will come into the picture.  As files are non-volatile in nature, the data will be stored permanently in a secondary device like Hard Disk and using python we will handle these files in our applications  Type...

What is Python Nested for Loop?

  Nested For Loop Nested For Loops Loops can be nested in Python, as they can with other programming languages. The program first encounters the outer loop, executing its first iteration. This first iteration triggers the inner, nested loop, which then runs to completion.   A for loop implements the repeated execution of code based on a loop counter or loop variable. This means that for loops are used most often when the number of iterations is known before entering the loop, unlike while loops which are conditionally based.   You can also nest a loop inside another. You can put a for loop inside a while, or a while inside a for loop.   Best Python Training Institute in Gurgaon... 0.0.1              Syntax: for [first variable] in [outer loop]: # Outer loop [statement of outer loop] # Optional for [second variable] in [nested loop]:   # Nest...

What is else statement in Python?

Decision making is required when we want to execute a code only if a certain condition is satisfied. The if…elif…else statement is used in Python for decision making. Python if Statement Syntax if test expression: statement(s) •         Here, the program evaluates the test expression and will execute statement(s) only if the text expression is True. •         If the text expression is False, the statement(s) is not executed. •         In Python, the body of the if statement is indicated by the indentation. Body starts with an indentation and the first unindented line marks the end. •         Python interprets non-zero values as True. None and 0 are interpreted as False. Python if Statement Flowchart  Best Python Training Institute in Gurgaon [5]:  Example: Python if Statement ...

What is Python Polymorphism?

The literal meaning of polymorphism is the condition of occurrence in different forms. Polymorphism is a very important concept in programming. It refers to the use of a single type entity  (method, operator or object) to represent different types in different scenarios.   Best Python Training Institute in Gurgaon... Example 1: Polymorphism in addition operator [3]:  # For integer data types, + operator is used to perform arithmetic addition ␣ ‹→ operation. num1 = 1 num2 = 2 print (num1 + num2) [5]:  # Similarly, for string data types, + operator is used to perform concatenation. str1 = "Eddy" str2 = "Grant" print (str1 + " " + str2) Eddy Grant Here, we can see that a single operator + has been used to carry out different operations for distinct data  types. This is one of the most simple occurrences of polymorphism in Python. 0.1            Function Polymorphism in Python Ther...