Ruby と Python

どちらもInterpreter Languageだが、ひとつを選べと言われたらどちらを覚えたほうがよいのだろう。  日本ではRubyがかなり人気があるようだが、WorldwideのUser BaseではPythonのほうが多い。 多いと言ってもPHPとかに比べるとかなり少ない。 Ruby # Old “coke” program from 80’s Basic programming book in Ruby answer = Random.rand(1..100) count,guess = 0,0 puts ‘I am thinking about number between 1 and 100. Can you guess?’ while (answer != guess) guess = gets.to_i count += 1 if guess > answer puts “#{guess} is too high” elsif guess < answer puts "#{guess} is too low" else puts "you got it right in #{count} try!" end end Python """Old "coke" program from 80's Basic programming book, in Python""" import random answer = random.randrange(1,100) print ("I am thinking a number between 1 and 100. Hope you can guess") guess, count = 0,0 while (answer != […]