pynumeral

pynumeral library formmatting numbers for python

View the Project on GitHub Jahongir2007/pynumeral

db2a7348b09e424b92aa94cb33c38fd9

PyNumeral v1.1.7

PyNumeral python library for formatting and manipulating numbers

Create a simple program in pynumeral

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
  
)

Docs

Run this library

  1. Install .zip file in github
  2. Copy file: pynumeral-1.0.3/bin/pynumeral.py
  3. Create new folder and paste pynumeral.py
  4. Create new (for example test.py) .py file in this folder (the folder must contain a pynumeral file)
  5. Write the code to your newly opened .py file and run it, following the PyNumeral syntax

Importing PyNumeral

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

Create

import pynumeral
num = pynumeral
num.numeral(12)
# 12

format() function

you 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>"

)

Numbers

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

Units of length

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

Bytes

Number Type Value
1048577 "0b" 0.0009765634313225746 GB
1024 "0b" 1.0 KB
234000 "0b" 0.2231597900390625 MB
104857756 "0b" 9.536757352179848e-05 TB

Currency

Number Type Value
100 "$0.0" $ 100.0
100 "$0.0" $ 100.0
100 "$0k" $ 100 k
100 "$0m" $ 100 m

Percentages

Number Type Value
1 "0%" 100 %
0.25 "0%" 25 %
-0.25 "0%" -25 %

Time

Number Type Value
49 "00:00:00" 00:49
120 "00:00:00" 2:00
3601 "00:00:00" 1:1:00

Unformatting

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

Number types

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

Manipulate

In PyNumeral, manipulation is generated mainly in variables.

a = 12 # variable for manipulate
num.add(
  num = a, # get value
  set = 1
  # value: 13
)

Actions on numbers

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
)

Calculate the given example

Imagine you are given an example PyNumeral will help you work on it quickly.

num.calc((24-12)/2)
# value: 6

Difference

Find the difference between any two numbers in pynumeral.

num.dif(
  num = 900,
  set = 100
  # value: difference 800
)

Clone

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
  '''
)

Number list

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
  '''
)

Value

The value() function stores the value

num.val(100)

Encryption of zeros

In PyNumeral, the encryption of zeros is done using the zeroform() function.

num.zeroform(
  code = "Z/N",
  num = "0.0"
  '''
  Output:
  number: Z/N
  '''
)

How to create language

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
    '''
)

Opposite numbers

To find the opposite of the desired number

num.opposite(12)
# -12
num.opposite(-45)
# 45

The truth of numbers

To determine this, you need to use the real() function.

num.real(
  self = "<",
  numf = 12,
  nums = 11
  # value: False
)

cordinate() function

Determine between which numbers the desired number is located

num.cordinate(12)
# value: 11 12 13