Showing posts with label python class 11 cbse chapter 1. Show all posts
Showing posts with label python class 11 cbse chapter 1. Show all posts

Friday, 15 March 2019

fundamental of python class 11 cbse part 2

PART 2

DATA TYPES

  • Data can be of any type like character, integers, real, string,
  • Anything enclosed in " " is considered as string in python.
  • Any value of fraction part is a real value.
  • True or False value specific boolean value.

MUTABLE AND IMMUTABLE

  • In python, Data object are categorized in 2 types-
  1. Mutable (changeable) - list, dictionary, sets.
  2. Immutable (not changeable) - integers, float, boolean, string and tuple.

STRINGS

A string can hold any type of known characters that is no. , letter and special characters.
  • Python string stores unicode character.
string is the sequence of character and each character can individually accedes using its index.

forward index starts with 0

backward index starts with -1

In word python 

  • name (0)='p'=name(-6)

LIST

  • It represent a, separated values of any data type between square brackets [ ]. [1,3,4,].
  • List can be changed or modified. That is why list is mutable.
>>> a=[1,2,3,4]
>>> a
     [1,2,3,4]
>>> Print (a)
     [1,2,3,4]
To change 1st value.
>>>a(0)=10
>>>a
      [10,2,3,4] 

TUPLES

  • Tuples are also list. It separates values of and type within parentheses.
EXAMPLES
  1. p=(1,2,3,4,5,6)
  2. f=(1,3,5,7) 
  • Values are immutable.

DICTIONARY

  • It is an un ordered set. It separates key:value pairs within { }, with the requirement that within a dictionary no 2 key can be the same.
>>> vowels={'a':1,'b':2}

fundamental of python class 11 cbse part 1

PYTHON FUNDAMENTALS

CHARACTER SET

  • It is a group of letters and signs which are specific to a language.
  • Set include letter, sign, number, symbols.
  1. Letter:A-Z, a-z.
  2. Digit: 0-9.
  3. special symbols: -,=,*,/,',(,) etc.
  4. White spaces: blank space, tab, carriage, return, newline, formfeed etc.
  5. Other character: Python can process all character of ASCII and UNICODE.

TOKENS

  • Tokens is the smallest unit of any programming language.It is also known as Lexical unit.

Types of token are-

  1. keyword
  2. Identifiers
  3. Literals
  4. Operators 
  5. Punctuators

KEYWORDS


  • Keywords are those words which provides a specific meaning to interpreter.
  • These are reserved for specific functioning.
  • These can not be used as identifiers ,variable name or any purpose. 
               eg. false, class, if, or.

IDENTIFIERS

  • Theses are building blocks of a program and are used to give names to different parts/blocks of a program like variable, objects, classes, functions.
  • An identifier may be combination of letter and numbers.
  • An identifier must begin with an alphabet or an underscore ( _ ). Subsequent letters may be number (0-9).
  • Uppercase and lowercase has different meaning.
  • Length of an identifier is unlimited.
  • Keywords can not used as an identifier.
  • Ex. Myfile, Date_9_0_12.

LITERAL / VALUES 

  • Literal are also called constant values.
  • Python permits following types of literals.

  1.  String literals.
  2. Numeric literals.
  3. Boolean literals.
  4. Special literals.
  5. Literal collection.

String literals

  • String literals is sequence of characters that can be a combination of letters, numbers and special symbols, enclosed in quotation mark, single, double, triple. (' '," ","' "').
  • Types of string
  1. Single line string: Text ="hello world" or Text = 'hello world'.
  2. Multi line string: Text= 'hello/ or Text=
                                                 world'

Numeric literals

numeric values can be of 3 types-  

INT.  

  • Decimal int. literal - 10,17,210 etc.
  • Octal int. literal - 0o17, 0o217 etc.
  • Hexa decimal int.- 0x14 etc.           
FLOAT (floating point real value)

  • Fraction form - 2.5 , 4534.456+3455.434, etc.
  • Exponent form - 1.8E+5. etc.

COMPLEX ( complex numbers)

  • 3+5i etc.

BOOLEAN LITERAL

  • It can contain either of only 2 values- true or false.

SPECIAL LITERALS

  • None, which means nothing(no value)
             x= none

OPERATORS

  • An operator is symbol that trigger some action when applies to identifiers (s)/ operand(s).
  • Therefore, an operator requires operand (S) to computer upon.
             Eg: C=a+b
    Types of operators
  1. Uniary Operators.
  2. Binary Operators.

PUNCTUATORS

  • In Python, punctuator are used to construct the program and make balance between instruction and statements Punctuators have their own synthetic semantic significance.  
  • EX. /.;'=- etc.