Jan-14-2017, 05:35 PM
Here your code now with function call.
And i call with a smaller number,try this 1980 ** 1980 get really big.
And i call with a smaller number,try this 1980 ** 1980 get really big.
def birthexp(birthyear): product = birthyear**birthyear length = len(str(product)) onesCount = str(product).count("1") threeCount = str(product).count("3") fiveCount = str(product).count("5") sevenCount = str(product).count("7") nineCount = str(product).count("9") sumCount = onesCount+threeCount+fiveCount+sevenCount+nineCount oneRation = onesCount/float(length)*100 threeRatio = threeCount/float(length)*100 fiveRatio = fiveCount/float(length)*100 sevenRatio = sevenCount/float(length)*100 nineRatio = nineCount/float(length)*100 totalRatio = sumCount/float(length)*100 print(str(product) + ": product after multiplying the birth year to itself.") print(str(onesCount) + ": number of ones found at a rate of " +str(oneRation)+ "percent.") print(str(threeCount) + ": number of threes found at a rate of " +str(threeRatio)+ "percent") print(str(fiveCount) + ": number of fives found at a rate of " +str(fiveRatio)+ "percent") print(str(sevenCount) + ": number of sevens found at a rate of " +str(sevenRatio)+ "percent") print(str(nineCount) + ": number of nine found at a rate of " +str(nineRatio)+ "percent") print(str(sumCount) + ": total odd numbers found at a rate of " +str(totalRatio)+ "percent") birthexp(2)
Output:4: product after multiplying the birth year to itself.
0: number of ones found at a rate of 0.0percent.
0: number of threes found at a rate of 0.0percent
0: number of fives found at a rate of 0.0percent
0: number of sevens found at a rate of 0.0percent
0: number of nine found at a rate of 0.0percent
0: total odd numbers found at a rate of 0.0percent