0

The output for this code is always 10. AM I doing something wrong? I also want assistance the negative rational exponent equation for "Vc"

let R=10000, C=1e-6, and Vs=10

   R= 10000
   C= 10**-6
   Vs= 10
   T= float(R*C)
   t= float(input("Enter the value of t:"))
   Vc=Vs*(1-(10**-(t/T)))
   print(format(Vc,".5f"))

Thank you in advance for your replies.

Cyberguille
  • 1,552
  • 3
  • 28
  • 58
Godang
  • 3
  • 3

2 Answers2

1

You don't always get 10. For small numbers, you get a value other than 10. Try entering .0001, for example.

For larger values of t, the expression 10**-(t/T) is so small a number that Python treats it as 0. So you have 10*(1-0), or 10, for large enough values of t. 1 is too large, so you do get 10 for an entry of 1, and anything bigger than that. -1, btw, gives an interesting answer, and entering a large negative value crashes the program with an overflow error.

CryptoFool
  • 21,719
  • 5
  • 26
  • 44
0

Well, When your t is greater than 1 it will print always 10. Because T is 0.01 and if you provide t is greater than 1, your code is negotiating 1-(10**-(t/T)) to 1.

  • Let's t=1 then t/T=100 and 10**-100=0 so Vs*(1-0)=10
  • If you increase your t=1 to another big integer it will always 10.

If you take t as much as possible a tiny number then you will see an output change.

I assume t as 0.00001234. Now your output is 0.02837357076786451. SO, you should take t as a minimum value to change output 10.

mhhabib
  • 2,975
  • 1
  • 15
  • 29