The largest new feature in Python 2.0 is a new fundamental data type: Unicode strings. Unicode uses 16-bit numbers to represent characters instead of the 8-bit number used by ASCII, meaning that 65,536 distinct characters can be supported.,ord(u), where u is a 1-character regular or Unicode string, returns the number of the character as an integer.,IDLE is the official Python cross-platform IDE, written using Tkinter. Python 2.0 includes IDLE 0.6, which adds a number of new features and improvements. A partial list:,To avoid introducing an ambiguity into Python’s grammar, if expression is creating a tuple, it must be surrounded with parentheses. The first list comprehension below is a syntax error, while the second one is correct:

```
import codecs
unistr = u '\u0660\u2000ab ...'
(UTF8_encode, UTF8_decode,
UTF8_streamreader, UTF8_streamwriter) = codecs.lookup('UTF-8')
output = UTF8_streamwriter(open('/tmp/output', 'wb'))
output.write(unistr)
output.close()
```

```
input = UTF8_streamreader(open('/tmp/output', 'rb'))
print repr(input.read())
input.close()
```

# Given the list L, make a list of all strings # containing the substring S. sublist = filter(lambda s, substring = S: string.find(s, substring) != -1, L)

sublist = [s for s in L if string.find(s, S) != -1 ]

[expression for expr in sequence1 for expr2 in sequence2... for exprN in sequenceN if condition ]

for expr1 in sequence1: for expr2 in sequence2: ... for exprN in sequenceN: if (condition): # Append the value of # the expression to the # resulting list.

In this tutorial, you'll learn everything about different types of operators in Python, their syntax and how to use them with examples.,Python language offers some special types of operators like the identity operator or the membership operator. They are described below with examples.,Operators are special symbols in Python that carry out arithmetic or logical computation. The value that the operator operates on is called the operand.,There are various compound operators in Python like a += 5 that adds to the variable and later assigns the same. It is equivalent to a = a + 5.

For example:

>>> 2 + 3 5

### Example 1: Arithmetic operators in Python

x = 15 y = 4 # Output: x + y = 19 print('x + y =', x + y) # Output: x - y = 11 print('x - y =', x - y) # Output: x * y = 60 print('x * y =', x * y) # Output: x / y = 3.75 print('x / y =', x / y) # Output: x // y = 3 print('x // y =', x //y) # Output: x ** y = 50625 print('x ** y =', x ** y)

**Output**

```
x + y = 19
x - y = 11
x * y = 60
x / y = 3.75
x // y = 3
x ** y = 50625
```

### Example 3: Logical Operators in Python

```
x = True
y = False
print('x and y is', x and y)
print('x or y is', x or y)
print('not x is', not x)
```

### Example 4: Identity operators in Python

x1 = 5 y1 = 5 x2 = 'Hello' y2 = 'Hello' x3 = [1, 2, 3] y3 = [1, 2, 3] # Output: False print(x1 is not y1) # Output: True print(x2 is y2) # Output: False print(x3 is y3)

Last Updated : 01 Mar, 2021,GATE CS 2021 Syllabus

Output :

1.4 - 1.4

Output:

GeeksforGeeks

In Python2, dividing two ints uses integer division, which ends up getting you the same thing as floored division. However, you can still use `//`

to get a floored result of floating point division. live example

# Python 2 >>> 10.0 / 3 3.3333333333333335 >>> 10.0 // 3 3.0

However, in **Python3**, dividing two ints results in a float, but using `//`

acts as integer division. live example

# Python3 >>> 10 / 3 3.3333333333333335 >>> 10 // 3 3

Floored division means round towards negative infinity. This is the same as truncation for positive values, but not for negative. 3.3 rounds down to 3, but -3.3 rounds down to -4.

# Python3 >>> -10 //3 - 4 >>> 10 //3 3

In python 2.7, to do real division you'll need to import division from a module named future:

```
from __future__
import division
```

Then, the `/`

will be the real (floating) division, i.e.:

15 / 4 => 3.75

And the `//`

will be the integer division (the integer part of the real division), i.e.:

`15 // 4 => 3`

n plays a very different role on each side of the =. On the right it is a value and makes up part of the expression which will be evaluated by the Python interpreter before assigning it to the name on the left.,In order to write programs that do things to the stuff we now call values, we need a way to store our values in the memory of the computer and to name them for later retrieval.,Names are also called variables, since the values to which they refer can change during the execution of the program. Variables also have types. Again, we can ask the interpreter what they are.,A reserved word that is used by the compiler to parse program; you cannot use keywords like if, def, and while as variable names.

```
>>> type("Hello, World!")
<class 'str'>
>>> type(17)
<class 'int'>
```

```
>>> type(3.2)
<class 'float'>
```

```
>>> type("17")
<class 'str'>
>>> type("3.2")
<class 'str'>
```

>>> 42000 42000 >>> 42, 000(42, 0)

```
>>> type('This is a string.')
<class 'str'>
>>> type("And so is this.")
<class 'str'>
>>> type("""and this.""")
<class 'str'>
>>> type('''and even this...''')
<class 'str'>
```

>>> print('' '"Oh no," she exclaimed, "Ben' s bike is broken!"''') "Oh no," she exclaimed, "Ben's bike is broken!" >>>

!= → It is just the opposite of ==. It is True if both values are not equal and False if they are equal.,== → It is used to check if two values are equal or not. It returns True if the values are equal, otherwise it returns False.,>= (greater than or equal to) → It is similar to > but will be True even if the values are equal. It is similar to >= of Maths.,In the above example, since the value of a is not equal to that of b, therefore (a == b) (equal to) returned False and (a !=b) (not equal to) returned True.

```
a = 3
b = 2
print("sum =", a + b)
print("difference =", a - b)
print("product =", a * b)
print("quotient =", a / b)
print("quotient (integer) =", a // b)
print("remainder =", a % b) print("power =", a ** b)
```

a, b = 3, 2 # assigning values to variables a and b c = a + b # storing sum of a and b in c print("sum =", c)

a, b = 5, 3 # assigning values to variables a and b print("quotient =", a / b) print("quotient (integer) =", a // b)

a, b = 4, 2 # assigning values to variables a and b print("quotient =", (a / b), "of type", type(a / b)) print("quotient (integer) =", (a // b), "of type", type(a // b))

print(2 == 2) print(2 == 3)

print(2 != 2) print(2 != 3)