Added examples for complex numbers to numeric-types article (#28443)
* Added examples for complex numbers to numeric-types article Introduce 3 examples of what a complex number would look like in Python. * fix: moved links to bottom
This commit is contained in:
committed by
Randell Dawson
parent
0a69401e59
commit
f9482c3df9
@ -12,7 +12,7 @@ print(100)
|
||||
print(8435367)
|
||||
```
|
||||
* floating point numbers (`float`)
|
||||
* <a href='https://docs.python.org/3/library/functions.html#float' target='_blank' rel='nofollow'>constructor</a>
|
||||
|
||||
#### Examples:
|
||||
|
||||
```py
|
||||
@ -21,11 +21,21 @@ print(46.84)
|
||||
print(84357.435)
|
||||
```
|
||||
* complex numbers
|
||||
* <a href='https://docs.python.org/3/library/functions.html#complex' target='_blank' rel='nofollow'>constructor</a>
|
||||
|
||||
#### Examples:
|
||||
|
||||
```python
|
||||
print(3 + 4j)
|
||||
print(5 + 6j)
|
||||
print(2j + 1)
|
||||
```
|
||||
The standard library adds numeric types for
|
||||
|
||||
* <a href='https://docs.python.org/3/library/fractions.html#module-fractions' target='_blank' rel='nofollow'>fractions</a>
|
||||
* <a href='https://docs.python.org/3/library/decimal.html#module-decimal' target='_blank' rel='nofollow'>decimals</a>
|
||||
|
||||
Numeric objects are created from literals or as the result of functions and operators. The syntax for numeric literals is well <a href='https://docs.python.org/3/reference/lexical_analysis.html#numeric-literals' target='_blank' rel='nofollow'>documented</a>.
|
||||
|
||||
### Other Resources
|
||||
* <a href='https://docs.python.org/3/library/functions.html#float' target='_blank' rel='nofollow'>floating point</a>
|
||||
* <a href='https://docs.python.org/3/library/functions.html#complex' target='_blank' rel='nofollow'>complex</a>
|
||||
|
Reference in New Issue
Block a user