DEV Community

Chiranjeevi Tirunagari
Chiranjeevi Tirunagari

Posted on

Intro to Programming and Python

Introduction

This is the first article in this series. If you are starting with the programming or python, this series can help you. I will try to explain in as simple as possible manner. Let's get into it.

What is programming in the first place?

Before starting with the term programming, first let's ask the question "Why computers?". If we see carefully, we are using computers mostly to do tasks which are either hard to do faster by ourselves or hard to do accurately by ourselves.

So, now as we know why we are using computers, let's come to the question "How to use computers?". We have certain tasks which we want our computers to do. But how do we tell them? There needs to be some medium of language existing with which we can command computers to do our tasks. But they don't understand human languages. Only language that a computer understands is binary language. Binary language consists of only 0's and 1's. Most of us know this. But why only binary language?

Because, computers are built with chips (not chips that we eat, but silicon chips). Any transfer of data from one device to another device in a computer or from one chip to other happens through electric signals. What signals we can give with electricity? There are only 2 possible signals that electricity can give which are ON and OFF. So, OFF is considered as 0 and ON is considered as 1. That is the reason why a computer can understand only binary language.

Do we need to learn binary language to use computers?

No, scientists from past made our lives easier by building some abstractions for us which let us use computers without knowing binary language. And that abstraction layer is an OPERATING SYSTEM. An operating system is a software which lets users interact with all parts of a computer without requiring to go to bottom level of implementation.

Ohh...Did I forget to tell you what programming is? I think you can guess it now. Yeah, that's right. Giving instructions to computer to do a task is called programming.

Why python?

Before learning any programming language, just question yourself, "Why are you learning it?". Python is good to learn if you want to get into machine learning, artificial intelligence, data science, web development (javascript is recommended in this case) or just curious to learn programming.

Compiler vs Interpreter

Compiler and interpreter are tools which are used to convert human written code into binary, then interacting with hardware using that binary and producing required output.

  • Both compiler and interpreter converts the human written code into binary. But the difference is that compiler converts the entire code in the file at once and interpreter does this line by line but not entire code once.
  • So, if there is an error in compiling code, it would return error without executing anything while compiling.
  • But in case of an interpreting code, if there is an error, since it is converted and executed line by line, it doesn't return an error until it sees a line with error and keeps converting and executing lines until then.
  • And python is an interpreted language and it uses an interpreter.

Where does execution happen?

  • We know that binary code is being executed. But where?
  • The code that needs to be executed is loaded into the main memory (RAM) and executed there.
  • So, when we talk about memory while programming, it is the memory from RAM.

Datatypes

We deal with lot of data while programming. The data can be from computer itself, it can be from user input, it can be from computation being done in previous stages of program. Let's say the program wants to ask a user running the program to give it 2 numbers as input. And, the program giving him back the sum of those 2 numbers as output. The steps involved are:

  • Taking 2 numbers from user. This is data and we need to store it.
  • We need to add these 2 numbers and we get some value. This is also data and we need to store it as we have to give it back to the user.

This is a small example. But in real world scenarios, we will be dealing with lot of data and we need to store them.

The types of data that a programming language can deal with is shown by its datatypes.

Conclusion

That's it for this article. In the next one, let's talk about datatypes in python.

Do follow me for the next articles.
Let's connect on: Twitter LinkedIn Showwcase

Top comments (0)