What is PEP8?

Vikram Chiluka
Updated on 26-Mar-2026 21:30:02

2K+ Views

In this article, we will explain PEP 8 and its uses in Python. We'll explore key style guidelines that make Python code more readable and maintainable. What is PEP 8? PEP stands for Python Enhancement Proposal. PEP 8 is the official style guide for writing readable and consistent Python code. It was written in 2001 by Guido van Rossum, Barry Warsaw, and Nick Coghlan. The primary goal of PEP 8 is to improve code readability and consistency across Python projects. Good coding style makes code more reliable and easier to understand for other developers. Indentation ... Read More

How do map, reduce and filter functions work in Python?

Vikram Chiluka
Updated on 26-Mar-2026 21:29:32

13K+ Views

Python's map(), filter(), and reduce() functions bring functional programming concepts to Python. These functions accept a function and an iterable, applying the function to elements in different ways to produce results. map() Function The map() function applies a given function to each item in an iterable and returns a map object (iterator) with the results. Unlike reduce(), it operates independently on each item rather than producing a single cumulative result. Syntax map(function, iterable) Parameters function − The function to apply to each element iterable − The sequence to iterate over (list, ... Read More

Difference between indexing and slicing in Python

Vikram Chiluka
Updated on 26-Mar-2026 21:29:08

14K+ Views

In this article, we will explain the differences between indexing and slicing in Python. Both are fundamental operations for working with sequence data types. Indexing and slicing are applicable only to sequence data types. The order in which elements are inserted is preserved in sequence types, allowing us to access elements via indexing and slicing. Python's sequence types include list, tuple, string, range, bytes, and byte arrays. Indexing and slicing are applicable to all of these types. Indexing The term indexing refers to accessing a single element of a sequence based on its position within the ... Read More

Difference between for loop and while loop in Python

Vikram Chiluka
Updated on 26-Mar-2026 21:28:32

53K+ Views

In this post, we will understand the difference between the for and while loop in Python. Both are control flow statements used for repetitive execution, but they serve different purposes based on the situation. For Loop A for loop is a control flow statement that executes code for a predefined number of iterations. The keyword used in this control flow statement is for. When the number of iterations is already known, the for loop is used. The for loop is divided into two parts − Header − This part specifies the iteration of the loop. In ... Read More

Python Program to Read First n Lines of a File

Vikram Chiluka
Updated on 26-Mar-2026 21:27:52

19K+ Views

In this article, we will show you how to read and print the first N lines of a text file using Python. This is useful when you need to preview large files or extract specific portions of text data. Assume we have a text file named sample.txt with the following content − Good Morning Tutorials Point This is Tutorials Point sample File Consisting of Specific abbreviated source codes in Python Seaborn Scala Imagination Summary and Explanation Welcome user Learn with a joy Method 1: Using readlines() with Slicing The most straightforward approach is to ... Read More

How to Print Lines Containing Given String in File using Python?

Vikram Chiluka
Updated on 26-Mar-2026 21:27:29

7K+ Views

In this article, we will show you how to print all the lines that contain a given specific string in a text file using Python. This is a common task when searching through files for specific content or filtering data. Let's assume we have a text file named ExampleTextFile.txt with the following content ? Sample File Content Good morning to TutorialsPoint This is TutorialsPoint sample File Consisting of Specific source codes in Python, Seaborn, Scala Summary and Explanation Welcome to TutorialsPoint Learn with a joy Good morning to TutorialsPoint Algorithm (Steps) Following are ... Read More

How to Find the Most Repeated Word in a Text File using Python?

Vikram Chiluka
Updated on 26-Mar-2026 21:27:05

9K+ Views

In this article, we will show you how to find the most repeated word in a given text file using Python. We'll use the Counter class from the collections module to efficiently count word frequencies. Assume we have a text file named sample.txt containing some random text ? Good Morning TutorialsPoint This is TutorialsPoint sample File Consisting of Specific source codes in Python, Seaborn, Scala Summary and Explanation Welcome TutorialsPoint Learn with a joy Using Counter from Collections Module The Counter class is a specialized dictionary that counts hashable objects. It's perfect for counting ... Read More

How to Find the Longest Words in a Text File using Python?

Vikram Chiluka
Updated on 26-Mar-2026 21:26:36

15K+ Views

In this article, we will show you how to find and print all the longest words from a given text file using Python. The longest words are those having the same length as the maximum length word in the file. We'll demonstrate this with a sample text file containing various words of different lengths. Sample Text File Let's create a sample text file to work with ? # Create a sample text file sample_text = """Good Morning Tutorials Point This is Tutorials Point sample File Consisting of Specific abbreviated source codes in Python Seaborn Scala ... Read More

How to Split given list and insert in excel file using Python?

Vikram Chiluka
Updated on 26-Mar-2026 21:26:10

4K+ Views

In this article, we will show you how to split a Python list and insert those items into an Excel file using pandas. This technique is useful for organizing data into structured columns for analysis and reporting. Assume we have a list containing player names and countries. We'll split this list and create an Excel file with separate columns for each data type. Expected Output Our program will create an Excel file outputExcelFile.xlsx with the following structure ? Player Name Country Virat Kohli India Bhuvaneshwar Kumar India Mahendra ... Read More

How to get values of all rows in a particular column in openpyxl in Python?

Vikram Chiluka
Updated on 26-Mar-2026 21:25:44

9K+ Views

In this article, we will show you how to get all the row values of a particular column in an excel file using the openpyxl library in Python. This is useful when you need to extract specific column data from Excel files for analysis or processing. Assume we have an Excel file named sampleTutorialsPoint.xlsx containing cricket player data. We will extract all row values from a specific column. Sample Data: sampleTutorialsPoint.xlsx Player Name Age Type Country Team Runs Wickets Virat Kohli 33 Batsman India Royal Challengers Bangalore 6300 20 Bhuvaneshwar ... Read More

Advertisements