- Trending Categories
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 10784 Articles for Python
![Abhinaya](https://www.tutorialspoint.com/assets/profiles/13548/profile/60_54851-1512705920.jpg)
2K+ Views
You can plot complex numbers on a polar plot. If you have an array of complex numbers, you can plot it using:import matplotlib.pyplot as plt import numpy as np cnums = np.arange(5) + 1j * np.arange(6,11) X = [x.real for x in cnums] Y = [x.imag for x in cnums] plt.scatter(X,Y, color='red') plt.show()This will plot a graph of the numbers in a complex plane.
![Chandu yadav](https://www.tutorialspoint.com/assets/profiles/22330/profile/60_142811-1519038104.jpg)
444 Views
You can find the Square root of complex numbers in Python using the cmath library. The cmath library in python is a library for dealing with complex numbers. You can use it as follows to find the square root −Examplefrom cmath import sqrta = 0.2 + 0.5j print(sqrt(a))OutputThis will give the output (0.6076662244659689+0.4114100635092987j)
![Govinda Sai](https://www.tutorialspoint.com/assets/profiles/13542/profile/60_86497-1512650655.jpg)
341 Views
There is no straightforward way of getting signal names from numbers in python. You can use the signal module to get all its attributes. Then use this dict to filter the variables that start with SIG and finally store them in a dice. For example,Exampleimport signal sig_items = reversed(sorted(signal.__dict__.items())) final = dict((k, v) for v, k in sig_items if v.startswith('SIG') and not v.startswith('SIG_')) print(final)OutputThis will give the output:{: 'SIGTERM', : 'SIGSEGV', : 'SIGINT', : 'SIGILL', : 'SIGFPE', : 'SIGBREAK', : 'SIGABRT'}
![Ankith Reddy](https://www.tutorialspoint.com/assets/profiles/22328/profile/60_142162-1519038074.jpg)
284 Views
To print Narcissistic Numbers, let's first look at the definition of it. It is a number that is the sum of its own digits each raised to the power of the number of digits. For example, 1, 153, 370 are all Narcissistic numbers. You can print these numbers by running the following codedef print_narcissistic_nums(start, end): for i in range(start, end + 1): # Get the digits from the number in a list: digits = list(map(int, str(i))) total = 0 length = len(digits) for d in digits: total += d ** length ... Read More
![George John](https://www.tutorialspoint.com/assets/profiles/13511/profile/60_58410-1512537824.png)
6K+ Views
Clamp function limits a value to a given range. Python doesn't have such a function in built. You can create this function likedef clamp(num, min_value, max_value): return max(min(num, max_value), min_value) print(clamp(5, 1, 20)) print(clamp(1, 10, 20)) print(clamp(20, 1, 10))This will give the output5 10 10
![Sravani S](https://www.tutorialspoint.com/assets/profiles/13538/profile/60_67753-1512711355.jpg)
151 Views
To print Strong Numbers, let's first look at the definition of it. It is a number that is the sum of factorials of its own digits. For example, 145 is a Strong number. First, create a function to calculate factorial:def fact(num): def factorial(n): num = 1 while n >= 1: num = num * n n = n - 1 return numYou can print these numbers by running the following code:def factorial(n): num = 1 while n >= 1: num = num * n ... Read More
![Arjun Thakur](https://www.tutorialspoint.com/assets/profiles/13574/profile/60_74441-1560315595.jpg)
1K+ Views
The constructor for the string class in python, ie, str can be used to convert a number to a string in python. For example, i = 10050 str_i = str(i) print(type(str_i))This will give the output:But if you want something that converts integers to words like 99 to ninety-nine, you have to use an external package or build one yourself. The pynum2word module is pretty good at this task. You can install it using$ pip install pynum2wordThen use it in the following way>>> import num2word >>> num2word.to_card(16) 'sixteen' >>> num2word.to_card(23) 'twenty-three' >>> num2word.to_card(1223) 'one thousand, two hundred and twenty-three'Read More
![Ramu Prasad](https://www.tutorialspoint.com/assets/profiles/13539/profile/60_87996-1512650215.jpg)
2K+ Views
You can get the XOR of any type of numbers using the ^ operator. Specifically for hex numbers, you can use:a = 0x12ef b = 0xabcd print(hex(a ^ b))This will give the output:0xb922The 0x at the beginning of the numbers implies that the number is in hex representation. You can use the ^ operator for other integer representations as well.
![George John](https://www.tutorialspoint.com/assets/profiles/13511/profile/60_58410-1512537824.png)
918 Views
You can divide large numbers in python as you would normally do. But this has a lot of precision issues as such operations cannot be guaranteed to be precise as it might slow down the language. You would be better off using a numeric computation library like bigfloat to perform such operations.You can read more about floating point issues that you might face with precision on https://docs.python.org/3/tutorial/floatingpoint.html
![Ankitha Reddy](https://www.tutorialspoint.com/assets/profiles/13550/profile/60_73963-1512711511.jpg)
2K+ Views
You can multiply large numbers in python directly without worrying about speed. Python supports a "bignum" integer type which can work with arbitrarily large numbers. In Python 2.5+, this type is called long and is separate from the int type, but the interpreter will automatically use whichever is more appropriate. As long as you have version 2.5 or better, just perform standard math operations and any number which exceeds the boundaries of 32-bit math will be automatically (and transparently) converted to a bignum. For example, a = 15421681351 b = 6184685413848 print(a * b) This will give the output − 95378247708541418748648