Escape Characters in Python

--> In String literals we can use escape characters to associate a special meaning.

>>>s="siddu\nsoftware"

>>> print(s)

durga

software.

>>>s="siddu\tsoftware"

>>> print(s) #siddu software


>>>s="This is " symbol"

    File "<stdin>", line 1

s="This is "symbol" 


SyntaxError: invalid syntax

>>>s="This is \" symbol"

>>> print(s)

This is "symbol


-->The following are various important escape characters in Python

\n===>New Line

\t===>Horizontal tab 

\r===>Carriage Return

\b===>Back space 

\f===>Form Feed

\V==>Vertical tab

\'>Single quote

\">Double quote

\\===>back slash symbol

None Data Type and Constants in Python

-->None means Nothing or No value associated.

-->If the value is not available, then to handle such type of cases None introduced. It is something like null value in Java.


Example:

def n1(): a=10

print(n1())

None















Constants 


-->Constants concept is not applicable in Python.

-->But it is convention to use only uppercase characters if we don't want to change value.

MAX_VALUE=10

-->It is just convention but we can change the value.

Andhra Pradesh is now OPEN with new best policies


-->Govt of AP  inviting you to invest in our state, where we have rolled out a red carpet to welcome you.


-->In AP, a business-friendly state government, talented youngsters and robust infrastructure await you.


-->The new policy framework has been designed based on comprehensive consultations with Industry veterans. 


-->The policy framework aims to foster businesses and a spirit of entrepreneurship in our state. We're building the best business ecosystem in the country.


-->Govt personally want to assure you that the GoAP will take every step to help you set a base in AP and grow. 


-->There's never been a better time to invest in India, there's never been a better time to invest in Andhra Pradesh!


-->Collaborate with us on this exciting growth journey, where we can expand both - your business horizons and our state's potential. 

Looking forward to seeing you in Andhra Pradesh!










AP Six Landmark Policies

-->The Cabinet approved six landmark policies that will transform Andhra Pradesh into an industrial powerhouse, marking a significant step towards fulfilling our 20 lakh job creation promise.


-->These policies align with our vision to attract investment, create jobs, boost entrepreneurship, and lead in clean energy. 


-->Our major focus is employment generation and empowering the youth of AP to think globally and act globally, with initiatives like One Family, One Entrepreneur.


These six policies are: 


1. AP Industrial Development Policy 4.0 (AP IDP 4.0)


2. AP MSME & Entrepreneur Development Policy 4.0 (AP MEDP 4.0)


3. AP Food Processing Policy 4.0 (AP FPP 4.0)


4. AP Electronics Policy 4.0 (AP EP 4.0)


5. AP Private Parks Policy 4.0 (AP PPP 4.0)


6. AP Integrated Clean Energy Policy 4.0 (AP ICE 4.0)

Fundamental Data Types and it's Immutability in Python

 -->All Fundamental Data types are immutable. i.e once we creates an object, we cannot perform any changes in that object.


-->If we are trying to change, then with those changes a new object will be created. This non-changeable behavior is called immutability.


-->In Python if a new object is required, then PVM wont create object immediately. First it will check is any object available with the required content or not. 


-->If available then existing object will be reused. If it is not available then only a new object will be created.


-->The advantage of this approach is memory utilization and performance will be improved.


-->But the problem in this approach is,several references pointing to the same object,by using one reference if we are allowed to change the content in the existing object then the remaining references will be effected.


-->To prevent this immutability concept is required. According to this once creates an object we are not allowed to change content. 


-->If we are trying to change with those changes a new object will be created.


>>> a=10

>>> b=10

>>>a is b#True

>>> id(a)#1572353952

>>> id(b)#1572353952


>>> a=10+5j

>>> b=10+5j

>>> a is b#False

>>> id(a)#15980256

>>> id(b)#15979944


>>> a=True

>>> b=True

>>> a is b#True

>>>id(a)#1572172624

>>> id(b)#1572172624


>>> a='siddu'

>>> b='siddu'

>>> a is b#True

>>> id(a)#16378848

>>> id(b)#16378848



bytearray Data type in Python

 -->bytearray is exactly same as bytes data type except that its elements can be modified.


Example:

>>>x=[10,20,30,40]

>>>b=bytearray(x)

>>>for i in b: print(i)#10 20 30 40

>>>b[0]=100

>>>for i in b: print(i)#100 20 30 40


Example:

>>> x =[10,256]

>>> b= bytearray(x)

ValueError: byte must be in range(0,256)


bytes Data Type in Python

 -->bytes data type represents a group of byte numbers just like an array.


Example

>>>x=[10,20,30,40]

>>>b = bytes(x)

>>>type(b)#bytes

>>>print(b[0])#10 

>>>print(b[-1])#40

>>> for i in b : print(i)#20 30 40 10


Conclusion 1:

-->The only allowed values for byte data type are 0 to 256.

-->By mistake if we are trying to provide any other values then we will get value error.


