Question: Python - TypeError: Not all arguments converted during string formatting I am getting error TypeError: Not all arguments converted during string formatting on lines 26

Python - TypeError: Not all arguments converted during string formatting

I am getting error "TypeError: Not all arguments converted during string formatting" on lines 26 & 35.I don't understand why. I am trying to time the runtime of a function and print number of times looped as well.

here is my code:

from datetime import datetime print("Enter a number") input1 = input() print("Enter a second number") input2 = input() if input1 > input2: dividend = input1 divisor = input2 else: dividend = input2 divisor = input1 def rgcd(a, b): if b == 0: return a else: return rgcd(b, a % b) def igcd(a, b): icount = 0 remainder = a % b while remainder > 0: a = b b = remainder remainder = a % b icount += 1 return b, icount x, y = igcd(dividend, divisor) recursiveStartTime = datetime.now() for i in range(1000000): (rgcd(dividend, divisor)) recursiveEndTime = datetime.now() recursiveRunTime = recursiveEndTime - recursiveStartTime iterativeStartTime = datetime.now() for i in range(1000000): (igcd(dividend, divisor)) iterativeEndTime = datetime.now() iterativeRunTime = iterativeEndTime - iterativeStartTime print("Recursive run time:", recursiveRunTime.total_seconds() * 1000, "milliseconds") print("Iterative Loops:", y) print("Iterative run time:", iterativeRunTime.total_seconds() * 1000, "milliseconds") 

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!