CLASS -11 COMPUTER SCIENCE
CHAPTER-2 PYTHON FUNDAMENTALS
🔔To download textbook pdf click on the ''DOWNLOAD'' button below -
NOTES FOR COMPLETE UNDERSTANDING -
- Program, is a group of instructions that controls processing.
- Or we can say , base for processing is ‘the Program’.
- Elements of processing i.e.– character sets , token, statements, input , expressions .
- Character Set - is a group of letters or signs which are specific to a language.
- Character set contains alphabets , signs, numbers , symbols .
- Letters: A-Z, a-z
- Digits: 0-9
- Special Symbols: _, +, -, *, /, (, ), {, } . . . etc.
- Spaces: blank space, carriage return, newline, form feed , tab ,etc.
- It can process all characters of ASCII & UNICODE.
- Token-
- It is the smallest unit of any programming language and also known as Lexical Unit.
- Various types of token are-
- Keywords
- Identifiers
- Literals
- Operators
- Punctuators
- Keywords are those which provides a special meaning to interpreter and are reserved for specific functioning in coding .
- Keywords can't be used as an identifier , variable name or for any other purpose.
- Available keywords in Python are -
- False ,
- assert,
- del ,
- for ,
- in ,
- or ,
- while ,
- break ,
- elif ,
- from ,
- is ,
- pass ,
- with ,
- True ,
- else ,
- global ,
- lambda ,
- raise ,
- yield ,
- and ,
- except ,
- if ,
- nonlocal ,
- as ,
- import ,
- not ,
- try,
- class ,
- def ,
- finally ,
- is ,
- return ,
- None ,
- continue .
- Identifiers - Identifiers can be considered as building blocks for a program as they are used to locate names to different parts of a program like : variables , objects , class , etc.
- It can be a mixtures of letters & numbers.
- It must begin with an alphabet or an underscore( _ ).
- Subsequent letters may be numbers(0-9).
- Python is case sensitive i.e. the uppercase letters are different from that of lowercase letters (T and t are different for interpreter).
- Length of an Identifier is unlimited.
- Keywords can't allowed to be used as an identifier.
- Space and special symbols should not be there in an identifier name excluding underscore( _ ) sign.
- Literals are often called Constant Values.
- Python permits following types of literals - – String literals - “Pankaj” , – Numeric literals – 10, 13.5, 3+5i , – Boolean literals – True or False , – Special Literal None , -Literal collections
- String Literal is a sequence of combination of letters, numbers and special symbols , enclosed within single , double or triple quotes .
- In python, string is of 2 types- – Single line string :Text = “Hello World” or Text = ‘Hello World’ – Multi line string :Text = ‘hello\n world’ or Text = ‘’’hello word ’’
- Numeric values can be of 3 variants -
- int (signed integers)
- Decimal Integer Literals – 11, 137, 2770 etc.
- Octal Integer Literals - 0o17, 0o217 etc.
- Hexadecimal Integer Literals – 0x15, 0x2A3, 0xABC etc.
- float ( floating point real value)
- Fractional Form – 2.07 , 17.555 -13.5, -0.00015 etc.
- Exponent Form - -1.7E+8, .25E-4 etc.
- Complex (complex numbers) : 3+5i etc.
- Boolean Literals
- It can have either of only two values – True or False
- Special Literals
- Special literal is None, which means nothing (no value): X = None
- Operators
- An Operator can be considered as a representation of some action that has to be applied on identifier (s)/ operand (s).
- Concluding that an operator requires operand (s) to compute upon. example : c = a + b Here, a, b, c are operands and operators are = and + which are performing differently
- Types of Operator- Python supports following types of operators.
- Unary operators:
- Unary plus (+)
- Unary Minus (-)
- Binary Operator
- Arithmetic operator (+, -, *, /, %, **, //)
- Relational Operator(<, >, <=, >=, ==, != )
- Logical Operator (and, or)
- Assigment Operator (=, /=, +=, -=, *=, %=, **=, //=)
- Bitwise Operator (& bitwise and, ^ bitwise xor, | bitwise or)
- Shift operator (<< shift left, >> shift right)
- Identity Operator (is, is not)
- Membership Operator (in, not in)
- Punctuators
- Punctuators are used to build program & to make balance between instructions and statements .They have their own style of syntactic and semantic recognition.
- Python has following Punctuators - ‘ , ” , #, \, (, ), [, ], {, }, @. ,, :, .. `, =
- As we have seen in previous slides, a program contains following components- – Expressions like a+b, a>b etc. – Statements like a=10, c=a+b etc. – Comments, lines starting with #. – Function, block starting with def keyword – Blocks and indentation like if and else blocks
🔔MORE MATERIALS TO BE UPLOADED STAY TUNED🔔