Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9139647
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T09:24:53+00:00 2026-06-17T09:24:53+00:00

Today I have a question for you about rounding up numbers using conditions in

  • 0

Today I have a question for you about rounding up numbers using conditions in Python.

I am doing a sales website and my client wants to round up the prices depending of the result converting them from USD to Colombian Pesos. For example: 200 USD to COP results in 353990 COP, and it should be rounded to 359000.

He have implemented a function that is doing the trick in Excel:

=IF(F4>=10000000,(ROUNDUP(F4,-6)-100000),IF(F4>=1000000,(ROUNDUP(F4,-5)-10000),IF(F4>=100000,(ROUNDUP(F4,-4)-1000),IF(F4>=10000,(ROUNDUP(F4,-3)-1000),IF(F4>=0,(ROUNDUP(F4,-3)))))))

I need to do exact the same thing but in Python, and I don’t know the way to do it.

Thanks for helping me!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T09:24:54+00:00Added an answer on June 17, 2026 at 9:24 am
    def round_up(value, multiple):
        return multiple * math.ceil(float(value) / multiple)
    
    def digits(value):
        return int(math.log(value, 10)) + 1
    
    def round_price(value):
        if value < 10000:
            return int(round_up(value, 1000))
        d = digits(value)
        new_value = int(round_up(value, 10 ** (d - 2)))
        new_value -= 10 ** (d - 3)
        return new_value
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I started learning Python just today using Python 2.7 and I have a question
I have a question about Objective-C today involving NSMutableArray. Coming from a .net/c# background
Today I have another specific question about a new feature in windows 7 called
I am trying to learn about VPN using OSX and have a question I
Today my question is about UITableViewController-s In particular I have noticed that the datasource
I have a question about Workspaces on TFS. Currently, I am using TFS 2008
Today I have question about Eclipse . I use this IDE very long and
my question for today is about the BouncyCastle encryption Library for J2ME, I have
I have a question today about the usage of HyperLinkField in a GridView. I
Today I came across this question: you have a code static int counter =

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.