Showing posts with label fundamental of python class 11 cbse part 2. Show all posts
Showing posts with label fundamental of python class 11 cbse part 2. 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}