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

Python Basics for Class X Students

Uploaded by

Prateek
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)
22 views5 pages

Python Basics for Class X Students

Uploaded by

Prateek
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

Page 1 of 5

Python for Class X

❖ Introduction to Python:
Python is a general-Purpose object oriented easy to learn high
level programming language. Guido van Rossum designed
Python.
❖ Why Python for AI:
(i) It is easy to read, write learn and maintain
(ii) Large standard library
(iii) Interactive mode
(iv) Portability and compatibility
(v) Extendable
❖ Python character set:
(i) Digit from 0 to 9
(ii) Alphabets A to Z and a to z
(iii) Special symbol like $, %, &, @ etc.
(iv) Whtie space like spacebar, tab key or enter key
❖ What is a Statement in Python?
Instructions written in a source code and are executed by a
Python interpreter are called statements.
➢ Simple Statement: Statement writing in single line
➢ Multiline Statement: Statement written in multiline using:
(i) Using Parentheses ()
(ii) Using Square Brackets [ ]
(iii) Using the continuation character (\)
➢ Multiple Statement:
More than one statement in one line using semicolon (;).
❖ Comment:
Comments are used to increase the readability of the code.
➢ Single line comment: Starts with # followed by the text.
➢ Multiline comment:
Starts with three single quotes ’’’ or three double quotes ”””
Page 2 of 5

❖ Keywords:
Keywords are words reserved by python have special meaning in
python language.
Example: None, False, class, is, return, True , if, elif, else, for etc.
❖ Identifiers: Variable names are called identifiers.
➢ Rules for identifier:
(i) We can use any alphabet upper or lower case, numbers or
underscore (_).
(ii) It can start with alphabet or an underscore.
(iii) Should not be special character or keywords
(iv) They are case sensitive.
❖ Variable:
Variable are the name given to a memory location to store any
value.
❖ Data Type:
Data types specify the kind of a value a variable can store.
Example:
(i) Numbers: Data with a numeric value.
(ii) Integer: Whole number
(iii) Float: It is a real number with floating point
representation.
(iv) Complex: It is made up of a real number and in imaginary
number.
(v) Null: It is a special datatype with NULL or noting value.
(vi) Boolean: It is a data type with two built in value True or
False.
(vii) Sequence: It is a collection of data store under a common
name.
(viii) String: It is an order sequence of UNICODE character in
single or double quote.
(ix) Lists: It is a sequence of heterogeneous values arrange as
elements and are referred by an index number. It is
mutable and enclosed n square brackets [ ]
List1=[“Jaipur”, “Delhi”, “Agra”]
Page 3 of 5

(x) Tuples: It is a sequence of heterogeneous values arrange


as elements and are referred by an index number. It is
immutable and enclosed in circular brackets ( ).
Mytuple1=(“Jaipur”, “Delhi”, “Agra”)
(xi) Set: A set is a collection of unique elements that is both
mutable and unordered. mySet=(21, 52, 33, 54, 95)

❖ Operators:
Operators are used to perform operator on variables and values.
➢ Arithmetic Operators:
Exponential (**) Multiplication (*) Division (/)
Floor Division (//) Remainder (%) Addition (+)
Subtraction (-)
➢ Relational Operator:
Equal to (==) Not equal to (!=) Greater than (>) Less than (<)
Greater than or equal to (>=) Les than or equal to (<=)
➢ Logical Operator:
(i) AND: Return true if both the operands are true.
(ii) OR: Return true if either the operands is true
(iii) NOT: Return true if the operand is False and vice versa.

➢ Assignment Operator:
+= : Add first and then assigns a new value.
-= : Subtracts first and then assigns a new value.
*= : Multiplies first and then assigns a new value.
//= : Floor Division first and then assigns a new value.
%= : Remainder first and then assigns a new value.
❖ Operator Precedence:
To evaluate an expression with multiple operators we follow and
order of precedence in Python.
❖ Type Conversion:
Type conversion is the process of converting the value of one data
type into another data type. It is of two types:
Page 4 of 5

➢ Implicit type conversion: When the process of converting the


value of one data type into another data type is done
automatically.
➢ Explicit type conversion: Also called type casting because
program does the type conversion exclusively by changing the
data type.
❖ The print( ) Function: print( ) function is used to display output.
❖ The input( ) Function: It is used to take input from the user.
❖ Conditional Statements:
Conditional Statements are used to select the block of statements
to be executed based on the condition.
Example:
1. if (Condition):
2. if (Condition):
:
else
3. if (Condition):
:
elif (Condition)
elif (Condition)
:
else
❖ Looping Statements:
The process of repetition of a set of instructions based on a
criterion is called a loop.
➢ For loop: For loop is used to repeat a set of instructions for a
fix number of time. There are commonly two different ways to
use For Loop:
(i) Using Sequence
(ii) Using Rage( ) Function
➢ The While Loop :
The while Loop is used to repeat a set of instructions as long as
the condition is true.
Page 5 of 5

❖ Array: Arrays are an ordered collection of values of the same data


type that can be arrange in one or more dimensions.

❖ Module and Packages:


A module is a Python file (.py) that contains Python code.

A Package is a collection of related Python module organized with


in directory.

➢ Some commonly used Python package:

(i) NumPy: (Numerical Python) is a library for numerical

computing.

(ii) Pandas: Pandas is a Python Library for data manipulation and

analysis.

(iii) Matplotlib: Matplotlib is a widely used Python library for data

visualization.

(iv) SciPy: It is used for scientific and technical computing.


(v) NLTK: Natural Language Tool Kit is a Python Library designed

for NLP.

(vi) OpenCV: Open-Source Computer Vision Library is a


powerful library for computer vision tasks.

❖ Anaconda:
Anaconda was developed and is maintained by Peter Wang
Oliphant, the founders of Anacaonda, Inc., in 2012.

❖ Jupiter Notebook:
Jupiter Notebook is an open-source web-based application where
a single document contains Python code, output window,

explanations, formulas charts, etc.




You might also like