Posts

Functions And Docstrings IN PYTHON

  Functions And Docstrings  “Functions in Python can be defined as lines of codes that are built to create a specific task and can be used again and again in a program when called.” There are two types of functions in the Python language: Built-in functions User-defined functions We have used a lot of built-in functions in our code till now, these functions include print(), or sum(), etc. So, we have a good idea about how to call a function. Built-in functions are already present in our python program, and we just have to call them whenever we need them to execute. Being familiar with built-in functions we will now look into User-defined function mostly in this tutorial. We must know how to define a function in Python. In order to create one ourselves, we have to use the def keyword in order to define a function accompanied by the function's name with a pair of parentheses. The function of parenthesis is to send arguments or parameters to a function. In simple words, parameter...

Short Hand If Else Notation In Python

  Short Hand If Else Notation In Python Before going through the if-else short-hand statement, we must be familiar with the basic definition, so that we can know what the short-hand statement actually is. In basic English, shorthand can be said as “a basic way of writing using abbreviations or symbols”. For example, we do not use the full name, Kentucky Fried Chicken, instead we use its abbreviation that is KFC. Writing in such a compact manner is known as shorthand. Now let us move towards the definition of shorthand with respect to the Python language. “An executable statement, written in so compact manner that it comprises of only a single line of code is known as shorthand statement.” Python supports many sorts of shorthand statements and with the help of these statements, we can write our code in a more compact sort or form using less space. We learned the original form of “if and else” statement in tutorial #13 of our playlist, we can also write it in a shorthand form of code...

OPERATORS IN PYTHON

  Operators In Python Today's tutorial is more about theoretical learning than coding because we must have basic knowledge about what we are actually implementing in our code because if our basis is strong then only we can make an efficient program of a larger scale. “Operators in Python can be defined as symbols that assist us to perform certain operations. The operations can be between variable and variable, variable and value, value and value” Operators that Python Language supports are: Arithmetic Operators Assignment Operators Comparison Operators Logical Operators Identity Operators Membership Operators Bitwise Operators We must remember most of them from our basic mathematics that we studied in school. May be except the last one, that might be new for some of us. To understand bitwise fully, we must have the basic knowledge of the conversion of decimal into binary. For example, the binary for the first five number is: 0001 0010 0011 0100 0101 And so on. Now I will give you a...

BREAK AND CONTINUE STATEMENT IN PYTHON

  Break & Continue Statements In Python “Break and continue statements are used to alter the flow or normal working of a loop, that could be either a “for loop” or “while loop”. If you are not familiar with the concept of loops, I recommend you go through Tutorial numbers 16 and 17 of Python Tutorials For Absolute Beginners In Hindi Playlist. You all know what break and continue mean in the basic English language. Break means interrupt and continue means resuming after an interrupt as the meanings of the words can describe that both these functions are totally opposite to each other. Hence, both of these keywords are mostly defined together, like “if and else” or “try and except,” but unlike the others, their functionality is quite the opposite of each other. They aren’t even used together in most of the cases like “except”, could only be used if there is “try” or “else” condition and if there isn’t “if” statement present, but in cases of “break and continue", they both do not...

WHILE LOOP IN PYTHON

  While Loops In Python Now, as we know now what loops are and why they are used, in this section, I will go directly towards the working and syntax of while loop along with its comparison with for loop and where to use it. “A while loop in python runs a bunch of code or statements again and again until the given condition is true when the condition becomes false, the loop terminates its repetition.” The syntax for a while loop is simple and very much like for loop. We have to use the keyword “while”, along with it, we have to put a condition in parenthesis, and after that, a colon is placed. The condition could be either true or false. Until the condition is true, the loop will keep on executing again and again. If we use a certain condition in our while loop that never becomes false, the program will continue running endlessly until we stop it by force. So, this kind of mistake in our syntax is known as logical/human error. To terminate an infinite loop, you can press  Ctrl+...

FOR LOOPS IN PYTHON

  For Loops In Python Starting with the technical definition of for loops: Like all the other functions we have seen so far in the video tutorials, for loop is also just a programming function that iterates a statement or a number of statements based on specific boundaries under certain defined conditions, which are the loop's basis. Note that the statement that the loop iterates must be present inside the body of the loop. Regarding loops, iteration means going through some chunk of code again and again. In programming, it has the same meaning, the only difference is that the iteration depends upon certain conditions, and upon its fulfillment, the iteration stops, and the compiler moves forward. For a beginner or layman, the concept of the loop could be easily understood using an example of the song's playlist. When we like a song, we set it on repeat, and then it automatically starts playing again and again. The same concept is used in programming, we set a part of code for l...