0% found this document useful (0 votes)
2 views43 pages

Unit7 Advance Python

The document provides an overview of advanced Python concepts, including installation of Jupyter Notebook, features of Python, and its applications in various fields. It covers Python basics such as data types, variables, control statements, loops, and libraries like NumPy, Pandas, and OpenCV. Additionally, it highlights the importance of Python in data science and machine learning.

Uploaded by

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

Unit7 Advance Python

The document provides an overview of advanced Python concepts, including installation of Jupyter Notebook, features of Python, and its applications in various fields. It covers Python basics such as data types, variables, control statements, loops, and libraries like NumPy, Pandas, and OpenCV. Additionally, it highlights the importance of Python in data science and machine learning.

Uploaded by

brijansh.m.ubale
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Artificial Intelligence

Std:X

Code:417
Unit 7: Advanced Python

▪ Jupyter Notebook- is an open-source web application


for creating, running and debugging Python code.
▪ The easiest way to use Jupyter Notebook is through
Anaconda.
▪ Use Python 3.3 or later version on your system.
[Link] and Setup of Anaconda Navigator

2. How to create and run a program in Jupyter


Notebook.

3. Virtual Environments:
Introduction to Python

▪ Python is a high-level, structured, open-source


programming language supporting development.
▪ Guido Van Rossum founded Python in the early
1990s.
Features of Python :

▪ Python is easy to learn and use.


(Complex tasks can be done using a few lines of code)
▪ It is an interpreted language that executes the code line
by line one at a time. This makes the debugging process
easier.
▪ It is a portable language as it runs equally well on
platforms such as Windows, Linux, Unix, and Macintosh.
Features of Python :

▪ It is open source language and available free of cost.


▪ It has a large standard library which contains useful functions that eliminate
the need for writing codes from scratch.
▪ eg- math library
▪ It is an extensible language which can be extended to other languages.
▪ It can be used for Graphical User Interface (GUI) programming.
▪ It supports both procedure-oriented and object-oriented programming.
Applications of Python :

▪ 1 Web Applications.
▪ [Link] Development.
▪ [Link] and Numeric Calculations (SciPy, Pandas,
NumPy)
▪ Software Development (Management, Control, testing)
▪ Education.
▪ Business Application.
Python Basics:

1. Print – Display output on the screen.


▪ Syntax : print(string)
▪ Eg1- print(“Hello”)

2. Comments: Comments are non-executable code and make


code more readable.
i) Single Line Comment: (#)
#This is a Python function.
▪ b) Multiline Comments :
▪ Python uses ‘ ‘ ‘ or “ “ “ for multiline
comments.
▪ Syntax:
▪ “””
Comment 1
Comment2
▪ “””
Keywords: Keywords are reserved words in
Python that have specific meanings and
operations.
Identifiers: The name we give to identify a
variable, function, class or other object.
▪ Rules for Writing Identifiers :
[Link] can combine uppercase and lowercase letters, digits
or an underscore(_).
myVariable,
variable_1,
variable_for_print
all are valid python identifiers.
2. An Identifier can not start with a digit.
So while variable1 is valid, 1variable is not valid.
2. We can’t use special symbols like !,#,@,%,$ etc in
our Identifier.
3. identifiers can be of any length.
Variables:

▪ Variables are used for storing data in the memory.


▪ Eg-
Roll_No=1
Name=Riya
Multiple Variable Assignment:
a)Assign multiple values to multiple variables:
num,name, age = 101,” Ram”,15
(Value Error will occur if the number of variables on the left-
hand side does not match with values on the right-hand side)
b)Assign the same value to multiple variables:
roll_no1=roll_no2=roll_no3='Grade A'
print(roll_no1)
print(roll_no2)
print(roll_no3)
Data Types
Data types are used to define the type of data contained in a variable.
▪ Numeric Data type:

1) Integer: Integers are whole numbers consisting of + or – sign.


Example: n=2
2)Float: Float data type represents floating point numbers with
decimal points.
Example: Salary=123456.06
3)Complex: A number can be written in the form of a+bj.
Example: c=4+5j
▪ Sequence: Sequence is an ordered collection of elements.

▪ [Link]: Sequence of characters used to store and represent


