Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Value , if condition
#1
Good afternoon,

Well second post about this small programm I have, after fixed the problem of memory error thank to you guys i have another one.

I've also checked on the forum but it seems nothing matched.

The problem I have is when I want to calculate my value I can just use some values for the speed { 2499 ,2856 3213 and 3570 } otherwise the program send me back the value is 0 . wich is quit weird for me

I suppose that my if condition is badly writed but don't really understand why...

Well if anybody had the same problem before that will help me a lot!

Thank you

print ('Enter your Head in feat:')
Head = int(input ())
print ('Enter you speed in rpm')
Speed = int(input()) 

if (2142< Speed <=2499):
        function = ((2499-Speed)/357)*((-1.75*10**-8)*Head**4+(1.21*10**-4)*Head**3-(3.1*10**-1)*Head**2+(3.53*10**2)*Head-1.49*10**5)+((Speed-2142)/357)*((-2.87*10**-9)*Head**4 +(2.58*10**-5)*Head**3-(8.71*10**-2)*Head**2+(1.3*10**2)*Head-7.03*10**4)
if (2499< Speed <=2856):
        function = ((2856-Speed)/357)*((-2.87*10**-9)*Head**4+(2.58*10**-5)*Head**3-(8.71*10**-2)*Head**2+(1.3*10**2)*Head-7.03*10**4)+((Speed-2499)/357)*((-2.21*10**-9)*Head**4 +(2.67*10**-5)*Head**3-(1.2*10**-1)*Head**2+(2.38*10**2)*Head-1.74*10**5)
if (2856< Speed <=3213):
        function = ((3213-Speed)/357)*((-2.21*10**-9)*Head**4+(2.67*10**-5)*Head**3-(1.2*10**-1)*Head**2+(2.38*10**2)*Head-1.74*10**5)+((Speed-2856)/357)*((-1.56*10**-10)*Head**4+(1.85*10**-06)*Head**3-(7.50*10**-3)*Head**2+(1.07*10**1)*Head-(1.60*10**-2))
if (3213<Speed and Speed<=3570):
        function = ((3570-Speed)/357)*((-1.56*10**-10)*Head**4+(1.85*10**-06)*Head**3-(7.50*10**-3)*Head**2+(1.07*10**1)*Head-(1.60*10**-2))+((Speed-3213)/357)*((-3.77*10**-10)*Head**4 +(7.19*10**-6)*Head**3-(5.12*10**-2)*Head**2+(1.61*10**2)*Head-1.87*10**5)

print("The value is : ")
print(function)
Reply
#2
Help me to help you:
-instead of using input(), use a specific value(s)
-share what your current output is, and what you'd expect the output to be.

Without that, there's really very little chance I can decipher all that craziness lol
Reply
#3
from command line type:
which pip
and type:

which python
do they match up?
It sounds as if you have multiple versions of python, and not using pip that matches python

somehow posted to wrong thread, sorry
Reply
#4
Thank you for your answer,

ok I will post with some value as example !

Enter your Head in feat: 5000
Enter you speed in rpm: 3250
The value is : 0

But the real value as to be around 1000

But if i do :

Enter your Head in feat: 5000
Enter you speed in rpm: 3570
The value is : 1125.0

That work perfectly because the speed value is referenced in the if condition.
Reply
#5
The code doesn't run, I've got two SyntaxError on the numbers 06. It is an invalid token for python. Write 6 instead of 06.
Reply
#6
Well I am actually on linux so I have asked my python version is 2.7.15rc1 [GCC7.3.0] on linux2
but don't know where to ask which pip ? you mean on the terminal or the pyhton console ?

Thank you

A friend found it after a while it seems you have to put some float as input and no int otherwise python ,as a dynamic type do it with multiplicated it by h 0 ...
Reply
#7
You replied before I could. Python2's division kept the type, so an int divided by an int produced an int result. Python3 "fixed" that, by always having division give float results.

You should look into using python3, python2 has just slightly more than a year of bugfixes left, before it's abandoned: https://pythonclock.org/
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  else condition not called when if condition is false Sandz1286 10 5,736 Jun-05-2020, 05:01 PM
Last Post: ebolisa
  [HELP] Nested conditional? double condition followed by another condition. penahuse 25 7,698 Jun-01-2020, 06:00 PM
Last Post: penahuse

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020