Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Server Side Programming Articles
Page 64 of 2109
Fibonacci Search Visualizer using PyQt5
The Fibonacci Search is an efficient algorithm for searching sorted arrays using Fibonacci numbers. Here, we'll create a visual demonstration of this algorithm using PyQt5 to help understand how it divides the search space. How Fibonacci Search Works The algorithm uses Fibonacci numbers to divide the sorted array into unequal parts, similar to binary search but with golden ratio proportions. It finds two consecutive Fibonacci numbers that are greater than or equal to the array length. Algorithm Steps Step 1: Find the smallest Fibonacci number greater than or equal to the array length. Step 2: ...
Read MoreFernet (Symmetric Encryption) using a Cryptography Module in Python
Symmetric encryption is a cryptographic technique where the same key is used for both encryption and decryption of messages. The Fernet module from Python's cryptography library provides a simple, secure implementation of symmetric encryption using the AES algorithm. How Symmetric Encryption Works Symmetric encryption follows these key steps − Key generation − A secret key is generated and shared between sender and receiver for encrypting and decrypting messages. Encryption − The sender converts plaintext into unreadable ciphertext using the secret key. Transmission − The encrypted ciphertext is ...
Read MoreDifference Between Tensor and Variable in Pytorch
PyTorch is an open-source Python library used for machine learning, computer vision and deep learning. It is an excellent library to build neural networks, conduct complex computations and optimize gradient differentiation. Developed by Facebook's Research Team (FAIR), it gained popularity due to its dynamic computing graphs, allowing it to change graphs in real time. This was revolutionary back in 2016 when models working in real-time just started to emerge. There are two main data structures to understand in PyTorch: Tensor and Variable. Let's explore their differences and evolution. What is a Tensor? A Tensor is used ...
Read MoreDifference between str.capitalize() vs str.title()
In Python, strings are immutable sequences of characters that can be manipulated using various built-in methods. Two commonly used string methods are capitalize() and title(), which both modify the case of characters but work differently. str.capitalize() The capitalize() method converts only the first character of the entire string to uppercase and makes all remaining characters lowercase. It treats the entire string as a single unit, regardless of spaces or word boundaries. Syntax str_name.capitalize() Here, str_name is the input string. The method takes no arguments and returns a new string. Example ...
Read MoreDifference between Shallow Copy vs Deep Copy in Pandas Dataframe
One of the most useful data structures in Pandas is the DataFrame — a 2-dimensional table-like structure containing rows and columns to store data. Understanding the difference between shallow and deep copies is crucial when manipulating DataFrames, as it affects how changes propagate between original and copied objects. What is Shallow Copy? A shallow copy creates a new DataFrame object that references the original data. The copied DataFrame points to the same memory location as the original DataFrame. Any modifications to the underlying data will affect both the original and shallow copy. Syntax df_shallow = ...
Read MoreDifference between Shallow and Deep Copy of a Class
A class is a blueprint that defines objects' attributes (data) and behaviors (methods). When working with class instances, you often need to create copies. Python provides two types of copying: shallow copy and deep copy, each with different behaviors regarding nested objects. Shallow Copy Shallow copy creates a new object but stores references to the original elements. Instead of duplicating nested objects, it copies their references. This means modifications to nested objects affect both the original and the copy. Shallow copy is performed using copy.copy() method from the copy module. Deep Copy Deep copy creates ...
Read MoreDifference Between Queue and Collestions in Python
In Python, a queue is a data structure that follows FIFO (First In First Out) principle, where elements are processed in the exact order they were added. Python provides two main approaches for queue implementation: queue.Queue and collections.deque, each with distinct characteristics suited for different scenarios. Key Differences Category queue.Queue collections.deque Thread Safety Thread-safe with built-in synchronization for multithreading Not thread-safe by default, requires external synchronization Functionality Designed specifically for FIFO operations with put() and get() methods Double-ended queue supporting both FIFO and LIFO with methods like append(), pop(), popleft() ...
Read MoreCreate list of Tuples using for Loop using Python
Python's key data structures are lists and tuples. Tuples are immutable collections where elements cannot be changed once set, while lists can be modified after initialization. When dealing with data that needs to be grouped together, a for loop is commonly used to create lists of tuples. This tutorial demonstrates creating a list of tuples using a for loop, simplifying repetitive data organization tasks. Syntax for variable in iterable: # loop code Basic Operations on Tuples Creating and Accessing Tuples # Initializing tuples my_tuple = (1, 2, "Hello", ...
Read MoreHow to Create a Dictionary Of Tuples in Python
A dictionary of tuples in Python combines the key-value structure of dictionaries with the immutable, ordered nature of tuples. This creates an efficient way to store multiple related values for each key, such as student information, product details, or coordinates. Syntax The basic syntax for creating a dictionary of tuples is ? dictionary_name = { key1: (value1_1, value1_2, ...), key2: (value2_1, value2_2, ...), key3: (value3_1, value3_2, ...) } Basic Example Let's create a dictionary storing student names and their test scores ...
Read MoreHow to Create Acronyms from Words Using Python
An acronym is an abbreviated version of a phrase formed by taking the first character of each word. For example, "CPU" is an acronym for "Central Processing Unit". In this article, we will learn different methods to create acronyms from words using Python. Example Scenario Input: "Automatic Teller Machine" Output: "ATM" Explanation: The acronym is created by taking the first character of each word: A-T-M. Algorithm to Create Acronyms The following steps create acronyms from words using Python − Split the input string into individual words using split() ...
Read More