
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 10478 Articles for Python

5K+ Views
In Python, a list is a dynamic array that can be expanded in size as needed. The maximum size of a list is limited by the system's memory and the platform's architecture. In this article, we will explore how to determine the maximum size of a list in Python. Understanding Python List Limits The size of a list in Python is not restricted by any fixed value set in the language itself but also it depends on below factors - Available system memory (RAM) System architecture, i.e., 32-bit or 64-bit The value of ... Read More

7K+ Views
In Python, strings are dynamic and can extend to a very large size, and can be limited only by the system's available memory. In other languages, compared to Python, it does not define a strict upper bound on string length. Instead, the practical maximum length of a string depends on the platform and memory constraints. In this article, we will explore how to determine the theoretical maximum string length in Python. Maximum Theoretical String Length Python strings are stored as sequences of Unicode characters, and the maximum size of a Python object is typically constrained by the value of sys.maxsize ... Read More

778 Views
In Python, floating-point numbers can be implemented using double-precision, i.e., 64-bit format, as per the IEEE 754 standard. These floats have a finite range and precision. The maximum value that a float can represent depends on the platform that we are using, but can be accessed using the sys.float_info attribute. Maximum Value of Float using sys.float_info The sys.float_info object provides details about the float implementation on the current platform. The attribute float_info.max gives the largest positive floating-point number representation. Example Here in this example, we are going to use float_info.max attribute from the sys.float_info object to get the maximum float value ... Read More

2K+ Views
Python allows dictionaries to be sorted using the built-in sorted() function. In this article, we will explore different ways to sort a dictionary in Python by its values. Sort a Dictionary Using itemgetter() method When we use the sorted() function along with the itemgetter() method of the operator module, the dictionary will be sorted by its values. The itemgetter() function returns a callable object that fetches an item from its operand using the provided index. Example Following is an example that shows how to sort a dictionary by its values using itemgetter() along with the sorted() function - from operator import ... Read More

625 Views
Python allows dictionaries to be sorted using the built-in sorted() function. Although dictionaries in Python 3.7+ preserve insertion order, we can still create a new dictionary sorted by its keys using various methods. In this article, we will explore different ways to sort a dictionary in Python by its keys. Using sorted() with a for Loop We can use the sorted() function on the dictionary keys and then iterate through them to build a new dictionary in key order. Example Following is an example, which shows how to sort a dictionary in Python using the sorted() function - dictionary = ... Read More

95K+ Views
Python has a built-in method called values() that returns a view object. The dictionary values are listed in the view object. We can use the values() method in Python to retrieve all values from a dictionary. Python's built-in values() method returns a view object that represents a list of dictionaries containing every value. In this article, we are going to see about the various ways to print all the values of the given dictionary in Python. Using dict.values() Method Python's dict.values() method can be used to retrieve the dictionary values which can be printed using the print() function. Example Following ... Read More

107K+ Views
A Python dictionary is an unordered collection of data values. It contains a key-value pair, in contrast to other data structures that only include one value per entry. In this article, we are going to see the various ways to print all the keys of a dictionary in Python. Using dict.keys() Method Python's dict.keys() method can be used to retrieve the dictionary keys, which can be printed using the print() function. This method returns a list object, which contains every key in the dictionary. The dictionary elements can be accessed using the dict.keys() method, just like we do with a list ... Read More

9K+ Views
When we open a file using the Python's built-in function open(), then the data temporarily stored in memory can be managed by setting the buffering parameter in the function. Buffering helps to improve the performance of opening a file by reducing the number of interactions with the disk during file input/output operations. Understanding the Buffering Parameter The buffering parameter in Python's open() function allows us to define how much data is stored in memory before being written to or read from the file. This buffering parameter is used to handle file operations with large data or frequent writes. Syntax Here ... Read More

1K+ Views
When the U modifier is used while opening a file then Python opens the file in Universal Newline mode. This mode enables Python to automatically detect and handle all common newline characters including , \r and \r during file reading. It is particularly useful when working with text files generated on various operating systems such as Windows, macOS or Linux which use different newline conventions. The U mode was used in Python 2 and early Python 3 versions to enable newline normalization. It allowed consistent handling of line endings regardless of the platform on which the file was created. However, ... Read More

13K+ Views
When we use the b modifier while opening a file, then the file is opened in binary mode. Any file whose format doesn't consist of readable characters is referred to as a "binary" file. Binary files include audio files like MP3s, text formats such as Word or PDF, and image files such as JPEGs or GIFs. Normally, the files are automatically opened in text mode in Python. When choosing a mode, include the letter "b" for binary mode. By default, the open() function opens a file in text format. As a result, the "wb" mode opens the file in binary format ... Read More