Category: Python

Python Enumerate

Enumerate function The enumerate() function return an enumerate object. The object must be a sequence, a list or an iterator. Examples Example 1 >>> my_list = ['a', 'b', 'c', 'd', 'e'] >>> list(enumerate(my_list)) [(0, 'a'), (1, 'b'), (2, 'c'), (3, 'd'),...

Python Eval

Eval function The eval() function evaluates an expression and returns the value of expression. The return value can be number or string. Examples Example 1 >>> a = 2 >>> b = 3 >>> eval('a + b') 5 >>> eval('a +...

Python Hash

Hash function The hash(object) function return an integer value of the object. The returned values are used to compare dictionary keys during a dictionary search. Examples Example 1 >>> x = 2 >>> hash(x) 2 >>> y = -3 >>> hash(y)...

Python Int

Int function The int() function return an integer value or return 0 value if no arguments are given. Examples Example 1 >>> int() 0 >>> x = int() >>> x 0 >>> y = int(3) >>> y 3 >>> Example 2...

Python Len

Len function The len() function return the length of a sequence (string, tuple, list, range) or a collection (dictionary, set). Examples Example 1 >>> x = "abc, de, fgh" >>> len(x) 12 >>> y = '12345' >>> len(y) 5 >>> Example...