- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 10804 Articles for Python
3K+ Views
If a function calls itself, it is called a recursive function. In order to prevent it from falling in infinite loop, recursive call is place in a conditional statement.Following program accepts a number as input from user and sends it as argument to rsum() function. It recursively calls itself by decrementing the argument each time till it reaches 1.def rsum(n): if n
9K+ Views
In this article, we will show you how to represent an infinite number in python. Infinity is an undefined number that can be either positive or negative. A number is used to represent infinity; the sum of two numeric values may be a numeric but distinct pattern; it may have a negative or positive value. All arithmetic operations on an infinite value, whether sum, subtraction, multiplication or any other operation, always result in an infinite number. In the field of computer science, infinity is commonly used to evaluate and optimize algorithms that do calculations on a huge scale. Infinity in ... Read More
1K+ Views
In this article, we will show you how to find the smallest number greater than x in Python. Introduction to Ceil Function in Python Ceil is a function in Python's math module, which is included in the Python Standard Library. In mathematics, it is the same as the Least Integer Function or the Ceil Function. If you are given a real integer x, ceil(x) is represented in mathematical notation as ⌈x⌉, where the upper direction of the brackets corresponds to ceiling operation (as the ceiling lies above your head). In contrast, the floor(x) (which returns the greatest integer ≤x) is ... Read More
2K+ Views
In this article, we will show you how to find the largest integer less than x in python. The Greatest Integer Function [X] denotes an integral part of the real number x that is the closest and smallest integer to x. It's also called the X-floor. [x]=the largest integer less than or equal to x. Generally If n
688 Views
Principle used in following solution to this problem is to divide given number with all from 3 its square root, a number's square root is largest possible factor beyond which it is not necessary to check if it is divisible by any other number to decide that it is prime number.The function returns false for all numbers divisible by 2 and less than 2. For others return value of all) function will be false if it is divisible by any number upto its square root and true if it is not divisible by any numberExampledef is_prime(a): if a ... Read More
3K+ Views
Multiplication of two matrices is possible only when number of columns in first matrix equals number of rows in second matrix.Multiplication can be done using nested loops. Following program has two matrices x and y each with 3 rows and 3 columns. The resultant z matrix will also have 3X3 structure. Element of each row of first matrix is multiplied by corresponding element in column of second matrix.ExampleX = [[1, 2, 3], [4, 5, 6], [7, 8, 9]] Y = [[10, 11, 12], [13, 14, 15], ... Read More
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
2K+ 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
115 Views
The uniform() function is defined in the random module of the standard Python library. It returns a random floating-point number between a given range of numbers>>> import random >>> random.uniform(10,100) 20.118467024396452 >>> random.uniform(10,100) 23.739576765885502
1K+ Views
The random module in the Python standard library provides a shuffle() function that returns a sequence with its elements randomly placed.>>> import random >>> l1=['aa',22,'ff',15,90,5.55] >>> random.shuffle(l1) >>> l1 [22, 15, 90, 5.55, 'ff', 'aa'] >>> random.shuffle(l1) >>> l1 ['aa', 'ff', 90, 22, 5.55, 15]
To Continue Learning Please Login
Login with Google