Found 10476 Articles for Python

How to change the PyGame icon?

Niharika Aitam
Updated on 09-Aug-2023 10:22:22

2K+ Views

While building video games, we often try to setup an image or logo for that developed game. Python provides a function in pygame named, set_icon(), which sets the icon as desired. Pygame is a set of modules that allows us to develop the games and multimedia applications. This is built in top of the SDL(Simple Direct Media Layer) library which has low access to the audio keyboard, mouse, joystick and graphics hardware through OpenGL and Direct3D. Syntax Following is the syntax for setting the icon for the game - pygame_icon = pygame.image_load(“image_name”) pygame.display.set_icon(pygame_icon) Where, pygame_icon is the name ... Read More

Ways to Convert a 3D list into a 2D list in Python

Aayush Shukla
Updated on 07-Aug-2023 22:02:51

404 Views

Python is a widely used programming language used for different purposes such as Web Development, Data Science, Machine Learning and to perform different operations with automations. In this article we will learn about different ways to convert a 3D list into 2D list. Let's first have a look how does both the types of list look like: - 3D List Three_dimensional_list = [ [['Sam', 'Tom'], ['Miller', 'David']], [['Rocky', 'Tyler'], ['Mason', 'Petrick']], [['Stefen', 'Damon'], ['Matt', 'Jeremy']] ] # This is the basic structure of a three dimensional list 2D ... Read More

How to change the position of legend using Plotly Python?

Niharika Aitam
Updated on 09-Aug-2023 10:21:06

1K+ Views

Plotly python is the library in python to create interactive visualizations using the plotly java script. It provides a wide range of charts and plots like scatter plots, line charts, bar charts and so on. Installing plotly library To use the plotly python library first we have to install the library in our python environment. The below is the code to install plotly python. pip install plotly On successful installation the above command generates the following output – Defaulting to user installation because normal site-packages is not writeable Collecting plotly Downloading plotly-5.14.1-py2.py3-none-any.whl (15.3 MB) ... Read More

How to change the position of legend in Pygal?

Niharika Aitam
Updated on 09-Aug-2023 10:19:58

186 Views

Pygal is abbreviated as Python Data Visualization Library, which is designed to create the interactive charts and graphs. This is library is built with the advanced features than the SVG(Scalar Vector Graphics) format, to work with the high quality graphics that can be easily embedded into the web pages and applications. Pygal is abbreviated as Python Data Visualization Library, which is designed to create the interactive charts and graphs. This is library is built with the advanced features than the SVG(Scalar Vector Graphics) format, to work with the high quality graphics that can be easily embedded into the web pages ... Read More

Ways to Concatenate Boolean to String in Python

Aayush Shukla
Updated on 07-Aug-2023 21:41:02

226 Views

One can refer this article to learn about different methods to concatenate Boolean to string. All the different methods can be used in different cases. Different Methods to Concatenate Boolean to String String Function Let's take an example to understand it in a proper manner: - Example # Case 1 value_of_boolean = True # The value of Boolean is given as input to the function final_string = "The value of the boolean will be displayed as: " + str(value_of_boolean) # The Boolean is converted into string with the help of str function print(final_string) # ... Read More

Ways to check if a String in Python Contains all the same Characters

Aayush Shukla
Updated on 07-Aug-2023 21:38:26

785 Views

Python is a very commonly used programming language used for different purpose such as web development, data science, machine learning and to perform many different processes with automation. In this article we will learn about different ways to check if a string in python contains all the same characters. Different Methods to Check if a String in Python Contains All the Same Characters Set Function Set will help us to check the similarities in between the strings given as input in the program. This is a very simple method and the output will be displayed as ... Read More

Python - Vowel Indices in String

Aayush Shukla
Updated on 07-Aug-2023 21:34:30

385 Views

Python is a widely used programming language for different purposes such as web development, data science machine learning and to perform many different processes with automation. In this article, we'll explore how to use several Python features to extract vowel indices from a given text. Different Methods to Find Vowel Indices in a String For Loop In this method by simply checking each element in the string, we can determine if it is a vowel and record its index. We can understand it in a better way through the following syntax and example: - Example def vowel_indices_in_a_string(whole_string): ... Read More

Compute the outer product of two given vectors using NumPy in Python

Niharika Aitam
Updated on 07-Aug-2023 19:35:47

322 Views

The Outer product of two vectors is the matrix obtained by multiplying each element of the vector A with each element in the vector B. The outer product of the vectors a and b is given as a ⊗ b. The following is the mathematical formula for calculating the outer product.a ⊗ b = [a[0] * b, a[1] * b, ..., a[m-1] * b] Where, a, b are the vectors. denotes the element-wise multiplication of two vectors. The output of the outer product is a matrix in which i and j are the elements of the ... Read More

Compute the inner product of vectors for-D arrays using NumPy in Python

Niharika Aitam
Updated on 07-Aug-2023 17:44:42

237 Views

Inner product is one of the most important operations in the linear algebra mathematical operations, which takes two vectors as input and gives the scalar value as the output. It is also known as the Dot product or the scalar product. The inner product of the two vectors is given as follows. a . b = ||a|| ||b|| cos(Ø) Where, ||a|| and ||b|| are the magnitudes of the vectors a and b respectively Ø is the angle between the vectors a and b a . b is the dot product of a and b Calculating Inner ... Read More

Compute the histogram of a set of data using NumPy in Python

Niharika Aitam
Updated on 07-Aug-2023 17:39:36

236 Views

A Histogram is the graphical representation of the dataset distribution. It represents the data in the form of series of bars, where the range of data values represented by each bar and height of the bar represents the frequency of the data values defined within the range. These are mainly used to represent the distribution of the numerical data like grades in a class, distribution of the population or distribution of the incomes of the employees etc. In histogram, x-axis represents the range of data values, divided into intervals and the y-axis represents the frequency of the range of data ... Read More

Advertisements