Skip to main content

Posts

Showing posts with the label Python

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-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.

Learning Python Part-4: Python Keywords

Python has a set of keywords that are reserved words that cannot be used as variable names, function names, or any other identifiers They are used to define the syntax and structure of the Python language. In Python, keywords are case sensitive. There are 33 keywords in Python 3.7.  All the keywords (except True, False and None) are in lowercase. Below is the list of keywords in Python 3.7 I will not be using just syntax to explain these keywords, rather I will use some simple yet enough code examples considering new plus experienced people. For those who are new to python, if you find it difficult  to understand the complete code, just try to see the context and usage of keyword.  False :  This keyword is used to represent a boolean false. If a statement is false, “False” is printed. False in python equals to 0. True: This keyword is used to represent a boolean true. If a statement is true, “True” is printed. True in python equals to 1. None:

Learning Python: part-3 - Python Objects

Since beginning, we are referring to Object oriented language paradigm and its close relation to Python. So let's go ahead and understand, what is an Object in python language or any other OOP based programming language. According to official Python documentation:  Objects are Python's abstraction for data. All data in a Python program is represented by objects or by relations between objects."  The literal meaning of above statement sounds like everything in python is an object. Well, that may not clear the concept what exactly it means.  Let's try to understand it with some real life example. "First of all object can be anything that you wish to declare as per your program requirement. " Let's imagine you are sitting in front of your desktop computer at your office. Let's analyse before you start working. What you see? Don't shout COMPUTER :).  " I will use it later for explaining classes.  Reason?  Well

Learning Python part -2: Intro to Python

                                Python is high-level, general-purpose programming language. It was developed by Mr. Guido van Rossum and first released in 1991. Python supports multiple programming paradigms, including procedural, object-oriented, and functional programming. Python was conceived in the late 1980s as a successor to the ABC language. Python 2.0 got released in 2000. This release introduced features like list comprehensions and a garbage collection system. Python 3.0 was released in 2008 and it is considered to be a major revision of the language. Due to this Python 3 is not fully backward-compatible. Most of the Python 2 code requires modification prior to running it on Python 3. Python 2.7.x, was officially discontinued in January 2020. Python emphasises code readability as it is meant to be an easily readable language. Code formatting in Python is visually uncluttered, and it often uses English keywords where other languages use punctuation.

Learning Python part 1: Intro to programming

Welcome everyone to this series on learning python programming. This post will be the first in this series and we will see basic introduction to the world of programming before we dive deep into it. This is just to have basics sound and clear. If you are already well versed with it, feel free to skip further to required section. So without any further delay, let's get started!!!! What is a Computer program? Well, a computer program is nothing but set of instructions grouped together and executed in order to get required result.  For example, We can write a simple Calculator program code in Python as below for some mathematical operations. You can find below code at  gitHub . What is Programming? As per technical definition, computer programming is the process of designing and building an executable computer program to accomplish a specific computing result. Basically programming involves tasks such as: Information gathering, analyzing, identifying require