- Syntax
- Example 1: Positive Exponent
- Example 2: Negative Exponent
- Example 3: Using Uppercase E
- Example 4: Checking the Data Type
- Example 5: Scientific Notation in Calculations
- Example 6: Very Small Scientific Value
- Example 7: Converting Scientific Notation to Integer
- Example 8: Scientific Notation in Expressions
- Example 9: Comparing Scientific Notation
- Example 10: Scientific Notation from User Input
- Common Mistakes
- Best Practices
- Key Points to Remember
Scientific notation is a compact way of writing very large or very small numbers.
Instead of writing many zeros, scientific notation expresses a number using a coefficient multiplied by a power of 10.
In Python, scientific notation is written using the letter e or E.
The general form is:
coefficienteexponent
For example:
3.5e4means3.5 ร 10โด2.1e-3means2.1 ร 10โปยณ
Scientific notation is commonly used in science, engineering, electronics, and mathematics where extremely large or very small values are frequently encountered.
Syntax #
variable_name = coefficienteexponent
Components #
| Component | Description |
|---|---|
variable_name |
Name of the variable. |
coefficient |
A decimal number. |
e or E |
Indicates “multiply by 10 raised to the power”. |
exponent |
Integer exponent that determines how many places the decimal point moves. |
Example 1: Positive Exponent #
main.py
number = 3.5e4
print(number)
print(type(number))
Output #
35000.0
<class 'float'>
Explanation #
3.5e4means3.5 ร 10โด.- The decimal point moves four places to the right.
- Scientific notation always produces a floating-point value.
Example 2: Negative Exponent #
main.py
number = 2.5e-3
print(number)
Output #
0.0025
Explanation #
2.5e-3means2.5 ร 10โปยณ.- The decimal point moves three places to the left.
- This notation is useful for representing very small numbers.
Example 3: Using Uppercase E #
main.py
number = 7.2E5
print(number)
Output #
720000.0
Explanation #
- Python accepts both lowercase
eand uppercaseE. - Both represent scientific notation.
- The stored value is identical.
Example 4: Checking the Data Type #
main.py
number = 9e2
print(number)
print(type(number))
Output #
900.0
<class 'float'>
Explanation #
- Even though the result is a whole number (
900), Python stores it as a floating-point number because scientific notation always creates afloat.
Example 5: Scientific Notation in Calculations #
main.py
distance = 1.5e6
time = 2
speed = distance / time
print(speed)
Output #
750000.0
Explanation #
- Scientific notation can be used just like any other numeric value.
- Python performs arithmetic operations normally.
- The result is a floating-point number.
Example 6: Very Small Scientific Value #
main.py
charge = 1.6e-19
print(charge)
Output #
1.6e-19
Explanation #
- Scientific notation is especially useful for representing extremely small values.
- Python automatically displays the value using exponential notation.
Example 7: Converting Scientific Notation to Integer #
main.py
number = int(5e3)
print(number)
print(type(number))
Output #
5000
<class 'int'>
Explanation #
5e3is initially stored as a floating-point value.- The
int()function converts it into an integer. - After conversion, the data type becomes
int.
Example 8: Scientific Notation in Expressions #
main.py
result = 2e3 + 5e2
print(result)
Output #
2500.0
Explanation #
2e3represents2000.0.5e2represents500.0.- Python adds the two floating-point values.
Example 9: Comparing Scientific Notation #
main.py
print(1e3 == 1000)
Output #
True
Explanation #
1e3represents1000.0.- Python compares
1000.0with1000. - Since the numeric values are equal, the result is
True.
Example 10: Scientific Notation from User Input #
main.py
number = float(input("Enter a number in scientific notation: "))
print(number)
Sample Input #
6.02e23
Output #
6.02e+23
Explanation #
- The user enters a number in scientific notation.
float()converts the input string into a floating-point value.- Python prints the equivalent floating-point number.
Common Mistakes #
1. Forgetting the Exponent #
Incorrect
number = 2.5e
Output #
SyntaxError: invalid decimal literal
Reason
Scientific notation requires an exponent after e or E.
Correct
number = 2.5e3
2. Assuming Scientific Notation Produces an Integer #
Incorrect
number = 5e2
print(type(number))
Incorrect Expectation #
<class 'int'>
Actual Output #
<class 'float'>
Reason
Scientific notation always creates a floating-point value.
3. Using Multiple Decimal Points #
Incorrect
number = 2.5.3e4
Output #
SyntaxError: invalid syntax
Reason
A numeric literal can contain only one decimal point.
4. Writing Spaces Inside Scientific Notation #
Incorrect
number = 3.5 e4
Output #
SyntaxError: invalid syntax
Reason
There must be no spaces between the coefficient, e, and the exponent.
Best Practices #
- Use scientific notation for extremely large or very small numbers.
- Use lowercase
econsistently for better readability. - Remember that scientific notation values are stored as floating-point numbers.
- Use
int()if an integer value is required after computation. - Use meaningful variable names when storing scientific values.
Key Points to Remember #
- Scientific notation provides a compact way to write very large or very small numbers.
- Python uses
eorEto represent powers of 10. - Positive exponents move the decimal point to the right.
- Negative exponents move the decimal point to the left.
- Scientific notation always produces a value of type
float. - Scientific notation values can participate in arithmetic operations like any other numeric values.
- Both lowercase
eand uppercaseEare valid in Python.