0% found this document useful (0 votes)
9 views18 pages

Computer Science TTR

The document provides an overview of key Python concepts including exception handling, data types, operators, and variable scope. It outlines syntax for raising exceptions, using try-except blocks, and differentiates between mutable and immutable data types. Additionally, it covers built-in functions and modules, as well as the distinction between arguments and parameters in functions.

Uploaded by

dhruvilmistry267
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)
9 views18 pages

Computer Science TTR

The document provides an overview of key Python concepts including exception handling, data types, operators, and variable scope. It outlines syntax for raising exceptions, using try-except blocks, and differentiates between mutable and immutable data types. Additionally, it covers built-in functions and modules, as well as the distinction between arguments and parameters in functions.

Uploaded by

dhruvilmistry267
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
You are on page 1/ 18

Python Things To Remember

Exception Handling

Syntax
raise Exception(“Text”)
assert(10>100), “Not possible”

try:
a = int(“abc”)
print(10/0)
except ZeroDivisionError:
print(“Division by zero not possible”)
except:
print(“Some error”)
else:
print(“No exception has been raised if this
prints”)
finally:
print(“Always prints regardless of exception or
not”)

Stack
Class 11 Python
Python Keywords

Python Data Types

Mutable (Changeable) and Immutable (Not Changeable) Data Types


Operators:
1.​ Arithmetic Operators:
a.​ +
b.​ -
c.​ *
d.​ /
e.​ %
f.​ //
g.​ **
2.​ Relational Operators:
a.​ ==
b.​ !=
c.​ >
d.​ <
e.​ >=
f.​ <=
3.​ Assignment Operators:
a.​ =
b.​ +=
c.​ -=
d.​ /=
e.​ %=
f.​ //=
g.​ **=
4.​ Logical Operators:
a.​ and
b.​ or
c.​ not
5.​ Identity Operators:
a.​ is
b.​ is not
6.​ Membership Operators:
a.​ in
b.​ not in

Order of Precedence

Explicit Conversion (Type Casting)


When data type conversion takes place because the programmer forced
it in the program.

Implicit Conversion (Coercion)


When data type conversion is done automatically by Python.

Argument (Functions)
An argument is a value passed to the function during the function call.

Parameter (Functions)
Parameter is defined in the function header.

Scope of a Variable
The part of the program where a variable is accessible can be defined as
the scope of that variable.
1.​ Global Variable:​
A variable that is defined outside any function or any block is
known as a global variable.
2.​ Local Variable:​
A variable that is defined inside any function or a block is known as
a local variable.

Built in Python Functions


Built in Modules
1. Math Module
2. Random Module
3. Statistics Module

String Functions
List Functions
Tuple Functions
Dictionary Functions

You might also like