# [Tutor] How to convert the fortran logic to python definition

Alan Gauld alan.gauld at yahoo.co.uk
Fri Mar 27 07:30:04 EDT 2020

```Please always use replyAll or ReplyList when responding to the Python
tutor list. Otherwise t just goes to the original poster.

On 27/03/2020 04:08, SATYABRATA DATTA wrote:
> Thanks Alan but if the x and y are both functions of Delta and I want to
> get back x(a,b,c,d) and y(a,b,c,d)

OK, I don't really understand what you want.
Where are x and y defined in the fortran code?

Also do you want to get back (x(a,b,c,d) and y(a,b,c,d))
ie the logical and of the two functions results.

Or do you want to get back both x(a,b,c,d as well as y(a,b,c,d)
That is two values? I wasn't even aware Fortran could do that
and it isn't what your code snippet appears to do.

Are you sure your fortran code does what you want?

>     >          if((x.lt.0.and.y.lt.0).or.(x.lt.0.and.y.gt.0))then
>
>     The obvious question here is what happens when x and/or y
>     is equal to zero? That is undefined.
>
>     Also
>
>     (A and B) or (A and notB)
>
>     is equal to:
>
>     A
>
>     Draw the truth table to prove it.

You haven't addressed either of my issues above.

If we ignore the zero cases your if statement is the same as:

if( x.lt.0) then

so y is effectively ignored.

Now, as I said I was never an expert in Fortran and there may
be some subtle fortran magic going on that I'm unaware of.
But it looks to me like your fortran is suspect, or at least
incomplete. Its very difficult to guess what should be happening.

Perhaps you should try asking on a Fortran forum, its probably
more likely that modern Fortran programmers will also know Python
than that Python programmers will know Fortran!

--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos

```