Skip to main content
deleted 71 characters in body
Source Link
Reinderien
  • 71.1k
  • 5
  • 76
  • 256
  • Keep fractional variables (0-1) instead of percentile variables (0-100) as the former are more "math-native" and can use in-built percent formatting
  • Try to make your prompts follow a more consistent lexical pattern; the example I've shown has a single "Enter" prompt at the top followed by a series of object phrases
  • Use built-in currency formatting. I have no way of knowing if my guessed hi_IN is accurate for you, but it does offeroffers a rendered rupee symbol. Prefer this symbol over hard-coding and spelling out "rupees". One of the several advantages of locale support is that it correctly renders the (interesting!) lakh digit group separation.
  • Use Python 3.
  • Keep fractional variables (0-1) instead of percentile variables (0-100) as the former are more "math-native" and can use in-built percent formatting
  • Try to make your prompts follow a more consistent lexical pattern; the example I've shown has a single "Enter" prompt at the top followed by a series of object phrases
  • Use built-in currency formatting. I have no way of knowing if my guessed hi_IN is accurate for you, but it does offer a rendered rupee symbol. Prefer this symbol over hard-coding and spelling out "rupees". One of the several advantages of locale support is that it correctly renders the (interesting!) lakh digit group separation.
  • Use Python 3.
  • Keep fractional variables (0-1) instead of percentile variables (0-100) as the former are more "math-native" and can use in-built percent formatting
  • Try to make your prompts follow a more consistent lexical pattern; the example I've shown has a single "Enter" prompt at the top followed by a series of object phrases
  • Use built-in currency formatting. hi_IN offers a rendered rupee symbol. Prefer this symbol over hard-coding and spelling out "rupees". One of the several advantages of locale support is that it correctly renders the (interesting!) lakh digit group separation.
  • Use Python 3.
edited body
Source Link
Reinderien
  • 71.1k
  • 5
  • 76
  • 256
from locale import setlocale, LC_ALL, currency, localeconv
setlocale(LC_ALL, 'hi_IN.UTF-8')
symbol = localeconv()['currency_symbol']

print('Enter...')
salary = float(input(f'your monthly salary: {symbol}'))
savings = float(input('your monthly savings: %'))/100
emi = float(input('your equated monthly installment (EMI): %'))/100
budget = float(input(f'the total amount you want to save: {symbol}'))
duration = float(input('how many months you have: '))


def fmoney(money: float) -> str:
    return currency(money, grouping=True)


tfinal = salarysalary*(1 - savings*salarysavings)       # total salary left after savings are subtracted
final_left = tfinal - emi*salary    # total salary left after savings and emi removed
percent_left = 1 - savings - emi    # total percentage of salary left after savings and emi removed in percent
final_budget = final_left*duration  # monthly saving multiplied by duration for final amount left
sav_per_month = budget/duration     # final budget savings you are planning per month

if sav_per_month < final_left:
    possible = 'possible'
    can = 'can'
else:
    possible = 'not possible'
    can = 'cannot'

print(
    f'It is {possible}.'
    f'\nEarning {fmoney(final_left)} with {percent_left:.1%} left,'
    f' you {can} save {fmoney(sav_per_month)} per month.'
    f'\nYou will be left with {fmoney(final_budget)}.'
)
from locale import setlocale, LC_ALL, currency, localeconv
setlocale(LC_ALL, 'hi_IN.UTF-8')
symbol = localeconv()['currency_symbol']

print('Enter...')
salary = float(input(f'your monthly salary: {symbol}'))
savings = float(input('your monthly savings: %'))/100
emi = float(input('your equated monthly installment (EMI): %'))/100
budget = float(input(f'the total amount you want to save: {symbol}'))
duration = float(input('how many months you have: '))


def fmoney(money: float) -> str:
    return currency(money, grouping=True)


tfinal = salary - savings*salary    # total salary left after savings are subtracted
final_left = tfinal - emi*salary    # total salary left after savings and emi removed
percent_left = 1 - savings - emi    # total percentage of salary left after savings and emi removed in percent
final_budget = final_left*duration  # monthly saving multiplied by duration for final amount left
sav_per_month = budget/duration     # final budget savings you are planning per month

if sav_per_month < final_left:
    possible = 'possible'
    can = 'can'
else:
    possible = 'not possible'
    can = 'cannot'

print(
    f'It is {possible}.'
    f'\nEarning {fmoney(final_left)} with {percent_left:.1%} left,'
    f' you {can} save {fmoney(sav_per_month)} per month.'
    f'\nYou will be left with {fmoney(final_budget)}.'
)
from locale import setlocale, LC_ALL, currency, localeconv
setlocale(LC_ALL, 'hi_IN.UTF-8')
symbol = localeconv()['currency_symbol']

print('Enter...')
salary = float(input(f'your monthly salary: {symbol}'))
savings = float(input('your monthly savings: %'))/100
emi = float(input('your equated monthly installment (EMI): %'))/100
budget = float(input(f'the total amount you want to save: {symbol}'))
duration = float(input('how many months you have: '))


def fmoney(money: float) -> str:
    return currency(money, grouping=True)


