Learning Python - Day 2

Learning Python - Day 2

What is python?

No alt text provided for this image

Unique Syntax: Python syntax is unique when compared to other programming languages. Many programming languages is based on the C like syntax which mainly contains curly braces and semicolons. C. C++, Java, JS etc are examples for this. But python is not like these. Because python believes in the principles like beautiful is better than ugly and readability counts. Python relies on significant white spaces. This makes it is easier to code in python and helps to read the code better.

General Purpose Programming Language: Python is a general purpose high level programming language that can be used at multiple domains. So what is a high level programming language. We know that computers can only understand 0s and 1s and the do all the process as 0s and 1s. Normally coding with these 0s and 1s can be said as machine code. The next variation is assembly code which is little better than machine code but not good as high level programing languages. We need to code in machine code in high performance scenarios like in the embedded systems and all. These languages are called low level languages and these are extremely close to the hardware, telling them what exactly they need to do. But writing code this way is very hard to do and maintain. Here is High level programming languages comes, These languages are easy to write and understand and in an human readable level. Here we tells the system to what to do and then the language implementation transforms these high level code in to low level language which does the job that prescribed in the high level language. By doing this, we don't have to worry about the machine specifics and their internals of the computer works, and we can focus on the problem that we have to solve.

Multi-paradigm: programming paradigms are the methods or methodologies that used to write the code. Here python support multiple programing paradigms. Lets first look at what a program is, Lets take the program as an assembly line suppose we are building a car with that assembly line and the input we gives are the components or raw materials for that car. We can say that the final output as the car and the machines or the employees which makes the car using the components and all as the algorithms. That is, Algorithms + Data structures = programs. Python supports multiple programming paradigms including structured programming, Functional programming and Object Oriented programming. In OOPs, the algorithms and the data which acts on those algorithms are packaged as objects. A program is then built by multiple objects which are connected to each other in a certain way or another.

Python is interpreted: Programs comes with two flavors, Interpreted and compiled. To understand more about this let see how a program executes at machine level. A computer CPU only speaks its own language which is ISA, Instruction Set Architecture. Which means the set of instructions that the CPU can understand and execute. By default the code we write is not readable by CPU, Hence we have to translate it into ISA somewhere before the execution. This translation or conversion process is done by two approaches. One is called compiling and this is done by compiled languages. Languages like C++ can take significant amount of time to compile a large program. The other approach is with the interpreted programming languages, these languages have a live translator which transfers the code the way the CPU understands in the real time. This is what python does by default. You don't need to compile your code beforehand, you write a python program and the python runtime will handle the rest no mater what type of CPU it is running on.

Python supports garbage collection: The modern PCs are relying on the architecture called von Neuman Architecture which includes a set of CPU and memory associated with Input, Output, and Mass storage devices. In this architecture the program and the data acts upon it is stored in the computer, In this type of stored program computers as the program runs it reads data to and from the memory. Here if a data stored is no longer used and no action is taken it leads to memory leaks. Think of its as a used plate which is not washed, In languages like C++, the programmer needs to take care in clearing all these data. But in python this cleanup is done by itself automatically and this is known as garbage collection. Because of that we can avoid common memory leaks and problems that associated with that. It also enhances the security of the program too.

Python is dynamically typed: Python is a dynamically typed language. What is dynamic? We don't have to declare the type of variable while assigning a value to a variable in Python. Other languages like C, C++, Java, etc.., there is a strict declaration of variables before assigning values to them. Python don't have any problem even if we don't declare the type of variable. It states the kind of variable in the runtime of the program. So, Python is a dynamically typed language.

要查看或添加评论,请登录

???????????? ?????????? ?? ??的更多文章

  • Learning Python - Day 6 - Exceptions

    Learning Python - Day 6 - Exceptions

    In most programs, there is a clear notion of the normal path through the code. But, of course, conditions can arise…

  • Learning Python - Day 5

    Learning Python - Day 5

    Objects and Types Overview While you can get a long way in Python with fairly shallow understanding of its underlying…

  • Learning Python - Day 4

    Learning Python - Day 4

    Installing and Starting Python Overview In this module, we'll cover obtaining and installing Python on your system for…

  • Learning Python - Day 3

    Learning Python - Day 3

    Python Pros and Cons Pros and Cons: In this article, we will take a look at various pros and cons of the Python…

  • Learning Python - Day 1

    Learning Python - Day 1

    Hi Friends, This article is kind of like a notes that I'm taking while brushing up my python coding skills. What I'm…

  • The Healthy Approach To Productivity

    The Healthy Approach To Productivity

    Today we are discussing about healthy approach to productivity based on the book "Only Study Guide You'll Ever Need" by…

  • Blockchain Technology, Part - 06

    Blockchain Technology, Part - 06

    What is Bitcoin? Let's meet first blockchain in the world. Bitcoin Bitcoin is a decentralized digital currency that got…

  • Blockchain Technology, Part - 05

    Blockchain Technology, Part - 05

    Blockchain Architecture Transaction Flow - Traditional systems In order to understand the working of a blockchain…

  • Blockchain Technology, Part - 04

    Blockchain Technology, Part - 04

    Ingredients for a Blockchain Hash: Fingerprint for Data You might have come across the term 'hash', maybe as root hash…

  • Blockchain Technology, Part - 03

    Blockchain Technology, Part - 03

    A Basic Dictionary of Blockchain In the previous article, we had a brief note on decentralized networks, distributed…

社区洞察

其他会员也浏览了