Starting with Python

Python is undoubtedly the best language to perform any data science operation. The best part of using Python is that the Python community is very active, so whenever you are stuck in a piece of code or concept, then you can easily find it on the internet. Without wasting much time, let’s start with the basics of Python.

P.S. – This tutorial will be fast-paced

Google and download Anaconda Navigator from here. We will work on the Jupyter Notebook, Open the Anaconda Navigator and launch the Jupyter Notebook.

Very Basic concepts in a nutshell (You don’t have to give 4-6 hours for the basics, we will keep covering the topics as and when it comes)
1. You can directly define a variable, Self-understandable code below # Create a variable multi
multi = 3.6 # Create a variable x
x = 100 # Feed the variables in your formula
result = x * multi**10 # Print the result
print (result)

2. There are 4 important data types in Python – Integer, Float, Boolean and String. There are other data types also, but we don’t really need them. So chuck !!

3. List – A list is an important data structure in Python. Basically, it’s an array where you keep multiple data types at one place.

x = [[‘Rahul’,10156],[‘Nitin’,8382],[‘Ajit’,9876]]
print(x)
print(type(x))

O/P

[[‘Rahul’, 10156], [‘Nitin’, 8382], [‘Ajit’, 9876]] <class ‘list’>

4. List’s element starts with index 0 i.e. if there are 8 elements in a list, you can access the elements from 0 to 7. You can also access the last element with -1, second last with -2, etc.

print(x[-1])
[‘Ajit’, 9876]

5. To access the range of list, use print(x[1:3]), it will help you access 2nd and 3rd element. The higher range value is excluded and the lower one is included.

6. You can directly modify a list with the index of the element you want to change ex. x[2] = [‘Ankit’,9765]

7. Add an element to the list, simply use ‘+’ sign. 
Example – x + [‘Kamal’+4321]

8. Delete an element from the list, simply use the function del()

9. Don’t use “=” sign for copying a list into another. Instead, use
new_list = list(old_list)
or
new_list = old_list[:]

These were the basics of data structure and data types. If you want to learn “How to write basic functions in Python” then click on the link.

 

 

 

 

 

 

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *