Vikram Chiluka

Vikram Chiluka

216 Articles Published

Articles by Vikram Chiluka

Page 18 of 22

How can I generate random integers between 0 and 9 using Python?

Vikram Chiluka
Vikram Chiluka
Updated on 28-Oct-2022 3K+ Views

In this article, we will show you how to generate random integers between 0 and 9 in Python. Below are the various methods to accomplish this task: Using randint() method Using randrange() method Using secrets module To generate random integers within certain ranges, Python supports a variety of functions. We will discuss Python's built-in random module for generating random numbers. The two primary functions provided by the random module to produce random integers are randint() and randrange(). In order to produce random values, a second module called secrets is also used. Using randint() method The random.randint() method is ...

Read More

How to Transpose a matrix in Single line in Python?

Vikram Chiluka
Vikram Chiluka
Updated on 27-Oct-2022 2K+ Views

In this article, we will show you how to transpose a matrix in a single line in python. Below are the various ways to accomplish this task − Using Nested List Comprehension Using NumPy Module Using zip() Function What is the transpose of the matrix? A matrix transpose is the interchanging of rows and columns. It is abbreviated to A'. The element in the ith row and jth column of A' will be moved to the jth row and ith column of A' Using Nested List Comprehension Algorithm (Steps) Following are the Algorithm/steps to be followed to ...

Read More

How to pick a random number not in a list in Python?

Vikram Chiluka
Vikram Chiluka
Updated on 27-Oct-2022 3K+ Views

In this article, we will show you how to pick a random number not in a list in python. Below are the various methods to accomplish this task − Using random.choice() function Using random.choice() function and List Comprehension Using random.choice() & set() functions Using random.randrange() function Using random.choice() function The random.choice() method returns a random element from the specified sequence. The sequence could be a string, a range, a list, a tuple, or anything else. Syntax random.choice(sequence) Parameters sequence − any sequence like list, tuple etc. Algorithm (Steps) Following are the Algorithm/steps to be followed to perform ...

Read More

How to Convert Decimal to Binary Using Recursion in Python?

Vikram Chiluka
Vikram Chiluka
Updated on 27-Oct-2022 3K+ Views

In this article, we will show you how to convert decimal to binary using recursion in python. A decimal number is the most familiar number system to the general public. It is base 10 which has only 10 symbols − 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9. Whereas Binary number is the most familiar number system to digital systems, networking, and computer professionals. It is base 2 which has only 2 symbols: 0 and 1, these digits can be represented by off and on respectively. When we convert a number from the decimal number system to ...

Read More

How to Check if a Number is Odd or Even using Python?

Vikram Chiluka
Vikram Chiluka
Updated on 27-Oct-2022 5K+ Views

In this article, we will show you how to check if a number is odd or even in python. Below are the methods to accomplish this task − Using modulo (%) operator Using Recursion Using the Binary AND (&) operator Using modulo (%) operator Python's modulo (%) operator (also called the remainder operator) is useful to determine if a number is odd or even. We obtain the remainder of the division of a number by 2. If it is 0, it is even otherwise it is odd Even Number − A number that can be divided by 2, ...

Read More

How to Convert Celsius To Fahrenheit using Python?

Vikram Chiluka
Vikram Chiluka
Updated on 25-Oct-2022 17K+ Views

In this article, we will show you how to convert Celsius To Fahrenheit using Python. Celsius Celsius is a temperature measurement unit that is also known as centigrade. It is an SIderived unit that is used by the majority of countries throughout the world. It is named after the Swedish astronomer Anders Celsius. Fahrenheit Fahrenheit is a temperature scale named after the Polish-born German physicist Daniel Gabriel Fahrenheit, and it uses degrees Fahrenheit as a temperature unit. To obtain Fahrenheit equivalent of celsius, multiply by 1.8 and add 32 - f=c*1.8+32 Or we can use another formula − ...

Read More

Write a Python code to sort an array in NumPy by the nth column?

Vikram Chiluka
Vikram Chiluka
Updated on 20-Oct-2022 3K+ Views

In this article, we will show you how to sort an array in NumPy by the nth column both in ascending and descending order in python. NumPy is a Python library designed to work efficiently with arrays in Python. It is fast, simple to learn, and efficient in storage. It also improves the way data is handled for the process. In NumPy, we may generate an n-dimensional array. To use NumPy, we simply import it into our program, and then we can easily use NumPy's functionality in our code. Method 1. Sorting a Numpy Array by the 1st column In ...

Read More

Why you should use NumPy arrays instead of nested Python lists?

Vikram Chiluka
Vikram Chiluka
Updated on 20-Oct-2022 3K+ Views

In this article, we will show you why to use NumPy arrays instead of nested Python lists, and the similarities and differences between them. Python NumPy Library NumPy is a Python library designed to work efficiently with arrays in Python. It is fast, simple to learn, and efficient in storage. It also improves the way data is handled for the process. In NumPy, we may generate an n-dimensional array. To use NumPy, we simply import it into our program, and then we can easily use NumPy's functionality in our code. Python Nested Lists A Python list is a mutable and ...

Read More

How to Create a Vector or Matrix in Python?

Vikram Chiluka
Vikram Chiluka
Updated on 20-Oct-2022 12K+ Views

In this article, we will show you how to create a vector or matrix in Python. NumPy is a Python library designed to work efficiently with arrays in Python. It is fast, simple to learn, and efficient in storage. In NumPy, we may generate an n-dimensional array. What are vectors? In python, vectors are built from components, which are ordinary numbers. A vector can be considered as a list of numbers, and vector algebra as operations done on the numbers in the list. In other words, a vector is the numpy 1-D array. We use the np.array() method ...

Read More

What is the preferred method to check for an empty array in NumPy?

Vikram Chiluka
Vikram Chiluka
Updated on 20-Oct-2022 23K+ Views

In this article, we will show you the preferred methods to check for an empty array in Numpy. NumPy is a Python library designed to work efficiently with arrays in Python. It is fast, simple to learn, and efficient in storage. It also improves the way data is handled for the process. In NumPy, we may generate an n-dimensional array. To use NumPy, we simply import it into our program, and then we can easily use NumPy's functionality in our code. NumPy is a popular Python package for scientific and statistical analysis. NumPy arrays are grids of values from ...

Read More
Showing 171–180 of 216 articles
« Prev 1 16 17 18 19 20 22 Next »
Advertisements