Conclusion 2:

-->Once we creates bytes data type value, we cannot change its values, otherwise we will get TypeError.

Example

>>> x=[10,20,30,40]

>>> b=bytes(x)

>>> b[0]=100#TypeError: 'bytes' object does not support item assignment

list data type in Python

-->If we want to represent a group of values as a single entity where insertion order is required,To preserve and duplicates are allowed, then we should go for list data type.


1. insertion order is preserved

2. heterogeneous objects are allowed

3. duplicates are allowed

4. Growable in nature

5. values should be enclosed within square brackets.


Example

list=[10,10.5,siddu,True,10]

print(list)# [10,10.5, 'siddu', True,10]


>>>list=[10,20,30,40]

>>> list[0]#10

>>> list[-1]#40

>>> list[1:3]#[20, 30]

>>> list[0]=100

>>> for i in list:

              print(i)#100 20 30 40


-->list is growable in nature. i.e., based on our requirement, we can increase or decrease the size.


>>> list=[10,20,30]

>>> list.append("siddu") 

>>> list[10, 20, 30, 'siddu']

>>> list.remove(20)

>>> list#[10, 30, 'siddu']

>>> list2=list*2

>>> list2#[10, 30, 'siddu', 10, 30, 'siddu']


Note: An ordered, mutable, heterogenous collection of eleemnts is nothing but list, where duplicates also allowed.

tuple data type in Python


-->tuple data type is exactly same as list data type except that it is immutable.i.e we cannot change values.


-->Tuple elements can be represented within parenthesis.


Example:

>>>t=(10,20,30,40)

>>>type(t)

<class 'tuple'>

>>>t[0]=100

TypeError: 'tuple' object does not support item assignment 

>>>t.append("siddu")

AttributeError: 'tuple' object has no attribute 'append'

>>>t.remove(10)

AttributeError: 'tuple' object has no attribute 'remove'


Note: tuple is the read only version of list

range Data Type in Python

-->range Data Type represents a sequence of numbers.

-->The elements present in range Data type are not modifiable. i.e range Data type is immutable.


Form-1: range(10)#generate numbers from 0 to 9

Example:

rarange(10)

for i in r: print(i) 0 to 9


Form-2; range(10,20)#generate numbers from 10 to 19

r = range(10,20)

for i in r: print(i) 10 to 19


Form-3: range(10,20,2)#2 means increment value.

r = range(10,20,2)

for i in r: print(i) #10,12,14,16,18


-->We can access elements present in the range Data Type by using index.


r=range(10,20)

r[0]==>10

r[15]==>IndexError: range object index out of range

-->We cannot modify the values of range data type

Example:

r[0]=100

TypeError: 'range' object does not support item assignment.

-->We can create a list of values with range data type.

Example

>>> l=list(range(10))

>>>l#[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]

set Data Type in Python

If we want to represent a group of values without duplicates where order is not important, then we should go for set Data Type.


1. insertion order is not preserved

2. duplicates are not allowed

3. heterogeneous objects are allowed

4. index concept is not applicable

5. It is mutable collection

6. Growable in nature

Example:

1) s=(100,0,10,200,10,'siddu')# (0, 100, 'siddu', 200, 10)


s[0]=>TypeError: 'set' object does not support indexing.

set is growable in nature, based on our requirement we can increase or decrease the size.


>>>s.add(60)

>>>s#(0, 100, 'siddu', 200, 10, 60)

>>> s.remove(100)

>>> s#(0, 'siddu', 200, 10, 60)

frozenset Data Type in Python

It is exactly same as set except that it is immutable. 

Hence we cannot use add or remove functions.


>>> s=(10,20,30,40)

>>> fs-frozenset(s)

>>> type(fs)

<class 'frozenset'> 5) >>> fs

frozenset((40, 10, 20, 30))

>>> for i in fs:print(i)

40 10 20 30

>>> fs.add(70)

AttributeError: 'frozenset' object has no attribute 'add' 

>>> fs.remove(10)

AttributeError: 'frozenset' object has no attribute 'remove'


dict Data Type In Python

 If we want to represent a group of values as key-value pairs then we should go for dict data type.


Example:

d=(101:'siddu',102:'ravi',103:'chiru')


Duplicate keys are not allowed but values can be duplicated.


If we are trying to insert an entry with duplicate key then old value will be replaced with new value.


Example:

>>> d=(101:'siddu',102:'ravi", 103:"chiru"}

>>> d[101]='lakshmi'

>>> d

(101: 'lakshmi', 102: 'ravi', 103: 'chiru')


We can create empty dictionary as follows d=()

We can add key-value pairs as follows d['a']='apple'

d['b']='banana'

print(d)


Note: dict is mutable and the order wont be preserved.

Downloading Talliki Vandhanam List

--> Citizens can know the status of Talliki Vandhanam Click Here -->Knowing the Status of Talliki Vandhanam   --> In GSWS NBM Login...