Rachel M.
asked 02/13/23python program problem
my program imports another program I wrote. the part of the imported program I'm having a problem with is .
def get_float(prompt):
variable = float(input(prompt))
variable = float(varaible)
return variable
the errors I get when I try and use this in the program it is imported into is 'could not convert string to float'
future = csc111_input.get_int(input("Enter the future value: "))
interest = csc111_input.get_float(input("Enter the interest rate: "))
num_periods = csc111_input.get_int(input("Enter the number of periods: "))
pv = p1p1_engr_econ.sp_pres_worth(future, interest, num_periods)
print(f"The present value of {future} when {num_periods} payments with {interest} rate is: "+"\033[91m" + str(format(pv, '.2f')) + "\033[0m")
1 Expert Answer
Jason C. answered 02/15/23
College-level Computer Science student
From a glance, it looks like you have a redundant call of input.
From what your code looks like, prompt should be a string that is the question, not the answer to the question.
Does this answer your question?
Still looking for help? Get the right answer, fast.
Get a free answer to a quick problem.
Most questions answered within 4 hours.
OR
Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.
Rachel M.
The last bit is the function that imports the get_float02/13/23