Python tell() function Last Updated : 28 Sep, 2021 Comments Improve Suggest changes Like Article Like Report Python too supports file handling and provides inbuilt functions for creating, writing and reading files. There are two types of files that can be handled in python, normal text files and binary files (written in binary language,0s and 1s). Text files: In this type of file, Each line of text is terminated with a special character called EOL (End of Line), which is the new line character (‘\n’) in python by default. Binary files: In this type of file, there is no terminator for a line and the data is stored after converting it into machine understandable binary language. Refer the below articles to get the idea about basics of File handling. Basics or file handlingReading and Writing to fileAccess modes tell() method: Access modes govern the type of operations possible in the opened file. It refers to how the file will be used once it's opened. These modes also define the location of the File Handle in the file. File handle is like a cursor, which defines from where the data has to be read or written in the file. Sometimes it becomes important for us to know the position of the File Handle. tell() method can be used to get the position of File Handle. tell() method returns current position of file object. This method takes no parameters and returns an integer value. Initially file pointer points to the beginning of the file(if not opened in append mode). So, the initial value of tell() is zero.syntax : file_object.tell() Let's suppose the text file named "myfile" looks like this: # Example 1: Position of File Handle before reading or writing to file. Python3 # Python program to demonstrate # tell() method # Open the file in read mode fp = open("myfile.txt", "r") # Print the position of handle print(fp.tell()) #Closing file fp.close() output : 0 # Example 2: Position of File Handle after reading data from file. Python3 # Python program to demonstrate # tell() method # Opening file fp = open("sample.txt", "r") fp.read(8) # Print the position of handle print(fp.tell()) # Closing file fp.close() Output : 8 # Example 3: For binary files. Let's create a binary file and we will notice the position of handle before writing and after writing to binary file. Python3 # Python program to demonstrate # tell() method # for reading binary file we # have to use "wb" in file mode. fp = open("sample2.txt", "wb") print(fp.tell()) # Writing to file fp.write(b'1010101') print(fp.tell()) # Closing file fp.close() Output : 0 7 Comment More infoAdvertise with us Next Article Python tell() function shaikameena Follow Improve Article Tags : Technical Scripter Python Technical Scripter 2019 python-file-handling Practice Tags : python Similar Reads Python str() function The str() function in Python is an in-built function that takes an object as input and returns its string representation. It can be used to convert various data types into strings, which can then be used for printing, concatenation, and formatting. Letâs take a simple example to converting an Intege 3 min read type() function in Python The type() function is mostly used for debugging purposes. Two different types of arguments can be passed to type() function, single and three arguments. If a single argument type(obj) is passed, it returns the type of the given object. If three argument types (object, bases, dict) are passed, it re 5 min read Python Functions Python Functions is a block of statements that does a specific task. The idea is to put some commonly or repeatedly done task together and make a function so that instead of writing the same code again and again for different inputs, we can do the function calls to reuse code contained in it over an 9 min read Python int() Function The Python int() function converts a given object to an integer or converts a decimal (floating-point) number to its integer part by truncating the fractional part.Example:In this example, we passed a string as an argument to the int() function and printed it.Pythonage = "21" print("age =", int(age) 3 min read Python len() Function The len() function in Python is used to get the number of items in an object. It is most commonly used with strings, lists, tuples, dictionaries and other iterable or container types. It returns an integer value representing the length or the number of elements. Example:Pythons = "GeeksforGeeks" # G 2 min read Python map() function The map() function is used to apply a given function to every item of an iterable, such as a list or tuple, and returns a map object (which is an iterator). Let's start with a simple example of using map() to convert a list of strings into a list of integers.Pythons = ['1', '2', '3', '4'] res = map( 4 min read pow() Function - Python pow() function in Python is a built-in tool that calculates one number raised to the power of another. It also has an optional third part that gives the remainder when dividing the result. Example:Pythonprint(pow(3,2))Output9 Explanation: pow(3, 2) calculates 32 = 9, where the base is positive and t 2 min read sum() function in Python The sum of numbers in the list is required everywhere. Python provides an inbuilt function sum() which sums up the numbers in the list. Pythonarr = [1, 5, 2] print(sum(arr))Output8 Sum() Function in Python Syntax Syntax : sum(iterable, start) iterable : iterable can be anything list , tuples or dict 3 min read Python print() function The python print() function as the name suggests is used to print a python object(s) in Python as standard output. Syntax: print(object(s), sep, end, file, flush) Parameters: Object(s): It can be any python object(s) like string, list, tuple, etc. But before printing all objects get converted into s 2 min read Like