python、C语言、fortran 三种语言的语法对比

 

Differences between Python

 FORTRAN and C

 

 

Operation

Python

FORTRAN

C

Computation of the logarithm base 10 of the input value with missing value management

log10()

LOG10()

log()

Computation of 10 raised to the power of the input value

exp10() or pow10()

POW(10, )

pow(10,)

Computation of input value1 raised to the power of the input value2

** (example: 10 ** 3) or pow(10, 3)

** (example: 10 ** 3) or POW(10, 3)

pow(10,3)

Missing value (-9999)

MissingValue

-9999

MISSING_VALUE

Conditions

if perm <= 0 or permMin == MissingValue:

    x = MissingValue

elif perm > 1000:

    x = MissingValue

else:

    x = log10(perm)

    y = log10(perm) - permMin

IF ((perm.LE.(0)).AND.(permMin.EQ.( -9999)) THEN

    x = -9999

ELSE IF (perm.GT.(1000)) THEN

    x = -9999

ELSE

    x = LOG10(perm)

    y = LOG10(perm) - permMin

ENDIF

if (perm<=0|| permMin == MissingValue)

{

x = MissingValue;

}

else

if (perm > 1000)

{  

x = MissingValue;

}

  else

  {

x = log10(perm);

  y = log10(perm) – permMin;

}

 

Logical operator - or

or

.OR.

||

Logical operator - and

and

.AND.

&&

Logical operator - not

not

.NOT.

        !

Comparison operator - equal

==

.EQ.

==

Comparison operator - different

!= or <>

.NE.

!=

Other similar comparison operators

<, <=, >, >=, (...)

.LT., .LE., .GT., .GE., ...

<, <=, >, >=

Assignment operators

=,+=, -=, *=, /=

 

=,+=, -=, *=, /=

Temporary "variable" creation

a = 10

REAL|INTEGER a

a = 10

int a =10;

Temporary "list" creation, append operation and display

a = []

a.append("Well1")

print a

 

char a[10];

a="Well1";

printf(“%s”,a);

Output display

output("Hello world!") or print "Hello world!"

PRINT 'Hello world!'

 

printf("Hello world!");

Loop

for i in range(i1, i2, inc):

DO i = i1, i2, inc

END DO

for (i=i1;i<i2;i=i+inc){}

while(i<i2){i=i+inc;}

 

Comment

#{comment until the end of the line}

C in the first column

//{in the first column}

 

/*…….*/{comment during the two symbols}

 

  • 3
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值