tfinal = salary*(1 - savings)       # total salary left after savings are subtracted
final_left = tfinal - emi*salary    # total salary left after savings and emi removed
percent_left = 1 - savings - emi    # total percentage of salary left after savings and emi removed in percent
final_budget = final_left*duration  # monthly saving multiplied by duration for final amount left
sav_per_month = budget/duration     # final budget savings you are planning per month

if sav_per_month < final_left:
    possible = 'possible'
    can = 'can'
else:
    possible = 'not possible'
    can = 'cannot'

print(
    f'It is {possible}.'
    f'\nEarning {fmoney(final_left)} with {percent_left:.1%} left,'
    f' you {can} save {fmoney(sav_per_month)} per month.'
    f'\nYou will be left with {fmoney(final_budget)}.'
)
deleted 102 characters in body
Source Link
Reinderien
  • 71.1k
  • 5
  • 76
  • 256
from locale import setlocale, LC_ALL, currency, localeconv
setlocale(LC_ALL, 'hi_IN.UTF-8')
symbol = localeconv()['currency_symbol']

print('Enter...')
salary = float(input(f'your monthly salary: {symbol}'))
savings = float(input('your monthly savings: %'))/100
emi = float(input('your equated monthly installment (EMI): %'))/100
budget = float(input(f'the total amount you want to save: {symbol}'))
duration = float(input('how many months you have: '))


def fmoney(money: float) -> str:
    return currency(money, grouping=True)


tfinal = salary - savings*salary    # total salary left after savings are subtracted
final_left = tfinal - emi*salary    # total salary left after savings and emi removed
percent_left = 1 - savings - emi    # total percentage of salary left after savings and emi removed in percent
final_budget = final_left*duration  # monthly saving multiplied by duration for final amount left
sav_per_month = budget/duration     # final budget savings you are planning per month

if sav_per_month < final_left:
    print(
        'It is possible.'
    = 'possible'
   f'\nEarning {fmoney(final_left)}can with= {percent_left'can'
else:.1%} left,'
     possible = 'not f'possible'
 you can save {fmoney(sav_per_month)}can per= month.')'cannot'
else:
    print(
        'Itf'It is not {possible}.'
        f'\nEarning {fmoney(final_left)} with {percent_left:.1%} left,'
        f' you cannot{can} save {fmoney(sav_per_month)} per month.'
    )

print(f'Youf'\nYou will be left with {fmoney(final_budget)}.' 
)
from locale import setlocale, LC_ALL, currency, localeconv
setlocale(LC_ALL, 'hi_IN.UTF-8')
symbol = localeconv()['currency_symbol']

print('Enter...')
salary = float(input(f'your monthly salary: {symbol}'))
savings = float(input('your monthly savings: %'))/100
emi = float(input('your equated monthly installment (EMI): %'))/100
budget = float(input(f'the total amount you want to save: {symbol}'))
duration = float(input('how many months you have: '))


def fmoney(money: float) -> str:
    return currency(money, grouping=True)


tfinal = salary - savings*salary    # total salary left after savings are subtracted
final_left = tfinal - emi*salary    # total salary left after savings and emi removed
percent_left = 1 - savings - emi    # total percentage of salary left after savings and emi removed in percent
final_budget = final_left*duration  # monthly saving multiplied by duration for final amount left
sav_per_month = budget/duration     # final budget savings you are planning per month

if sav_per_month < final_left:
    print(
        'It is possible.'
        f'\nEarning {fmoney(final_left)} with {percent_left:.1%} left,'
        f' you can save {fmoney(sav_per_month)} per month.')
else:
    print(
        'It is not possible.'
        f'\nEarning {fmoney(final_left)} with {percent_left:.1%} left,'
        f' you cannot save {fmoney(sav_per_month)} per month.'
    )

print(f'You will be left with {fmoney(final_budget)}.')
from locale import setlocale, LC_ALL, currency, localeconv
setlocale(LC_ALL, 'hi_IN.UTF-8')
symbol = localeconv()['currency_symbol']

print('Enter...')
salary = float(input(f'your monthly salary: {symbol}'))
savings = float(input('your monthly savings: %'))/100
emi = float(input('your equated monthly installment (EMI): %'))/100
budget = float(input(f'the total amount you want to save: {symbol}'))
duration = float(input('how many months you have: '))


def fmoney(money: float) -> str:
    return currency(money, grouping=True)


tfinal = salary - savings*salary    # total salary left after savings are subtracted
final_left = tfinal - emi*salary    # total salary left after savings and emi removed
percent_left = 1 - savings - emi    # total percentage of salary left after savings and emi removed in percent
final_budget = final_left*duration  # monthly saving multiplied by duration for final amount left
sav_per_month = budget/duration     # final budget savings you are planning per month

if sav_per_month < final_left:
    possible = 'possible'
    can = 'can'
else:
    possible = 'not possible'
    can = 'cannot'

print(
    f'It is {possible}.'
    f'\nEarning {fmoney(final_left)} with {percent_left:.1%} left,'
    f' you {can} save {fmoney(sav_per_month)} per month.'
    f'\nYou will be left with {fmoney(final_budget)}.' 
)
added 242 characters in body
Source Link
Reinderien
  • 71.1k
  • 5
  • 76
  • 256
Loading
Source Link
Reinderien
  • 71.1k
  • 5
  • 76
  • 256
Loading