rby_pyt_syntax Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

!/usr/bin/python

print “Hello, Python!”

A

!/usr/bin/ruby -w

puts “Hello, Ruby!”;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

!/usr/bin/python

import subprocess

subprocess.Popen(
    '''
    echo hi there
    echo lo there
    ''',
    shell = True
)
A

!/usr/bin/ruby

print «EOC
echo hi there
echo lo there
EOC

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q
#!/usr/bin/python
# has new line before and after
print '''
    blah, blah
    blah, blah
'''
A

!/usr/bin/ruby

print &laquo_space;EOF
blah, blah
blah, blah
EOF

no space after «

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

!/usr/bin/python

no BEGIN or END

A

!/usr/bin/ruby

puts “This is main Ruby Program”

END {
   puts "Terminating Ruby Program"
}
BEGIN {
   puts "Initializing Ruby Program"
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

!/usr/bin/python

# First comment
print "Hello, Python!" # second comment
# This is a comment.
# This is a comment, too.
# This is a comment, too.
# I said that already.
A
#!/usr/bin/ruby
# First comment
puts "Hello, Ruby!"  # second comment
=begin
This is a comment.
This is a comment, too.
This is a comment, too.
I said that already.
=end
How well did you know this?
1
Not at all
2
3
4
5
Perfectly