Category: Python

Python Read and Write Files

Read and Write Files For reading and writing files with Python, first you need to use open function, inside the open function set the path of the file and then set the mode of the file. The mode can be ‘r’...

Python Exception Handling

Exception Handling Exceptions occur during execution of a block when errors are detected and interrupt the normal execution of a code block. Python handle exceptions using the statement try…except, similar to the try…catch in Java. Examples Exception Handling using try except...

Python Functions

Built-in Functions This section shows python built-in functions, types and classes like: range, sum, len, list, str, set, input, hash, getattr, setattr, open, chr, dir, any, ord, exec. abs() all() any() bin() bool() chr() dir() enumerate() eval() hash() int() len() list()...

Python Abs

Abs function The abs() function return the absolute value of a number. The argument inside the function may be an integer or a floating point number. Examples Example 1 >>> x = 5 >>> abs(x) 5 >>> Example 2 >>> y...

Python All

All function The all(iterable) function return True if all elements of the iterable are true or if the iterable is empty. Examples Example 1 >>> x = [1, 2, 3] >>> x.__iter__ <method-wrapper '__iter__' of list object at 0x02D549E0> >>> all(x)...