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

Python Basics

The document outlines the rules for declaring variables in Python, including naming conventions and invalid examples. It also describes various operators such as arithmetic, assignment, comparison, logical, bitwise, membership, and identity operators. Additionally, it briefly mentions data types and the necessity of indentation in loops.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views7 pages

Python Basics

The document outlines the rules for declaring variables in Python, including naming conventions and invalid examples. It also describes various operators such as arithmetic, assignment, comparison, logical, bitwise, membership, and identity operators. Additionally, it briefly mentions data types and the necessity of indentation in loops.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 7

Procedural

Python Programming
Language
Object Oriented

Back-end & front-end development

Rules for declaring variable


1) Starts with Alphabets name : number = valid.
2) Should not start with digits : 9number = Invalid.
3) Can have digits at end & in between : number5 = valid, num23ber = valid
4) We cannot use any special symbol except.._(Underscore) : hari@123 = Invalid, hari 123 =
Invalid. hari_123 = valid. _hari123 = valid.
5) Case sensitive : hari and print Hari are two different variables

['False', 'None', 'True', '__peg_parser__', 'and', 'as', 'assert', 'async', 'await', 'break', 'class',
Keywords 'continue', 'def', 'del', 'elif', 'else', 'except', 'finally', 'for', 'from', 'global', 'if', 'import', 'in', 'is',
'lambda', 'nonlocal', 'not', 'or', 'pass', 'raise', 'return', 'try', 'while', 'with', 'yield']

Cannot be used as variables


Operators:-

Arithmetic Operator:-

+  Addition
-  Subtraction
*  Multiplication
/  Division(Quotient is the output, with decimal as is)
//  Floor division (Rounded of number of left digit is output, without decimal)
%  Modulus (Reminder is output)
**  Exponent

Assignment Operator:-

Balance & Deposit example. Operands are assigned with a variable for repetitive operation

Comparison Operator:-

To check whether two values are same or not.


==  Two values are same
!=  Two values are not same
Operators:-

Logical Operator:-

Logical operators - AND , OR, NOT


Logical AND = returns if both logic is true
Logical OR = returns if any of the logic is true
Logical NOT = returns the opposite of actual output

Bitwise Operator:-

Used to compare binary values. Basically, numbers are converted into binary values(0&1) and then compared according to
truth tables
&  Compare two binary values following AND table
|  Compare two binary values following OR table
^  Compare two binary values following XOR table
~  NOT table
<<  Left shift
>>  Right shift
Operators:-

Membership Operator:-

Will check whether a member is present in the list or not. (e.g., Voter name in voter list of a ward)
IN  returns TRUE if member is in the list
NOT IN  returns TRUE if the member is not in the list

Identity Operator:-

Will check whether the object are in fact the same object or not
IS  returns TRUE if object is same
IS NOT  returns TRUE if object are not same
Data types:-

Both negative & positive


Data types:-
Loops

FOR Loop:

Why Indentation reqd.?

You might also like