Python Class Intro
Python Class Intro
---------------------------
* It is general purpose object oriented programming language.
Applications of Python:
------------------------------
1) Web Application Development
2) Desktop GUI Application Development
3) Scientific and Numeric Computing
4) Software Development
5) Business Application Development
6) Image Processing Applications
7) IOT based applications
8) Machine learning
9) Artificial Intelligence
10) Data Analysis
11) Web Scraping
12) Robotics
Advantage of Python:
-----------------------------
1) Extensive Library - Python have lot of extensive library for regular
expressions, email, image processing and so on.
2) Extensible - Python can be extended to other language. You can write some of
your code in C, C++.
3) Embeddable - Python can be embedded into other programming language like C++.
This less us add script capabilities to our code in other language.
6) Simple and Easy - The no of coding line in python are much small than other
programming language. So, it is easy for developer.
7) Readable - It is not much verbose language, reading python is much like reading
English.
8) Object Oriented
10) Portable
11) Interpreted
12) Python is for Everyone - Work is all platform and can be used to develop
different applications.
Disadvantage of Python:
--------------------------------
1) Speed Limitations
2) Weak is Mobile Computing and Browsers
3) Design Restrictions
4) Underdeveloped Database Access Layers
Variables:
------------
* Variables are the containers for storing data in memory.
* Unlike other programming language Python variables are loosely typed or
dynamically typed
* A variable is get create at the time you assign a value to it.
Eg:
a = 10 #int
b = 12.34 #float
c = "Hello" #string
d = True #bool
e = 10j #complex
a,b,c = 10,20,30
a = b = c = 10
Variable Types:
--------------------
i) Local variable
* Variables declared inside a function are called Local
variables. Its scope end within that function.
ii) Global variable
* Variables declared ouside a function are called Global
variables. Its is available thoughtout the program.
Datatypes in Python:
--------------------------
* Types of data used in program are called Datatypes.
* Since Python variables are loosely types we can use same variable for
storing different types of data.
Number Types: int, float, complex (Note: there is no limit for number range
in python)
Text Type: str
Sequence Types: list, tuple, range
Mapping Type: dict
Set Type: set, frozenset
Boolean Type: bool
Binary Types: bytes, bytearray, memoryview
Conversion function:
----------------------------
int() - convert string to int
float() - convert string to float
complex() - convert string to complex
str() - convert other types to string
list(), tuple(),range() - get list of inputs
dict() - get pair of inputs
set(),forozenset() - get list of inputs
bool() - convert string to bool
bytes() - convert string to byte
bytearray() - get list of inputs
memoryview() - get the memory address of that value.
Eg:
age = int(input()) #10
print(age)
Output:
Runtime Input value #10
Eg:
age = int(input("Enter ur age: "))
print("Your age is ",age);
Note: In python the print() function print the value and then move to next
line, because the default terminator in print function is '\n'.
* we can change it using 'end' paramter.
Eg:
print("Hello")
print("Hi")
Output:
Hello
Hi
Eg:
print("Hello",end=" ")//Changing default \n with space for end variable
print("Hi")
Output:
Hello Hi
Eg:
print("Hello",end="!")//Changing default \n with ! for end variable
print("Hi")
Output:
Hello!Hi
Note:
In python we cannot uses + operator for concatenation of string with
other types like Java.
Eg:
a=10
b=20
print(a+b)
Output:
30
Eg:
a="Good "
b="morning"
print(a+b)
Output:
Good morning
Eg:
a=10
b="Hello"
print(a+b)
Output:
Error
Eg:
age=25;
print("The age is "+age)
Output:
Error
Eg:
age=25
print("The age is "+str(age))
Output:
The age is 25
Eg:
a=10
b=20
print("The values are",a,b)
type() function:
-------------------
* It is used to get the type of data being stored in a variable.
Eg:
a=10
print(type(a))
Output:
<class 'int'>