Skip to main content


Showing posts from April, 2020

Learning Python Part-8: Python Variables and Python Constants

It is not possible every time for programmer or user to provide input values to be used in program for some operations. This approach is fine when we are working in interactive mode or testing some small programs. However, in realtime scenarios, most of the times we need to provide and store the values in memory and are used later at the time of executing instructions. Python Variables: Variables acts a container that holds data which can be changed later throughout programming.  For example,  num = 4 (in above example, “num” is variable that holds value 4 as data and = is an assignment operator ) We can assign multiple variables with different values as below a = 2 b = 6.6 c = "Python" Or another simple way,  a, b, c = 2, 6.6, ”Python" Also same value can be assigned to multiple variables as below x = y = z = ”python” As you may have notice in above examples, value assigned to a variable, can be integer or float or string and others

Learning Python Part-7: Python Identifiers

As we discussed earlier, in python programming, we use Object Oriented Programming (OOP) extensively. So before we go ahead and start creating objects like variables, classes or functions, we need to understand few basic considerations about how to set identifiers. In other words, naming convention rules for objects. Try to use names that helps to understand purpose of it in the code. Identifiers can be a combination of letters (a to z) or (A to Z),digits (0 to 9), and an underscore _.  An identifier cannot start with a digit.  Invalid name example:  1variable Keywords cannot be used as identifiers. Python Keywords are reserved and connote be used as identifiers We cannot use special symbols like !, @, #, $, % etc. in our identifier. Identifier can be of any length.

Learning Python Part-6: Python Comments

When it comes to writing a python program, based on the requirements, programs can simple programs of limited number of  lines or it can be really large program which might even span multiple python modules. Now the point here is that, even if we know how to write the program and even we follow correct concepts and syntaxes while writing program, we cannot keep it in our mind forever. We cannot remember each and everything about the program like variables, classes, concepts, functions and so on after some period of time. If the program written by us at some point in time back, once we open it after a period of time, it should not be a situation that we are blank, or guessing why particular code, function and so on. Even it may happen that you are working in a team and program code writing tasks might be shared. So when you put all pieces together written by multiple programmers in your team, you should be able to understand the code. This is where we bring in the concepts of

Learning Python - Part-5: Python Interfaces

When it comes to working with python, we can always use interactive mode by launching python  or Python3 command as shown in below screenshot.  Image: 1 Once launched we can run all sorts of python operations, however, this approach is not used for development work.  When it comes to writing programs, we generally prefer editors. In fact we can use basic editors like notepad(Windows)/vi editors(Linux). In these editors, once we are done with writing programs, we need to make sure files are stored as .py extension ( Image: 2 ). We simply run python command to execute the programs as shown in below screenshot ( Image: 3 ). Image: 2 Image: 3 Though using normal editors is fine, but when it comes to writing simple, large or complex programs, these basic editors do not offer help or suggestions or correction while writing code. That is where the need of tools that help during programming arises. Below are some of the code editors and IDEs that are widely used.