Found 11312 Articles for Python

Program to check if a string contains any special character

Niharika Aitam
Updated on 06-Nov-2023 11:22:22


Python helps us to develop code as per the developer requirement and application. It provides multiple modules, packages, functions and classes which makes the code more efficient. Using python language, we can check if a string contains any special character or not. There are several ways to check the string for the specials characters in it, let’s see one by one. Using a Regular Expression The re module in Python provides support for regular expressions, which are patterns used to match character combinations in strings. The regular expression pattern [^a−zA−Z0−9\s] matches any non−alphanumeric character (excluding whitespace) in the string. The ... Read More

Program to Print K using Alphabets

Niharika Aitam
Updated on 06-Nov-2023 11:55:14


Python is used to print different patterns easily within less time as per the user requirement. In the same way, we can print the letter K using the alphabets available in the English language. Example In this example we will create the letter K by using the K alphabet. The below is the code. string="" j = 7 i = 0 for Row in range(0, 10): for Col in range(0, 10): if (Col == 1 or ((Row == Col ... Read More

Program to print window pattern

Niharika Aitam
Updated on 06-Nov-2023 12:10:20


Python is one of the most popular and efficient programming language which helps the developers to write and execute the code very easily and faster. It provides several methods, packages, modules and libraries to develop the code within no time and with less complexity. A window can be a square or a rectangle or a triangle with having a plus sign or without a plus sign, in the middle. In order to print the window pattern using the python language let’s see an example and understand. Example In this example, we will create a window in the rectangle without ... Read More

Print objects of a class in Python

Niharika Aitam
Updated on 06-Nov-2023 12:22:16


An object is the part of the Object Oriented Language (OOPs), which is an instance of the class. The class is the blueprint or template that specifies the methods and properties of that given class. When we create an object of a class, it contains all the set of instance methods and variables that are related to that particular object Using __str__ method We have two methods namely, __str__ or __repr__ in python which automatically calls the string and used to print the object with the detail view about it. Following is the syntax for using the __str__ method. ... Read More

Show Uniform Discrete Distribution in Statistics using Python

Pranay Arora
Updated on 02-Nov-2023 14:03:34


In the field of statistics, there is a major role played by probability distributions in modeling and analyzing various random phenomena. Uniform Discrete Distribution is one of them. It is particularly used when dealing with discrete random variables which have equally likely outcomes. Ahead in this article, we will explore Uniform Discrete Distribution in the light of Python programming, using the scipy.stats.randint() function. Scipy is a powerful python library for scientific analysis and calculations. The stats module provides tools for statistical analysis including probability distributions. The randint() function in the scipy.stats module represents the uniform discrete variable, which inherits its ... Read More

Show Tukey-Lambda Distribution in Statistics using Python

Pranay Arora
Updated on 02-Nov-2023 14:01:33


Introduction Statisticians skillfully mesh probability distributions with relevant data sources, thereby lending (or disavowing) plausibility to wide-ranging, though pertinent, hypotheses regarding variable complexities within those databases. In this realm, the Tukey Lambada distribution distinguishes itself via distinct features. With its versatility, the Tukey distribution efficiently models diverse datasets showcasing varied shapes, tails, and degrees of asymmetry. As we dive into Python implementation, it's crucial to understand the Tukey-Lambda distribution's fundamental traits first. Understanding the Tukey-Lambda Distribution In 1960s, John W. Tukey developed the Tukey-Lambda distribution – a statistical constant probability distribution. Flexible enough to accommodate multiple shape variances, this distribution ... Read More

Python - Unique Values Multiplication

Pranay Arora
Updated on 02-Nov-2023 13:04:22


List in python allows duplicate entries, that is we can have the same value twice in a list. That is useful in most cases, but sometimes there is a need to remove the duplicate elements to perform certain operations. In this article we will focus on how we can take up the unique values removing duplicates from a list of integers and finding their product. It has a wide use case scenario and we will try and discuss all possible ways to generate the output. Method 1: Set Implementation Set in python is unordered data collection that is iterable, mutable ... Read More

Python - Unique Tuple Frequency (Order Irrespective)

Pranay Arora
Updated on 02-Nov-2023 12:52:03


In this article, we will have input as a list of tuples and our goal will be to print the frequency of unique tuples but it will be order irrespective. Order irrespective means that a tuple (1, 2, 3) and (1, 3, 2) will be treated as same even though their order is different. For example, consider the following − Input [(1, 2, 3), (2, 1, 3), (4, 5, 6), (1, 2, 3), (3, 2, 1)] Output 2 Explanation The tuples at index 0, 1, 3 and 4 are same and hence frequency count increases by ... Read More

Python - Uneven Sized Matrix Column Minimum

Pranay Arora
Updated on 02-Nov-2023 13:59:29


In Python, when dealing with matrices of uneven row lengths, the efficiency in locating each column's minimum values becomes paramount; a variety of approaches each boasting its own strengths and suitability for different scenarios exist to tackle this task. We are going to delve into several methods within this article: from basic nested loops all the way up to advanced tools such as NumPy and Pandas. Ultimately, you will grasp a comprehensive understanding of two crucial skills: mastering the manipulation of uneven-sized matrices and extracting valuable information from them. Method 1: Using Nested Loops This method, utilizing nested loops, iterates ... Read More

Python - Tuple value product in dictionary

Pranay Arora
Updated on 02-Nov-2023 12:49:07


Dictionaries in python are widely used, to store data in key-value pairs. Many times, we get stuck in finding the product of elements in the tuple received as value in the dictionary. This mostly arises in situations working with data manipulation or analysis. Through this article, we will code and understand various ways to unpack the dictionary and calculate the product of tuple elements at each index. Input {'a': (1, 3, 5, 7), 'b': (2, 4, 6, 8), 'c': (2, 3, 5, 7)} Output (4, 36, 150, 392) Method 1: Using Tuple Unpacking and zip() Function ... Read More

1 2 3 4 5 ... 1132 Next