Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

round to nearest multiple of 5 python

def rof(x):   '''round up to multiple of 5'''
    if x%5==4:
        x+=1
    elif x%5==3:
        x+=2
    print(x)
Comment

round to nearest multiple of 5 python from both end

#round up to multiple of 5 from both end
def rof(x,y,z):
    if x%5==4:
        x+=1
    elif x%5==1:
        x-=1
    elif x%5==2:
        x-=2

Comment

PREVIOUS NEXT
Code Example
Python :: remove whitespace from data frame 
Python :: list in one line of text in python 
Python :: dictionary changed size during iteration 
Python :: ipython history 
Python :: make value of two tables unique django 
Python :: py function 
Python :: get column or row of matrix array numpy python 
Python :: pip change python version 
Python :: string list to list 
Python :: pdf to string python 
Python :: check word in list 
Python :: Find the length of a nested list in python 
Python :: docstrings in python 
Python :: Using Lists as Queues 
Python :: iterate through a list and print from index x to y using for loop python 
Python :: python request add header 
Python :: python only decimal part 
Python :: twitter api python 
Python :: python for data analysis 
Python :: import matplotlib sub 
Python :: SUMOFPROD1 codechef solution 
Python :: sphinx autodoc extension 
Python :: python if boolean logic 
Python :: python windows os.listdir path usage 
Python :: Python Tkinter Scale Widget 
Python :: Converting (YYYY-MM-DD-HH:MM:SS) date time 
Python :: join string with comma python 
Python :: how to multiply in python 
Python :: python map list of int to string 
Python :: 1d array operations in python 
ADD CONTENT
Topic
Content
Source link
Name
1+7 =