Learn Python Essentials in 5 Minutes

Learn Python Essentials in 5 Minutes

Hey! You need to learn python. If you are looking for a short tutorial which can give a good start in Python. So Please trust me this will be the end of your search. Anyways Python is not only a scripting language that is used for data science. There are so many uses of python, for example, a big community of developer uses python in multimedia Software development. In the same way, So many developers use python in Web Application development. That is why we call Python is a multipurpose language like Java. Python is also very easy due to syntax like the English language.

learn python

Here you will learn the following things.

  1. Various Python Data Types
  2. Conditional Statements in Python
  3. Function in Python
  4. Python Modules
  5. Input and output in Python

 

Now are You ready For being a hardcore developer in Python? Of course, You are! Right? So you need to first install python. You can Download Python and Install it. There are two basic versions of Python 2.x family and 3.x family . 2.x comes with great documentation and community support . On the flip of the coin , 3.x is very fast . So It is completely Application dependent what you should choose.

I hope you have installed Python. You have to set the path into environment if you are using a Windows-based Operating system. Now Lets Learn Python –

Road map to learn Python  essentials simple and describe below . After reading this article you will be knowing at least writing basic code in Python .

Now, let’s start briefing one by one-

1. Learn Python Data Type-

Python support five standard data type. Unlike other Programming language Python is quite flexible in data type . Here we use one root type for every sub-data type For example In java for numbers we have to define the subset Int, Float, double but in python we use Number as a data type. There are five data type respectively Number, String, Tuple , List, Dictionary.

Syntax-

var coin =5   # Number Declaration

var result =8.9   # Number Declaration

Str ='Data Science Learner'    # String Declaration

list_of_python = [1, 'learn python ' , 4.5 ]  # List Declaration

Tuple_of_python =('Rahul', 4, 98) 3  #Tuple Declaration

Dictionart_of _Python = { 'key1 '='value1' , 'key2 '='value2'}

Difference between List and Tuple in Python –

List and Tuple in python look quite similar. In fact, there is quite a similarity in List in Python and Tuple in Python. The only difference is that you can not update tuple while you can update a list in python. These two data types are similar to Array in C but unlike C there we can store different data types.

For Example-

Python_List= [ "Data Science Learner ", 3.4 ,3]       # Here we are storing different data type in a Python List

2.Conditional Statement in Python –

Conditional Statement in Python is quite similar with conditional Statement in java and other traditional Programming Language  .

if <condition is=”” true=””>:
———————————
———————————-
elif <condition2>:
———————————-
———————————-
else:
<do another=”” thing=””>:
———————————
There will not be any closing braces in python. There will be : symbol after every conditional statement in Python.

3. Loop in Python- 

If you want to be an expert in python the only way is to learn the basics.

Syntax of for loop-

for var in range(limit source, limit destination):

Statement 1;

Statement 2;

4. Function in Python –

The function is used to modular the code. We have to use the ‘def ‘ keyword in defining the function. Functions in python are consist of two parts.

  1. Defining a Function in Python
  2. Calling a Function in Python

Defining a Function in Python-

Here we write the behavior of the function.  What does it going to perform and what does it going to return like that.

For Example-

def funname  (parameters 1, parameters 2, …………… ):

statement 1

statement 2

—————————

return expression

Calling a Function in Python-

For calling a function in  python we have just pass the values (  actual arguments ) and Semicolon   ‘;’   is also required at end of caller statement.

For Example-

Funname(10 ,20);

5.Python Modules-

If you want to add any functionality. The required functionality is not in the current module you have to just import that module in your current script.

Syntax-

import part_you_need  from module_name   # adding only a part into the current namespace

import module_name *   # Importing all into the current namespace from module

6. I/O Function in Python-

If you want to input a string using Python there are so many options. I am going to list two functions for you guys :

  1. input
  2. raw_input

Syntax For input function in Python –

var = input(“Learn python using input function”)

var = raw_input(“Learn python using raw_input function”)

Last Notes –

I have not given a detailed tutorial in this article. This can only give you a start to know the essentials. After reading you can start coding in python. See I am telling you my own experience in coding, You cant learn any programming language by reading at once. You have to read first then write some code. Learn again to fill your knowledge gap in that programming language.

Specially If you want to learn Python, You can not be rigid to a particular approach because it is open source language . Developers are contributing to some thing every day. So you should learn python basics only and for advanced work in python always look for a better way. How much you write code your experience will help you in writing a similar task in less time next time. Learning a programming language is an ongoing process. Never Commit this process.

Few words for IDE –

In the continuous series of articles our next post will give you a deep approach in learning python.  If I discuss IDE for python there are so many options. In which I selected PyDev with Eclipse. This IDE made my life simpler, I do not have to remember too much syntax. By just knowing a few tricks in eclipse you can save a lot of time. As  smart coder you should go for a recommendation made by IDE.

For example you want to run a function of a module for this you just have to write the name of the module and then ” .”. a=just after it press Ctrl and space together. ide will automatically show you all functions inside that module. You have to just choose the function. You need not remember the complete syntax of the function.

I hope you have enjoyed this short tutorial to Learn Python. There is another article for learning Python for Data Science if you have already a good understanding of Python basics. In the Complete Overview of Learning Python for Data Analysis , you will know the complete overview of how to start programming data science in Python Language.

If you have any suggestions or improvement you can comment below. We love to write to you. If you want to get free Ebooks and other materials on python, Do not forget to subscribe us .

 

 

Join our list

Subscribe to our mailing list and get interesting stuff and updates to your email inbox.

Thank you for signup. A Confirmation Email has been sent to your Email Address.

Something went wrong.

Share via
 
Thank you For sharing.We appreciate your support. Don't Forget to LIKE and FOLLOW our SITE to keep UPDATED with Data Science Learner