Menu

Someone Make Python Program Round Results Nearest Whole Number Repeating Whole Numbers App Q43780469

Can someone make this python program round the results to thenearest whole number? and if their are repeating whole numbers thatappear evenly for example(2,2) or (1,1,1,1) or (3,3,3,3,3,3) thendelete them in the final result file.

#importing xlwt library to write into xls
import xlwt
from xlwt import Workbook

#create a workbook
wb = Workbook()
#create a sheet
sheet = wb.add_sheet(‘Sheet’)

#percentages list
percentages = [23.6, 38.2, 50, 61.8, 78.6, 113, 123.6, 138.2,161.8]
#add first row
for i in range(len(percentages)):
   sheet.write(0,i+1,str(percentages[i])+’%’)

#user input
n = int(input(‘Enter number of elements: ‘))
#second row starts from index 1
row=1
print(‘Enter numbers: ‘)
for i in range(n):
    #User input
   val = float(input())
   #Add entered value to first column of the row
   sheet.write(row,0,str(val))
   #calculate each percentage
   for j in range(len(percentages)):
       result =(percentages[j]/100)*val
       #write result to sheet by roundingupto 3 decimal points
      sheet.write(row,j+1,str(round(result,3)))
   #increment the row by 1
   row+=1
#save Workbook as xls`
wb.save(‘percentages.xls’)

Thank you so much for anyone who helped!

Expert Answer


Answer to Can someone make this python program round the results to the nearest whole number? and if their are repeating whole num…

OR