Jan-14-2017, 05:17 PM
(This post was last modified: Jan-14-2017, 05:17 PM by garretmorion.)
'm relatively new to python and the only other experience I've had is C++. Whenever I define a function in Python, I can't seem to execute it. This my current code for my assignment, if possible I just want to know why my code won't execute
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")