+ 4
Can someone more clearly explain what accumulate is? Say if there is 10 variables, and you accumulate with range(8), does it take the first 8 integers/strings or any random 8 integer/string?
Accumulate
4 Respuestas
+ 1
It returns the sum of all previous elements and the current one, for example, if you have:
print(list(accumulate([5,4,22])))
then it will print:
[5,9,31]
equivalent to
[5,5+4,5+4+22]
0
George Ciuclea you are right regarding the logic of accumulate method. Doc to refer:
https://docs.python.org/3/library/itertools.html#itertools.accumulate
- 1
i still do'nt get it
- 9
for str_employee in range(5):
def Name ():
strName = input ("Enter your name: ")
return strName
def hoursworked ():
strhours = input ("Enter Total Hours Worked: ")
flthours = float(strhours)
return flthours
def wagerate ():
strwage = input ("Enter Wage Rate: quot;)
fltwage = float(strwage)
return fltwage
currentUser = Name()
currentSal = (hoursworked () * wagerate ())
fltpercent_08 = float (.08)
fltpercent_20 = float (.20)
fltfedtax = (currentSal * fltpercent_20)
fltstatetax = (currentSal * fltpercent_08)
print ("")
print ("Your Federal Tax is: quot;, fltfedtax)
print ("Your State Tax is: quot;, fltstatetax)
print ("")
sum = fltfedtax
for fltstatetax in range (0):
sum = fltfedtax + fltfedtax
sum2 = fltstatetax
for fltstatetax in range (0):
sum2 = fltstatetax + fltstatetax
print ("")
print ("Total Taxes")
print ("Total Federal Tax is: quot;, sum)
print ("Total State Tax is: quot;, sum2)