Learn Python with Dhawal -1- Chapter


CHAPTER ONE

Out of the most programming languages out there python is the most easiest to learn for both people who are well-versed with the programming as well as the total newbies. Before we begin with how to write the code, lets know more about the language itself.

About Python:
Python in the world of computers is a language which is used in various places. Python is developed under an OSI-approved open source license, making it freely usable and distributable, even for commercial use. Python's license is administered by the Python Software Foundation. (Source Offical Python.org website )

Python is an open source language, meaning anyone can use it as well as contribute in its development. Think of it like JAVA or ANDROID or CHROMIUM, all of them are owned and managed by certain organisation but are open for everyone to use, make modifications(legal and ethical modifications permitted by the license) as per needs as well as contribute in its development.

To know more  about Python you can visit https://www.python.org. It is the official source for all your information regarding Python. You can also google and find other quotable or referable sources alongside.

How Python Works :

For every programming language to work, there's a layer which works most of the time from the shadows but is the most important layer that you'd ever encounter. For almost every programming language out there, there's a compiler or an interpreter. Now unlike traditional languages where a language either has a compiler or interpreter, often known as GEN2 or GEN3 languages. Python is both an compiled as well as an interpreted language.

Python being a 4th Gen aka a higher level language, works on two different stages. Many might know that C language is a compiled language as first the code is written and then sent to the compiler where the machine code is being generated and then we execute that machine code to get our desired outputs. Just like JAVA ( in some case scenarios ), Python is both compiled and interpreted i.e. First the code is compiled and converted into machine language and then its interpreted.

A compiler converts the code that you have written into a machine language at once and then it executes it. If there's any error in the code, it won't finish the compiling process and won't produce a machine code as an output. An interpreter works on a little different basis. It reads each line of code one by one and then converts it into machine code and executes it. If it encounters an error, it stops but the code until the error is encountered is already executed. Both compiler and interpreter have their advantages which I might try posting in some other post but for now I think this is enough information you'd like to know about.

So, in Python, your code is first compiled and checked for errors and then if everything goes well, it is interpreted line by line at byte code level.

Learning the Basics of a Programming Language:

There are a few requisites before you get started working and playing around with python codes. You need to first learn the basics of Python as whole and programming basics itself.

I am writing this post as if you are a non-CS background personality and you never ever have even had encountered a single piece of code in your life so if you are a person who knows about basics of programming then you can surely skip this part. But if you want to get brushed up with basics again then here's your read.

Python is a very easy to understand as it uses most common english terms unlike other languages where there are a ton of programming jargons. Being a Higher generation language its as close to english as it can get. Before you begin, Here are some terms that you'd need to keep in mind. We will learn specifics about Python variables and data types in next Chapter/Post. Here are some basic brush in concepts.

Variable: A variable is something whose value varies depending on the circumstances. Think of a variable like an empty carton box, you can put any value you want in it. You can change its value time and again as per your needs. Some variables are single valued while some are multi-valued.

There are some nomenclature rules which you have to follow while naming variables and other most things in any programming language. A variable name can contain anything from 0-9,a-z,A-Z or any combination of those, you can use an underscore(_) to separate long words or terms.

You can't use any special characters while naming a variable, there might be some exceptions here and there but a general rule of thumb states to avoid them. A variable should have at least one character in name and it shouldn't be idiotically long.

You can follow UpperCamelCase or lowerCamelCase style of naming long variables if you don't want to use underscore.

Can Do : names, Name, name99, Full_name, id_no, na9me, 9name2, fullName, FullName, FULLNAME, etc..

Can't Do : name&, Na------, Name#, &&se, +-Name, thisisaverylongnameetc...

Types of Variables :

In Python you usually don't need to worry about any of these data types but for learning programming it is necessary to know what you'd be dealing with and what happens behind the scenes when you try to operate on different things.

Integer : Commonly known and used as int, an integer is a variable which holds the integer values.

Boolean : It just holds any of two values, i.e. TRUE or FALSE.

