Python input:
from math import * x,n = 5,1 x *= 2+3**3 class myclass: def __init__(s, n): s.color = n def ok(s,val): print val**2 o = myclass("blue") print o.color v = [5,6,o] x,v[n] = 1+2,3 v[1+1]=v[1:n+2][2*n-1].ok(1) while x > 3 and x < y: x = x+1 y = 3 while y < 4: y = x x = 1 if y > 3: continue else: break def test(a,b): # func a=b for x in 1,2,3: y=x; z=x return a,b for x in 1,2,3: y=x z=x print 1,2\ +3*x+cos( 2+sin(3)) assert 1==1 test(2+3,x/3) x = {1:2, 3:4+5} x = 0.2 + 1. + 2E5 + 2.E5 + 2.e+5 y = '234\'234"' z = "234\"234'" if x < 10: print """multi-line string""" elif x > 20: print 123 else: print 234
Output:
blue
1
1 10.460095472
123
|
Perl output:
; ($x, $n) = (5, 1); $x *= 2 + 3**3; { package myclass; sub new { my($class, $n) = @_; my $s = {}; bless $s, $class; $s->{color} = $n; return $s; } sub ok { my($s, $val) = @_; print $val**2, "\n"; } } $o = new myclass("blue"); print $o->{color}, "\n"; $v = [5, 6, $o]; ($x, $v->[$n]) = (1 + 2, 3); $v->[1 + 1] = [@{$v}[1..$n + 2 - 1]]->[2 * $n - 1]->ok(1); while($x > 3 and $x < $y) { $x = $x + 1; $y = 3; while($y < 4) { $y = $x; $x = 1; if($y > 3) { next; } else { last; } } } sub test { my($a, $b) = @_; $a = $b; foreach my $x (1, 2, 3) { $y = $x; $z = $x; } return ($a, $b); } foreach my $x (1, 2, 3) { $y = $x; $z = $x; } print 1, " ", 2 + 3 * $x + cos(2 + sin(3)), "\n"; die if not 1 == 1; &test(2 + 3, $x / 3); $x = {1 => 2, 3 => 4 + 5}; $x = 0.2 + 1. + 2E5 + 2.E5 + 2.e+5; $y = '234\'234"'; $z = "234\"234'"; if($x < 10) { print qq(multi-line string), "\n"; } elsif($x > 20) { print 123, "\n"; } else { print 234, "\n"; }
Output:
blue
1
1 10.4600954719667
123
|