The Awesome Python Class Part-2

BinayKumarRay 193 views 13 slides Mar 12, 2016
Slide 1
Slide 1 of 13
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13

About This Presentation

Indents, pip, virtualenv, datatypes, data structures, data containers


Slide Content

The Awesome Indents, pip, virtualenv, basic data types and data structures. Part-2

Summary of Part-1 In the first part we have installed python. Setup editor and checked with pip. This part we will get to know how to write a basic python code. Dig into pip and virtualenv, and learn about data types and data structures. ‹#›

Set up environment to start PIP Its Python Installer Package. Python is so well designed and managed that you don't have to do anything manually, just type pip install package name and bang. Its can handle multiple python version and multiple pip version on a single machine. Virtual Environment It's creates the necessary development environments on the same systems so that user can use multiple software version in one machine. For this tutorial we will not use any environment as its simple python learning. In the next play list of web development we will go for it. ‹#›

Python Code There are certain things that can make you feel like a king while writing code. First of all add the following list of plugins to your sublime text and follow proper coding styles. As we have discussed in the first part there is no braces in python and hence code block is distinguished by indents. A good coding practice follow 4 space indent for one block. It might confuse you at first if you are following conventional languages like c or java but then you will feel more comfortable and readable code. ‹#›

Hello world Done! Only a line that too way too readable. Isn’t it great. ‹#›

Enjoying? Lets swap two variables ‹#›

Datatypes Unlike any other languages you don’t need to define the variable type every time before using it. I mean suppose now variable x = 2 now type(x) is int, in the next line is x = 2.5 type(x) will be float, the very next line assign x = ‘India’ and its str now. so it’s kind of generic where you don’t need to define like int x = 1, like you do in C or java and that makes typecasting super easy in python. That’s the awesomeness of python. So basically we have the same data types in python int, float, str. ‹#›

Basic Data Structures Here comes one of the most important concepts of python, MUTABLE & IMMUTABLE Mutable means “liable to change” meaning you can change the values but Immutable you can not change the values. There are 4 basic data structures available in python. List Dictionary Tuple Set List is like and arrey. Dictionary is like hash table that has key value pair. Tuple is like list but immutable. Set is used as data structured to define mathematical sets. ‹#›

Lists List behaved exactly like arrey, It’s a sequence, enclosed with [ ] and separated by ‘ , ‘ . ‹#›

Tuple Tuple is same as list, But it is immutable. You can not alter the value of a tuple with your code. It is enclosed by ( ). ‹#›

Dictionary Dictionary is enclosed by {} and have key value pair. It is the most important data structures of python. It’s handled as a hash table in backend. ‹#›

Set Set acts as mathematical set to represent data. ‹#›

Thanks Stay Tuned for the next part. Enjoy !! ‹#›