String :  It holds a set of characters together in a string.

Character : As the name suggests it holds a single character.

Array :  It holds a set of numbers, characters etc...

But while working with Python there are a few more which you need to know about.

List : Lists are very similar to arrays,  but while array can contain a list of a number or characters as you can't mix both in same array, list can do that for you.

Tuples : Tuples are very similar to lists but only point of difference being they can't be updated.

Dictionary : Like you have dictionary for various languages, you can create a dictionary of your own to use while you code using python.


Arithmetic Operations :

As many of you know the story of computers began as calculators and present day computers are nothing much but a very complex and super advanced calculators.

Here are some basic operations that you can do using these symbols, we will learn how to use them in later chapters.
Symbol Explanation
 + Addition Operator is used to add two numbers, variables and give an output.
- Subtraction Operator is used to subtract two numbers, variables and give an output
* Multiplication Operator is used to multiply and give product of two variables or numbers as an output
/ Division Operator is used to divide the two numbers or variables and give the output of only quotient. It will round off the value depending upon the variable holding the value of output.
% Modulo Operator is used to divide the two numbers or variables and give remainder as an output. It'll also round off the number depending upon the variable holding the output.


Logical Operations :

There are logical operations which are used to check the logical correctness in some cases. Below are some symbols and their uses.


SymbolExplanation
 &&Logical AND Operator is used to check if both the conditions are true or both the sides are logically true
||Logical OR Operator is used to check if any of the conditions or any of the side is logically true
==Is equal equals to operator is used to check that both LHS and RHS are exactly the same on logical level.


Conditional Operations :

For every now and then you'd need to check a condition as you move ahead in your programming journey. To check those conditions you can use any of below operators as per the circumstance.


SymbolExplanation
 &AND operator is used to check if both conditions are true
|OR operator is used to check if any of the conditions are true
!NOT operator is used to negate the value.
=IS EQUAL TO operator is used to check the equivalence
!=NOT EQUALS TO Operator is used to check if its not equal.


Here I end with my very brief explanations of programming basics. In next chapter I'd begin with coding and we will learn the concepts as we use them on the go. This series mostly will be a weekly series so do follow to get the updates.

For more information you can always google up and read from the sources you favour. Here is a source where you'd like to learn about some basic data types and other things. Although you can easily pass them while working with python as it takes cares of certain things on its own but you can give it a try if you have a super curious mind.

Link about details on data types : https://www.javatpoint.com/java-data-types

NEXT CHAPTER >>

~*~*~*~


This series is totally authored by me (Dhawal Joshi). Any similarities found on the text, or codes or anything is purely accidental. All the sources of reference will be mentioned, linked and will be given the proper credits. If I miss anything or there's anything wrong, feel free to comment or send me an email and I'll try to edit it out. I am not a Python expert, I am sharing whatever I have learnt on my own and with a few sources around to refer from which will be mentioned. Also feel free to share this series with others so most can benefit out of it.

~*~*~*~


Do comment and share your thoughts about it! I'd love to know what do you think. Also, I'd keep updating it quite often so do follow the blog to get all the updates by clicking here.

Also, a minor headsup.... Obsessed is free to read on Kindle Unlimited! Do check it out. I'd be glad to read your reviews!
Share :

Are you getting regular fresh content updates? If not click on the button below.

7 comments:

  1. This was useful, would love to know more about this.

    ReplyDelete
    Replies
    1. Thanks, you can read ahead and comment your thoughts.

      Delete
  2. Brilliantly explained.
    Even a layman would be able to understand the concept.
    Keep on updating. Would like to know more.

    ReplyDelete
    Replies
    1. Thanks, I have updated almost a week's chapter content.

      Delete
  3. Can you please give an example of String?
    and btw, it is really helpful. I am kinda studying from your book.

    ReplyDelete
    Replies
    1. There are examples of strings in further chapters. String is basically a sentence in layman terms.

      Delete

Do comment and share your thoughts.