Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting error in round method in python (AttributeError: module 'math' has no attribute 'round') [closed]

Tags:

python

Here is my program and i am getting "(AttributeError: module 'math' has no attribute 'round')" error message

import math
def profit(info):
  cost = info['cost_price']
  sell =info['sell_price']
  num = info['inventory']

  return math.round((sell-cost)*num)
like image 840
Hell Kitchen Avatar asked Apr 09 '26 11:04

Hell Kitchen


1 Answers

Unlike ceil, floor, and trunc, round can be found in the standard library as a built-in function.

So you don't need import "math"

def profit(info):
  cost = info['cost_price']
  sell =info['sell_price']
  num = info['inventory']

 return round((sell-cost)*num)
like image 92
tapu74 Avatar answered Apr 10 '26 23:04

tapu74



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!