text-based information.
Example: book “Artificial Intelligence”
▪ [Link]: It is a collection of different types of elements separated
by commas. It is ordered, mutable and allows duplicate
elements.
Example : list1=[1,91.2,”Aditya”]
▪ [Link]: It is similar to the list contains a group of elements.
It is immutable.
Example : tuple1=(12.5.7,”abc”)
▪ Sets: Sets is an unindexed, unordered collection of values of any
type with no duplicate entry.
▪ Example : set1={1,2,3,4,5}

▪ Dictionary: Dictionary data type is a collection of items where each


item is a key: value pair.
▪ Example:
dic1={1:"sandhya",2:"Arnav",3:"Sumedh"}
[Link](2)
3. Tuple: It is similar to the list containing a group of elements.
It is immutable.
Example : tuple1=(12.5.7,”abc”)
▪ Input and Output:

▪ Input function is used to take input from the user and store it in a
variable.
▪ The input () function always returns data as a string, which we
can not use to do mathematical calculations.
▪ Type Conversion :

▪ A) Implicit Type Conversion :


Python automatically converts one data type into another data
type.
a=10
B=10.5
C=a+b
Print(c)
B) Explicit type Conversion :

▪ You can convert the data type of an object to another data type
using predefined functions such as int(), float(), str(), bool() etc.
a="3“
b=int(a)
c=b*b
print(c)
Conditional Control Statement

▪ If
▪ If-else
▪ elifelse
▪ Nested if
▪ Loop Control Structure :

▪ [Link] = ["apple", "banana", "cherry"]


▪ for x in fruits:
▪ print(x)

Output :
apple
banana
cherry
for x in "banana":
print(x)
Output:
b
a
n
a
n
a
▪ The break Statement
▪ With the break statement we can stop the loop before it has looped
through all the items:

fruits = ["apple", "banana", "cherry"]
▪ for x in fruits:
▪ print(x) //1tab
▪ if x == "banana": //1tab
▪ break //2tab

▪ Output: apple banana


The continue Statement
▪ With the continue statement we can stop the current
iteration of the loop, and continue with the next:

fruits = ["apple", "banana", "cherry"]


▪ for x in fruits://1 tab
▪ if x == "banana": // 1 tab output: apple cherry
continue//2 tab
▪ print(x) //1 tab
▪ The range() Function:
▪ The range() function returns a sequence of numbers, starting from 0
by default, increments by 1 (by default), and ends at a specified
number.

1. for x in range(6): output: 0,1,2,3,4,5


print(x)

2. for x in range(2, 6): output:2,3,4,5


print(x)
▪ Python – Data Structure: A data structure is a group of data
elements grouped together under one name such as list ,
tuple, or set.
▪ List:
Program 1:
List1= ["apple", "banana", "cherry", "apple", "cherry"]
print(List1)
▪ Output:
['apple', 'banana', 'cherry', 'apple', 'cherry']
▪ Program 2:

▪ L1= ["apple", "banana", "cherry"]


print(L1[1])
Output: banana

Program 3:
L1= ["apple", "banana", "cherry"]
print(L1[-1])
Output:
▪ Python Libraries and Packages: Python packages and libraries
are the collection of modules and functions that are used to carry
out special tasks and simplify the programming process

▪ [Link]: NumPy is a Python library.


▪ NumPy is used for working with arrays.
▪ NumPy is short for "Numerical Python“
▪ import numpy as np
▪ [Link]: Pandas is a software library written for the Python programming
language for data manipulation and analysis. In particular, it offers data
structures and operations for manipulating numerical tables and time series. It is
free software.

▪ 3. Matplotlib: It helps to analyse data. Matplotlib is a data


visualization library built on NumPy arrays and aids in creating
multiple plots at a time.
▪ import [Link] as pltX

▪ [Link]:
▪ OpenCV, short for Open Source Computer Vision Library, is an open-
source computer vision and machine learning software library. Originally
developed by Intel, it is now maintained by a community of developers
under the OpenCV Foundation.
▪ OpenCV is a huge open-source library for computer vision, machine
learning, and image processing. OpenCV supports a wide variety of
programming languages like Python, C++, Java, etc
▪ [Link]:
▪ The Natural Language Toolkit is a Python library for natural
language processing (NLP). It provides a comprehensive
collection of tools and resources for working with human
language data.

▪ NumPy, Pandas and Matplotlib are widely used Python libraries for
Data science.

▪ OpenCV is used for creating Computer Vision applications.

▪ NLTK: It helps to create NLP applications.


Thank You

You might also like