What isPickle or Serialization and UnPickle or DeSerialization in python how to define.The process of converting an object from python

Image
Object Serialization The process of converting an object from python supported form to either file supported   form or network supported form, is called serialization (Marshalling or pickling) The  process of converting an object from either file supported form or network supported   form to a python-supported form is called deserialization (Unmarshalling or  unpickling).  Object Serialization by using Pickle  Object Serialization by using JSON  Object Serialization by using YAML  Object Serialization by using Pickle: We can perform serialization and deserialization of an object wrt file by using the pickle   module. It is Python's inbuilt module.  pickle module contains dump() function to perform Serialization(pickling).  pickle.dump(object,file)  pickle module contains load() function to perform Deserialization (unpickling).  object = pickle.load(file)  Program to perform pickling and unpickling of Em...

PYTHON CONTENT

introduction

Python is a general-purpose high-level programming language. Python was developed by Guido Van Rossum in 1989 while working at National Research Institute in the Netherlands. But officially Python was made available to the public in 1991. The official date of Birth for Python is Feb 20th, 1991. Python is recommended as the first programming language for beginners.

Ex 1: To print Helloworld :

Python

print("Hello World")

Ex 2: 

Python

 1) a=10 
 2) b=20 
 3) print("The Sum:",(a+b))

The name Python was selected from the TV Show "The Complete Monty Python's Circus", which was broadcasted on BBC from 1969 to 1974. 

Where we can use Python: 


We can use it everywhere. The most common important application areas are 
For developing Desktop Applications.
For developing web applications.
For developing database Applications.
For Network Programming.
For developing games.
For Data Analysis Applications.
For Machine Learning.
For developing Artificial Intelligence Applications.
For IoT

WHICH COMPANIES USE PYTHON:

Internally Google and Youtube use Python coding.
NASA and Network Stock Exchange Applications developed by Python.
Top Software companies like Google, Microsoft, IBM, and Yahoo use Python.

Features of Python:

1) Simple and easy to learn:
2) Free and Open Source
3) High-Level Programming language
4) Platform Independent
5) Portability
6) Dynamically Typed
7) Both Procedure Oriented and Object-Oriented
8) Interpreted
9) Extensible
10) Embedded
11) Extensive Library

IDENTIFIERS


A Name in Python Program is called Identifier. 
It can be Class Name OR Function Name OR Module Name OR Variable Name.
a = 10


Rules to define Identifiers in Python: 

1. The only allowed characters in Python are

alphabet symbols(either lower case or upper case)

digits(0 to 9)

underscore symbol(_) 

By mistake, if we are using any other symbol like $ then we will get a syntax

error.

cash = 10 (correct)

ca$h = 20 (wrong)

2. Identifier should not starts with a digit 

123total (wrong)

total123 (correct)

3. Identifiers are case-sensitive. Of course, Python language is case sensitive language. 

total=10 

TOTAL=999

print(total) # output will come 10 

print(TOTAL) #999 

4) We cannot use reserved words as identifiers 
 Eg: def = 10
5) There is no length limit for Python identifiers. But not recommended to use too lengthy identifiers.

RESERVED WORDS

In Python, some words are reserved to represent some meaning or functionality. Such types of words are called reserved words. 

 Except for the following 3 reserved words, all contain only lower case alphabet symbols
True  False  None
Eg: a= true (wrong)
 a=True (correct)
There are 35 reserved words available in Python.

 True, False, None  and, or, not, is 
 if, elif, else 
 while, for, break, continue, return, in, yield 
 try, except, finally, raise, assert 
 import, from, as, class, def, pass, global, nonlocal, lambda, del, with

DATA TYPES 

Data Type represents the type of data present inside a variable. 
In Python, we are not required to specify the type explicitly. Based on the value provided, the type will be assigned automatically. Hence Python is a Dynamically Typed Language. 

Python contains the following inbuilt data types :
1) Int 2) Float 3) Complex 4) Bool 5) Str 6) Bytes 7) Bytearray 8) Range 9) List 10) Tuple 11) Set 12) Frozenset 13) Dict 14) None





Note: Python contains several inbuilt functions 
1) type() to check the type of variable 
2) id() to get the address of the object
3) print() to print the value In Python everything is an Object.

1) int Data Type: 
We can use the int data type to represent whole numbers (integral values) 
Eg: a = 10 
 type(a) #int 
Note: 
In Python, we have a long data type to represent very large integral values. 
But in Python3 there is no long type explicitly and we can represent long values also by using int type only. 
We can represent int values in the following ways 
1) Decimal form 
2) Binary form 
3) Octal form 
4) Hexadecimal form 

I) Decimal Form (Base-10):

It is the default number system in Python  The allowed digits are: 0 to 9 
Eg: a =10

II)Binary Form (Base-2): 
The allowed digits are : 0 & 1 
Literal value should be prefixed with 0b or 0B
Eg: a = 0B1111
a = 0B123 
a = b111

III) Octal Form (Base-8):
The allowed digits are : 0 to 7 
The literal value should be prefixed with 0o or 0O.
Eg: a = 0o123 a = 0o786

IV) Hexa Decimal Form (Base-16):

The allowed digits are: 0 to 9, a-f (both lower and upper cases are allowed)
 Literal value should be prefixed with 0x or 0X 
Eg: a = 0XFACE 
a = 0XBeef 
a = 0XBeer
Note: Being a programmer we can specify literal values in decimal, binary, octal, and hexa decimal forms. But PVM will always provide values only in decimal form.
a=10 
 b=0o10 
c=0X10 
 d=0B10 
print(a)10
print(b)8
print(c)16
print(d)2

Base Conversions :
Python provides the following in-built functions for base conversions
1)bin():
We can use bin() to convert from any base to binary







6) '0b10000'
2)oct(): 
We can use oct() to convert from any base to octal

3)hex(): 
 We can use hex() to convert from any base to hexadecimal 









2) Float Data Type:

We can use float data type to represent floating-point values (decimal values) 
 Eg: f = 1.234 
types (f) float 
We can also represent floating-point values by using an exponential form (Scientific Notation)
 Eg: f = 1.2e3  instead of 'e' we can use 'E' 
 print(f) 1200.0 
The main advantage of exponential form is that we can represent big values in less memory.

3) Complex Data Type:

A complex number is of the form








Eg: 3 + 5j 
 10 + 5.5j
 0.5 + 0.1j

In the real part if we use int value then we can specify that either by decimal, octal, binary, or hexadecimal form. 
But imaginary part should be specified only by using the decimal form.

Comments

Popular posts from this blog

Rajasthan Royals Vs Kings 11punjab dreem 11 prediction playing 11 pitch report

What isPickle or Serialization and UnPickle or DeSerialization in python how to define.The process of converting an object from python

How to Call Method of a Particular Super Class in python types of super method examples