pynumeral library formmatting numbers for python
PyNumeral python library for formatting and manipulating numbers
Creating even-odd program with the PyNumeral library is explained below with code and comments:
import pynumeral # importing pynumeral
'''
we store the functions in the pynumeral document to the num variable.
'''
num = pynumeral # this in num variable
number_in = int(input("Enter number: ")) # Input number
num.format( # use format function
num = number_in, # declare a number for formatting
form = "0%2" # format type
)
In python file
import pynumeral # importing pynumeral
'''
we store the functions in the pynumeral document to the num variable.
'''
num = pynumeral # this in num variable
import pynumeral
num = pynumeral
num.numeral(12)
# 12
format()
functionyou can format any number from the format()
function to percentages, integers, rounded numbers, currencies, odd-evens, and more. Syntax:
num.format(
num = 10.5,
form = "<0.0>"
)
Number | Type | Value |
100 | "0.0" | 100.0 |
-100 | "|0|" | 100 |
100.3 | "0.!0" | 100 |
2 | "0,0t" | 2 ,000 |
3 | "0t" | 3 000 |
15 | "0,0m" | 15 ,000000 |
100 | "0m" | 100 000 000 |
100 | "+0" | +100 |
100.8 | "<0.0>" | 101 |
100.1 | "!0.0" | 0.09999999999999432 |
12.14 | "0.[0]" | 12.1 |
12.147 | "0.0[0]" | 12.14 |
12.1479 | "0.00[0]" | 12.147 |
12 | "0C" | 12 C |
24 | "0C[0F]" | 75.2 F |
51, 52 | "1", "2", "3", "on" | 51 st, 52 nd, 53 rd, 100 th |
1200 | "0a" | 1.2k |
100 | "(0.000)" | ( 100, 000) |
100 | "0.0" | 100.0 |
100 | "0%2" | even |
Number | Type | Value |
8 | "0_m" | 8 mm |
25 | "0_m" | 2.5 cm |
250 | "0_m" | 25 dm |
2500 | "0_m" | 25 m |
25000 | "0_m" | 25 km |
Number | Type | Value |
1048577 | "0b" | 0.0009765634313225746 GB |
1024 | "0b" | 1.0 KB |
234000 | "0b" | 0.2231597900390625 MB |
104857756 | "0b" | 9.536757352179848e-05 TB |
Number | Type | Value |
100 | "$0.0" | $ 100.0 |
100 | "$0.0" | $ 100.0 |
100 | "$0k" | $ 100 k |
100 | "$0m" | $ 100 m |
Number | Type | Value |
1 | "0%" | 100 % |
0.25 | "0%" | 25 % |
-0.25 | "0%" | -25 % |
Number | Type | Value |
49 | "00:00:00" | 00:49 |
120 | "00:00:00" | 2:00 |
3601 | "00:00:00" | 1:1:00 |
Got a formatted string? Use the unformat function to make it useful again.
num.unform(
num = 20,
type = "0%"
# value: 0.2
)
Value | Type | Number |
20.2 | "0.0" | 20 |
20 | "0.!0" | 20.0 |
35 | "|0|" | 35 |
20 | "0k" | 20000 |
15 | "0m" | 15000000 |
20 | "0%" | 0.2 |
numbers accepted in mathematics. Syntax:
num.number("pi")
# 3.141592653589793
Type | Value |
"pi" | 3.141592653589793 |
"inf" | inf |
"e" | 2.718281828459045 |
"nan" | nan |
"tau" | 6.283185307179586 |
In PyNumeral, manipulation is generated mainly in variables.
a = 12 # variable for manipulate
num.add(
num = a, # get value
set = 1
# value: 13
)
In the PyNumeral library, numbers can be added, subtracted, multiplied, and divided.
# add numbers
num.add(
num = 14,
set = 12
# value: 26
)
# subtract numbers
num.sub(
num = 14,
set = 12
# value: 2
)
# multiply numbers
num.mul(
num = 14,
set = 12
# value: 168
)
# division numbers
num.div(
num = 14,
set = 12
# value: 1.166666666666667
)
Imagine you are given an example PyNumeral will help you work on it quickly.
num.calc((24-12)/2)
# value: 6
Find the difference between any two numbers in pynumeral.
num.dif(
num = 900,
set = 100
# value: difference 800
)
A PyNumeral clone is a manipulation of this variable and consists of a clone name and contains a value.
a = 12
num.clone(
name = "myclone",
set = a
'''
Output:
Name clone: myclone
Value clone: 12
'''
)
Use this method to display a list of numbers from any number to any number.
num.numlist(
start = 1,
end = 6
'''
Output:
1
2
3
4
5
'''
)
The value()
function stores the value
num.val(100)
In PyNumeral, the encryption of zeros is done using the zeroform()
function.
num.zeroform(
code = "Z/N",
num = "0.0"
'''
Output:
number: Z/N
'''
)
Create your number formats:
num.makelang(
lang="uzb",
abb_k="ming",
abb_m="million",
abb_b="milliard",
abb_t="trillion",
curr="so'm",
num=1000
'''
Output:
1.0 ming
so'm 1000
'''
)
To find the opposite of the desired number
num.opposite(12)
# -12
num.opposite(-45)
# 45
To determine this, you need to use the real()
function.
num.real(
self = "<",
numf = 12,
nums = 11
# value: False
)
cordinate()
functionDetermine between which numbers the desired number is located
num.cordinate(12)
# value: 11 12 13