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-
- Mutable (changeable) - list, dictionary, sets.
- 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.
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]
>>> 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.
- p=(1,2,3,4,5,6)
- 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.
No comments:
Post a Comment