0% found this document useful (0 votes)
0 views5 pages

Python Class Intro

Python is a general-purpose, object-oriented programming language used in various applications such as web development, machine learning, and data analysis. It offers advantages like extensive libraries, improved productivity, and ease of use, while also having disadvantages such as speed limitations and weak mobile computing support. The document also covers variables, data types, input and print functions, and the type() function in Python.

Uploaded by

sachinv13307
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
0 views5 pages

Python Class Intro

Python is a general-purpose, object-oriented programming language used in various applications such as web development, machine learning, and data analysis. It offers advantages like extensive libraries, improved productivity, and ease of use, while also having disadvantages such as speed limitations and weak mobile computing support. The document also covers variables, data types, input and print functions, and the type() function in Python.

Uploaded by

sachinv13307
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 5

Python Introduction:

---------------------------
* 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.

4) Improved Productivity - Python simplicity and extensive library render


programmers more productivity than other programming language like Java, C++.

5) IOT Opportunities - Since Python is used as major programming language in new


platform like Raspberry PI, So it is used as primary program in IOT application
development.

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

9) Free and Open-Source

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

Multiple variable in single line:

a,b,c = 10,20,30

Mutliple variable with same value:

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.

Some of the build in datatypes supported by Python are,

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

input function in Python:


--------------------------------
* To get input at runtime in python there is predefined function called
input() for version 3+
raw_input() for 2+
* It return the value as string, to convert into relevant datatype are there
predefined conversion function available in python.

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);

print() function in python:


----------------------------------
* To print any value or statement in python there is a predefined function
called print() for version 3+
print statement for ver 2+

* It print the value or statement in console.

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

* To overcome this problem in python we have to convert other type value to


string using str() function.

Eg:
age=25;
print("The age is "+age)

Output:
Error

Eg:
age=25
print("The age is "+str(age))

Output:
The age is 25

* In Python we can pass mulitple argument to print() function, it all get


append() into one string and print in the console.

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'>

You might also like