
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 10400 Articles for Python

250 Views
In python, the runtime context is supported by the with statement. The context is defined by the context manager. Using the context manager, we can create user defined classes to define the runtime context. It enters into the task before executing the statement body, and when the statement body is completed, it ends.There are two different methods for context manager. These methods are −Method __enter__()The __enter__() method is used to enter into the runtime context. It will return either the current object or another related object. The returned value is bound to the identifier in as clause of the with ... Read More

4K+ Views
The byte and bytearrays are used to manipulate binary data in python. These bytes and bytearrys are supported by buffer protocol, named memoryview. The memoryview can access the memory of other binary object without copying the actual data. The byte literals can be formed by these options. b‘This is bytea with single quote’ b“Another set of bytes with double quotes” b‘’’Bytes using three single quotes’’’ or b“””Bytes using three double quotes””” Some of the methods related to byte and bytearrays are − Method fromhex(string) The fromhex() method returns byte object. It takes a string where each byte is ... Read More

10K+ Views
In Python programming, some basic sequence type classes are, Lists , Strings , Tuples, Range, etc, these data structures hold an ordered collection of items. They allow us to access their elements through indexing and iteration, there are additional sequence-type objects such as Byte sequences. Sequence Types In Python Sequence types in Python are categorized into two types they are mutable and immutable sequences. Mutable Sequence Types These Sequences can be changed after their creation, and also we can modify elements, adding new elements and removing existing ones. Lists: A list is a mutable, ordered ... Read More

4K+ Views
The Numeric Types in Python are the integer datatypes. It includes integers, floatimg point, complex, etc. The complex includes real and imag parts. Also, includes Hexadecimal and Octal types. Python int datatype The Numeric Types include the int datatypes − a = 5 print("Integer = ", a) print("Type = ", type(a)) Output Integer = 5 Type = Python float datatype The Numeric Types include the float datatypes − Example a = 7E2 print("Float = ", a) print("Type = ", type(a)) Output Float = 700.0 Type = Python complex datatype The Numeric Types include the ... Read More

1K+ Views
The problem statement is to remove the nth character from the given string. Let's understand with an example. Consider my_string = "Tutorialspoint". The given value of n is 6; then we need to remove the 5th character from the string. Because the index value starts from zero. And it should result in "Tutorialspoint". Removing nth Character using a for Loop The for loop can be used to remove the n-th character from a string. In this approach, we iterate through each index of the string and print the characters. If the index value is equal to the given (n-1)th value, we ... Read More

3K+ Views
This article will teach you how to determine whether a string contains a URL or not. In Python, strings are collections of bytes that represent Unicode characters. You can use single or double quotes and everything enclosed in them is considered as a string. When given a string, we will first determine whether it contains a URL. If one is found, we will then print the URL. Using findall() method We will employ Python's regular expression concept to resolve this issue. Regular expressions are supported by the Python re package. Using a particular syntax defined in a pattern, a regular ... Read More

3K+ Views
List is a built-in data structure in python which functions like a dynamically sized array. Lists are created by putting elements in square brackets ‘[element 1, element 2, ….]’. Elements present in list are indexed and the indexing starts from [0]. List has the following properties − List is mutable meaning that elements can be added, removed or changed from a list after its creation. List is ordered, so adding new elements to the list will not change the order of existing elements. List allows for entry of duplicate elements since each element has a unique index. A single ... Read More

2K+ Views
This article will demonstrate how write a Python program to sort a tuple (made up of float elements) using its float elements. Here, we'll look at both how to sort using the in-built sorted() function and how to sort using the in-place method of sorting. Input-Output Scenarios Following is an input and its output scenario determining the sorting of a tuple by its float element − Scenario-1 Input: tuple = [(‘Dengu’, ’54.865’), (‘Malaria’, ‘345.743’), (‘Corona’, ‘456.864’), (‘Typhoid’, ‘35.285’), (‘Jaundice’, ’83.367’)] Output: [(‘Corona’, ‘456.864’), (‘Malaria’, ‘345.743’), (‘Jaundice’, ’83.367’), (‘Dengu’, ’54.865’), (‘Typhoid’, ‘35.285’)] In the above scenario we can see that ... Read More

3K+ Views
This article teaches you how to write a python program to find mirror characters in a string. Let us first understand what mirror characters in a string are. Two identical alphabetically positioned characters, one from the front and the other from the back, are known as mirror characters. For example, the alphabet a's mirror character is "z, " "b's" is "y, " and so on. Input-Output Scenario Following is an input and its output example of mirror characters in a string − Input: p = 3 Input string = Coding Output: Cowrmt Here, the alphabets “d”, “i”, “n”, “g” ... Read More

1K+ Views
Python has an in built module called calendar which operation is related to calendar. There are some calendar functions in Python. calendar(year, w, l, c) This function shows the year, width of characters, no. of lines per week and column separations. Example print ("The calendar of 2014 is : ") print (calendar.calendar(2014, 3, 1, 4)) Output The calendar of year 2014 is : 2014 January ... Read More