#!/usr/bin/env python3

# This script calculates the percentage (things like 124,5 x 15%).
# It takes in consideration floats entered with commas.
# Results will be displayed as strings in the form e.g. 124,5 x 15% = 18,675

from sys import argv
script, total, part = argv

## If float ends with .00 it will be converted to integer
def change_to_integer(n):
    if n - int(n) == 0.00:
        n = int(n)
    return n

## Commas replaced with dots → conversion to float
total = float(total.replace(",", "."))
part = float(part.replace(",", "."))

final_result = total * part / 100

## Conversions to integers if floats ends with .00 → conversion to strings
## → replacement of dots with commas
total = str(change_to_integer(total)).replace(".", ",")
part = str(change_to_integer(part)).replace(".", ",")
final_result = str(change_to_integer(final_result)).replace(".", ",")

print("\n{} x {}% = {}\n".format(total, part, final_result))
