Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Structured Search For Big Data From Keywords To Key-objects

Authors: Mikhail Gilula

1st Edition

012804652X, 9780128046524

More Books

Students also viewed these Databases questions

Question

Difference between traditional file system and modern approach:

Answered: 1 week ago