Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

order of operations in python

Name: Anonymous 2013-05-03 5:47

hey guys just trying to figure out what i have wrong here... here's a simple conversion in python (fahrenheit to celsius)

c = 5 / 9 * float (f - 32)

i'm not sure why this will not convert properly but i'm guessing it has to do with the way python does order of operations

this is what i'm coming up with
http://gyazo.com/3735a2a4608bd3f7f36d79f5140ea3b1.png

so when you put in float (f - 32), is basically what's going on is python is not treating f - 32 as a "parentheses" in order of operations and doing the division before anything else.....also if i remember correctly PEMDAS has "Multiplication" clearly ahead of "Division" so why does Python do the division before anything else?

Name: Anonymous 2013-05-03 6:21

you forgot some parenthesis


(define (celsius fahrenheit)
      (*  (- fahrenheit 32)
          (/ 5. 9)))
(define f 420)
(celsius f)
215.56

Name: Cudder !MhMRSATORI!fR8duoqGZdD/iE5 2013-05-03 6:23

Name: Anonymous 2013-05-03 13:09

What kind of idiot posts a screenshot of plain text?

Name: OP 2013-05-03 13:21

@Anonymous 2013-05-03 13:09
sue me

@Anonymous 2013-05-03 06:21
thanks for that link

so basically in something like...

f = 90
c = 5 / 9 * float (f - 32)

so here does the float () function negate the use of (f - 32) as parentheses in order of operations?

Name: Anonymous 2013-05-03 13:42

What is integer division?

Name: Anonymous 2013-05-03 13:59

90 degrees fahrenheit is 0 degrees celsius. Case closed.

Name: Anonymous 2013-05-03 14:35

You're all wrong c = ℓP⋅tP.

Name: Anonymous 2013-05-03 14:38

OP is stupid fukin goyim. No wonders jews are the EXPERT PROGRAMMERS

Name: Anonymous 2013-05-03 15:27

expert programmers

Name: Anonymous 2013-05-03 20:25

>> 9

Truth

Name: Anonymous 2013-05-03 20:32

>>9
Jews are expert deceivers: http://www.youtube.com/watch?v=SywLjSSm7dY

Name: Anonymous 2013-05-03 22:54

10/18 *  float(f-32)

Name: Anonymous 2013-08-31 18:09


If by god you mean the imaginary half naked old man that lives in the head of all American Christians then yes.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List