Python Articles

Page 55 of 852

Ethical Hacking with Python

Atharva Shah
Atharva Shah
Updated on 31-Dec-2024 1K+ Views

Python is an increasingly popular programming language for Ethical Hacking, especially in today's digital world, where security is paramount. With the rise of cybercrime, it's essential to take proactive measures to safeguard our online assets. Ethical Hacking is a critical step in this process, involving the identification and resolution of system vulnerabilities before they can be exploited by malicious hackers. This article will explore how Python is used for Ethical Hacking, including its advantages and best practices. Basics of Ethical Hacking Hacking is broadly classified into three types - Black Hat Hacking, White Hat Hacking, and Grey Hat Hacking. Black ...

Read More

How to Copy a Tensor in PyTorch?

AYUSH MISHRA
AYUSH MISHRA
Updated on 27-Dec-2024 10K+ Views

PyTorch is a very popular Python library used in machine learning. This library is developed by Facebook AI. This library provides robust tools for deep learning, neural networks, and tensor computations. Below are different approaches to Copying a Tensor in PyTorch. Using clone() function Using detach() method Using copy.deepcopy() method Using clone() function We use the clone() method to create a deep copy of a tensor. In deep copy, the original tensor and the copied tensor do not share memory. If we make changes in copied ...

Read More

Unique Number of Occurrences in Python

Akshitha Mote
Akshitha Mote
Updated on 20-Dec-2024 1K+ Views

Suppose we have an array, and we need to check whether each element has a unique number of occurrences. If no such element exists, we return false; otherwise, we return true. For example, given the array [1, 1, 2, 2, 2, 3, 4, 4, 4, 4], the function will return true because no two elements have the same number of occurrences: 1 occurs twice, 2 occurs three times, 3 occurs once, and 4 occurs four times. Various Techniques to Find Unique Occurrences Following are the various techniques to find the unique occurrence of the elements in a list − ...

Read More

Python Sequence Types

SaiKrishna Tavva
SaiKrishna Tavva
Updated on 18-Dec-2024 11K+ 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

Check whether product of \\\\\'n\\\\\' numbers is even or odd in Python

Akshitha Mote
Akshitha Mote
Updated on 17-Dec-2024 655 Views

In this article, we try to find different methods to solve a problem to check whether the product of n numbers is even or odd. A number that is divisible by 2 is known as an even number. otherwise; it is an odd number. For example, 14 and 12 are two even numbers, the product is 168 is an even number. 9 and 5 are two odd numbers, the product is 45 is an odd number. Consider one even number 2 and one odd number 3, product of these two numbers is 6 an even number. Facts to Check if ...

Read More

Difference between == and is operator in python.

Akshitha Mote
Akshitha Mote
Updated on 17-Dec-2024 1K+ Views

In Python, the == and is operators are used for comparison, but they serve different purposes. The == operator checks for equality of values, which means it evaluates whether the values of two objects are the same. On the other hand, the is operator checks for identity, meaning it determines whether two variables point to the same object in memory. Before discussing the differences between the == and is operators in Python, let’s first understand these operators in detail. What Is the 'is' Operator? The Python is operator tests whether two variables refer to the same object in memory. If ...

Read More

Find Peak Element in Python

SaiKrishna Tavva
SaiKrishna Tavva
Updated on 12-Dec-2024 5K+ Views

A peak element in an array is defined as an element that is greater than its neighbors. We can use some common approaches such as binary search to efficiently locate a peak element and linear search algorithm which involves iterating through an array. Binary Search Approach The Binary Search is an efficient technique for locating a peak element in an array. To find a peak, follow these steps: Choose the middle element of the array. ...

Read More

How to save a histogram plot in Python?

SaiKrishna Tavva
SaiKrishna Tavva
Updated on 12-Dec-2024 7K+ Views

When working with data visualization, plotting and saving a histogram on a local machine is a common task. This can be done using various functions provided by Python's Matplotlib, such as plt.savefig() and plt.hist(). The plt.hist is used function to create a histogram, by taking a list of data points. After the histogram is plotted we can save it, by using the plt.savefig() function. Steps to Plot, Save and Display a Histogram The steps included to plot and save the histogram are as follows. Configure ...

Read More

Python Program to Implement Binary Search without Recursion

SaiKrishna Tavva
SaiKrishna Tavva
Updated on 12-Dec-2024 5K+ Views

To implement binary search without recursion, the program takes a sorted list and a key as input. It uses the Binary search method, which is an efficient way to find a specific item in a sorted list. It works by repeatedly dividing the list in half. This method works by first comparing the key with the middle element of the list. If the key matches the middle element, the search is successful, and the index is returned. If the key is less than the middle element, the search continues on the left subarray; if it's greater, the search shifts to ...

Read More

How to install Python in Ubuntu?

Abhishek Nair
Abhishek Nair
Updated on 21-Nov-2024 486 Views

Python is a powerful, open-source and easy to learn programming language. It is one of the most popular modern programming languages with a huge community of developers and extensive documentation. It usually comes pre-installed on all latest Linux systems as it is one of the building blocks of many operating system tools. Though, based on user requirement, one can install specific version of Python from available sources. In this tutorial, we will show you two ways to install Python on an Ubuntu system − Installing Python using package manager (apt) Installing Python using its source code Using Package ...

Read More
Showing 541–550 of 8,519 articles
« Prev 1 53 54 55 56 57 852 Next »
Advertisements