- 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
What are various inbuilt methods used to access constants database in scipy.constants() module?
It is difficult to remember the values, units, and precisions of all physical constants. That’s the reason scipy.constants() have four methods with the help of which we can access physical constants. Let’s understand these methods along with examples −
scipy.constants.value(key)− This method will give us the value in physical constants indexed by key.
Parameters
key- It represents the key in dictionary physical_constants. Its value is a Python string or Unicode.
Returns
value- It represents the value in physical_constants corresponding to the key parameter. Its value is of float type.
Example
from scipy import constants constants.value(u'proton mass')
Output
1.67262192369e-27
scipy.constants.unit(key)− This method will give us the unit in physical constants indexed by key.
Parameters
key- It represents the key in dictionary physical_constants. Its value is a Python string or Unicode.
Returns
unit- It represents the unit in physical_constants corresponding to the key parameter. Its value is a Python string.
Example
from scipy import constants constants.value(u'elementary charge')
Output
‘C’
scipy.constants.precision(key)− This method will give us the relative precision in physical constants indexed by key.
Parameters
key- It represents the key in dictionary physical_constants. Its value is a Python string or Unicode.
Returns
prec- It represents the relative precision in physical_constants corresponding to the key parameter. Its value is of float type.
Example
from scipy import constants constants.value(u'proton mass')
Output
3.0491050773439597e-10
scipy.constants.find(sub=None, disp=False)− This method will give us the list of physical_constants keys having a given string.
Parameters
sub- It represents substring to search keys for. By default, it will return all the keys.
disp- It is of Boolean type. If True, it will print the keys and return none. If false, it will only return the list of keys without printing anything.
Returns
keys- It represents the list of keys. It will return the list of keys if disp is FALSE. It will not return anything if disp is TRUE.
Example
#Importing the modules from scipy.constants import find, physical_constants #Finding constant with ‘Bohr’ in the key find('Bohr')
Output
['Bohr magneton', 'Bohr magneton in Hz/T', 'Bohr magneton in K/T', 'Bohr magneton in eV/T', 'Bohr magneton in inverse meter per tesla', 'Bohr radius', 'deuteron mag. mom. to Bohr magneton ratio', 'electron mag. mom. to Bohr magneton ratio', 'helion mag. mom. to Bohr magneton ratio', 'muon mag. mom. to Bohr magneton ratio', 'neutron mag. mom. to Bohr magneton ratio', 'proton mag. mom. to Bohr magneton ratio', 'shielded helion mag. mom. to Bohr magneton ratio', 'shielded proton mag. mom. to Bohr magneton ratio', 'triton mag. mom. to Bohr magneton ratio']
Example
#Getting the constant called ‘Bohr radius’ physical_constants['Bohr radius']
Output
(5.29177210903e-11, 'm', 8e-21)
- Related Articles
- What are the various extraction methods in data warehouses?
- What are the various methods available under Select class in Selenium?
- What are the methods used to provide effects in jQuery?
- What are the various methods related to data sharing through data propagation?
- What are constants in C++?
- What are the various literary devices used in English Literature?
- What is the procedure to access database users in DBMS?
- What are native methods in Java and where are they used?
- What are Enumerated Constants in C++?
- Access to the Password Database in Python
- Access to the Group Database in Python
- How are access links and displays used to access non-local names?
- What are the various fuels which are used to generate electricity in a thermal power plant?
- What are C++ Integer Constants?
- What are C++ Character Constants?
