Vikram Chiluka

Vikram Chiluka

216 Articles Published

Articles by Vikram Chiluka

Page 20 of 22

What is the use of the WITH statement in Python?

Vikram Chiluka
Vikram Chiluka
Updated on 22-Sep-2022 7K+ Views

In this article, we will learn about the “with” statement in python and its uses. The with statement in Python replaces a try-catch block with a simple shorthand. More significantly, it ensures that resources are closed immediately after processing. Reading or writing to a file is a common use of the with statement. A context manager is a function or class that supports the with statement. A context manager enables you to open and close resources right when you want to. The open() function, for example, is a context manager. When you use the with statement to call the ...

Read More

How to declare an attribute in Python without a value?

Vikram Chiluka
Vikram Chiluka
Updated on 22-Sep-2022 5K+ Views

In this article, we will show you how to declare an attribute in python without a value. In Python, as well as in several other languages, there is a value that means "no value". In Python, that value with no value is None, let us see how it is used. You simply cannot. Variables are just names in Python. A name always refers to an object ("is bound"). It is conventional to set names that do not yet have a meaningful value but should be present to None. Method 1: By Initializing them with None Directly We can directly assign ...

Read More

How does concatenation operator work on list in Python?

Vikram Chiluka
Vikram Chiluka
Updated on 22-Sep-2022 877 Views

In Python, a list is an ordered sequence that can hold several object types such as integer, character, or float. In other programming languages, a list is equivalent to an array. Concatenation of lists is an operation that adds the elements of one list to the end of another. We're discussing list data structures here, therefore we'll join the elements of one list to the end of another. In this article, we will show you how to concatenate lists in python. The following are the different methods to accomplish this task − Using Concatenation(+) Operator Using For Loop(Naive Method) ...

Read More

How to remove index list from another list in python?

Vikram Chiluka
Vikram Chiluka
Updated on 19-Sep-2022 3K+ Views

In this article, we will show you how to remove the index list elements from the original list using python. Now we see 2 methods to accomplish this task − Using pop() method Using del keyword Assume we have taken a list containing some elements. We will remove the index list elements from the main list using different methods as specified above. Note We must sort the indices list in descending order because removing elements from the beginning will change the indices of other elements, and removing another element will result in an incorrect result due to misplaced ...

Read More

What is PEP8?

Vikram Chiluka
Vikram Chiluka
Updated on 15-Sep-2022 2K+ Views

In this article, we will explain PEP8 and its uses in python. Also, we will see its advantages while coding. What is PEP8? PEP is an abbreviation for Python Enterprise Proposal. Writing code with good logic is a crucial aspect of programming, but many other important elements can affect the quality of the code. The developer's coding style makes the code more reliable, and every developer should remember that Python rigidly follows the string's order and format. A good coding style makes the code more readable. The code is simplified for the end user PEP 8 is a document that ...

Read More

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

Vikram Chiluka
Vikram Chiluka
Updated on 15-Sep-2022 13K+ Views

In this article, we will show you the Python's map(), filter(), and reduce() functions add a touch of functional programming to the language. All three of these are convenience functions that can be replaced with List Comprehensions or loops but offer a more elegant and concise solution to some problems. map(), filter(), and reduce() all work in the same way. These functions accept a function and a sequence of elements and return the result of applying the received function to each element in the sequence. map() function Like reduce(), the map() function allows you to iterate over each item in ...

Read More

Difference between indexing and slicing in Python

Vikram Chiluka
Vikram Chiluka
Updated on 15-Sep-2022 14K+ Views

In this article, we will explain to you the differences between indexing and slicing in python. Indexing and slicing are applicable only to sequence data types. The order in which elements are inserted is preserved in sequence type, allowing us to access its elements via indexing and slicing. To summarise, Python's sequence types are list, tuple, string, range, byte, and byte arrays. And indexing and slicing are applicable to all of these types. Indexing The term "indexing" refers to refers to an element of an iterable based on its position inside the iterable. The indexing begins from 0. The ...

Read More

Python Program to Read First n Lines of a File

Vikram Chiluka
Vikram Chiluka
Updated on 18-Aug-2022 19K+ Views

In this article, we will show you how to read and print the first N lines of a text file for the given N value using python. Assume we have taken a text file with the name ExampleTextFile.txt consisting of some random text. We will return the first N lines of a text file for the given N value. ExampleTextFile.txt 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 Algorithm (Steps) Following are the Algorithm/steps to be followed ...

Read More

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

Vikram Chiluka
Vikram Chiluka
Updated on 18-Aug-2022 7K+ Views

In this article, we will show you how to print all the lines that contain a given specific string in a given text file using python. Assume we have taken a text file with the name ExampleTextFile.txt consisting of some random text. We will return the lines from a text file containing a given particular string from a text file. ExampleTextFile.txt 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 the Algorithm/steps ...

Read More

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

Vikram Chiluka
Vikram Chiluka
Updated on 18-Aug-2022 9K+ Views

In this article, we will show you how to find the most repeated word in a given text file using python. Assume we have taken a text file with the name ExampleTextFile.txt consisting of some random text. We will return the most repeated word in a given text file ExampleTextFile.txt 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 Algorithm (Steps) Following are the Algorithm/steps to be followed to perform the desired task − Import the Counter function (The Counter class ...

Read More
Showing 191–200 of 216 articles
Advertisements