Ruby 50 Ruby UTF print, \n [Ruby-1] print("hello, Ruby.\n") [Ruby-2] Hello, Ruby. [Ruby-3] print("hello, \"Ruby\".\n") 2 [Ruby-4] seisuu = 10 pr

Similar documents
I 1 1 ( *) ( *) ex1-1.rb ) 2 CGI

1 Ex Ex. 2 2

5-2 print(i, "\n") print("-- while--\n") while i < 2 j = print(i, ",", j, "\n") print("-- while--\n") while j < 3 print(i, ",", j, "\n") j = j + 1 pri

Windows [ ] [ (R)..] cmd [OK] Z:\> mkdir progi [Enter] \ ) mkdir progi ) (command ) help [Enter] help ( help ) mkdir make directory Windows ) mkdir mk

平成16年度 教育研究員研究報告書 高等学校 地理歴史・公民

NEWS LETTER No.10 (Page 1)

untitled

Microsoft PowerPoint - ruby_instruction.ppt

AP_12_15_yonezawa.indd

. 1 EBM Evidence-Based Medicine JCAHO 2

listings-ext

parser.y 3. node.rb 4. CD-ROM

¥×¥í¥°¥é¥ß¥ó¥°±é½¬I Exercise on Programming I [1zh] ` `%%%`#`&12_`__~~~ alse

¥×¥í¥°¥é¥ß¥ó¥°±é½¬I Exercise on Programming I [1zh] ` `%%%`#`&12_`__~~~ alse

untitled


Ruby演習テキスト1

untitled

超初心者用

¥×¥í¥°¥é¥ß¥ó¥°±é½¬I Exercise on Programming I [1zh] ` `%%%`#`&12_`__~~~ alse

program_japanese

haskell.gby

or a 3-1a (0 b ) : max: a b a > b result a result b ( ) result Python : def max(a, b): if a > b: result = a else: result = b ret

Ruby Ruby ruby Ruby G: Ruby>ruby Ks sample1.rb G: Ruby> irb (interactive Ruby) G: Ruby>irb -Ks irb(main):001:0> print( ) 44=>

Windows Cygwin Mac *1 Emacs Ruby ( ) 1 Cygwin Bash Cygwin Windows Cygwin Cygwin Mac 1 Mac 1.2 *2 ls *3 *1 OS Linux *2 *3 Enter ( ) 2

Sokushu2_perl

27

r2.dvi

r9.dvi

r1.dvi

Microsoft PowerPoint Perl講習会.ppt [互換モード]

ohp03.dvi

離散数理工学 第 2回 数え上げの基礎:漸化式の立て方

102

9_白銀志栄_Final.indd

つくって学ぶプログラミング言語 RubyによるScheme処理系の実装

Microsoft PowerPoint - 11RubyIntro-No02.ppt [互換モード]

PowerPoint Presentation

離散数理工学 第 2回 数え上げの基礎:漸化式の立て方

2 key. 3

r03.dvi

¥¤¥ó¥¿¡¼¥Í¥Ã¥È·×¬¤È¥Ç¡¼¥¿²òÀÏ Âè2²ó


8 if switch for while do while 2

コメント プログラム中には コメントを加える事ができます 処理の際には無視されるので 注釈や覚え書きとして利 できます print("hello Sapporo!") # Hello Sapporo! と 表 する # コメントは無視される 字列 字列とは 単語や 章のような 字の連なったものです

情報科学概論 第1回資料

javascript key


Python Speed Learning

Javaセキュアコーディングセミナー東京 第3回 入出力(File, Stream)と例外時の動作 演習解説

K227 Java 2

r08.dvi

fp.gby

10 (1) s 10.2 rails c Rails 7 > item = PlanItem.new => #<PlanItem id nil, name nil,...> > item.name = "" => "" > item.valid? => true valid? true false

untitled

ohp08.dvi

Microsoft PowerPoint - Ruby n

Emacs Ruby..

201_P1_P24(2)

indd

katagami No.65

P01-14.indd

新善-1208

8_p01.indd

untitled

2

1_p01.indd


40_No43.indd

2007.3„”76“ƒ



sayo pdf

月信11-12pdf用.indd

広報ちくしの_ indd


レッツ中央205号.indd

えふ・サポート-113号-162.indd




d


レッツ中央210号.indd


レッツ中央212号.indd

0405宅建表01.indd

広報ちくしの_ indd

10/ / /30 3. ( ) 11/ 6 4. UNIX + C socket 11/13 5. ( ) C 11/20 6. http, CGI Perl 11/27 7. ( ) Perl 12/ 4 8. Windows Winsock 12/11 9. JAV


3 Java 3.1 Hello World! Hello World public class HelloWorld { public static void main(string[] args) { System.out.println("Hello World");

/ 123 / 30 7/ / 78 9/ / / 40 2/ / 150 2/583/ / 40 3/ /8 6 1/29

Microsoft Windows,Word2013 Microsoft Corporation

1-1 IE 1-2 IE2 1-3 IE Method Ebgineering Method Engineering

Microsoft PowerPoint - Prog05.ppt

from tkinter import * root = Tk() # variable teban = IntVar() teban.set(1) # def start(): canvas.create_rectangle(0, 0, 560, 560, fill= white ) for k


コメント 埋め込みドキュメント # 記号から行末まではコメントとして無視される. # コメントです # この行もコメントです print "Hello n" # こんにちは # print "World! n" print "World! n" 行頭に "=begin" がある行から, 行頭に "=

1-4 int a; std::cin >> a; std::cout << "a = " << a << std::endl; C++( 1-4 ) stdio.h iostream iostream.h C++ include.h 1-4 scanf() std::cin >>

Transcription:

Ruby 50 Ruby UTF-8 1 1 print, \n [Ruby-1] print("hello, Ruby.\n") [Ruby-2] Hello, Ruby. [Ruby-3] print("hello, \"Ruby\".\n") 2 [Ruby-4] seisuu = 10 print(seisuu, "\n") jissuu = 3.141592 print(jissuu, "\n") [Ruby-5] mojiretsu = "Ruby" print(mojiretsu, "\n") 1

3 [Ruby-6] print(1 + 1, "\n") print(2-3, "\n") print(5 * 10, "\n") print(100 / 4, "\n") [Ruby-7] print(1.0 + 2.0, "\n") print(2.0 * 3.0, "\n") print(5.0-8.0, "\n") print(9.0 / 2.0, "\n") [Ruby-8] print(7 / 2, "\n") print(7.0 / 2.0, "\n") [Ruby-9] 4 [Ruby-10] mystring = " Ruby" print(mystring, "\n") print(mystring, "\n") print("mystring", "\n") 2

[Ruby-11] print(12 + 12) print("\n") print("12" + "12") print("\n") print("12 + 12") print("\n") [Ruby-12] when = " " who = " " what = " " where = " " why = " " how = " " phrase1 = when + who + what + " " print(phrase1, " \n") phrase2 = when + who + why + where + how + what + " " print(phrase2, " \n") 5 [Ruby-13] a = 10 b = 10 if b > a print("b a \n") elsif b == a print("b a \n") else print("b a \n") [Ruby-14] a, b 3

[Ruby-15] x = 2 if x >= 1 && x <= 10 print("x 1 10 \n") [Ruby-16] x 6 [Ruby-17] [Ruby-18] while i < 3 [Ruby-19] (10) [Ruby-20] + 1 1 [Ruby-21] sum = 0 while i <= 10 sum = sum + i print(sum, "\n") 4

[Ruby-22] j = 0 while i < 9 j = 0 while j < 9 print(i * j, "\n") j = j + 1 [Ruby-23] tango = ["knowledge", "information", "system", "library", "metadata"] while true print(" \n") print(". ( ) \n") a = gets.chomp if a == "." break j = 0 while j < tango.size if a == tango[j] print(a, " \n") break j = j + 1 if j == tango.size print(a, " \n") tango.push(a) } tango.each{ value print(value, "\n") 5

7 gets, chomp [Ruby-24] str = "Hi\n" print(str, "!\n") str1 = str.chomp str2 = str.chomp.chomp str3 = str.chop str4 = str.chop.chop print(str1, "!\n") print(str2, "!\n") print(str3, "!\n") print(str4, "!\n") [Ruby-25] print(" \n") name = gets.chomp print(name, " \n") [Ruby-26].chomp 8 [Ruby-27] nums = [1, 2, 3] strs = ["a", "b", "c"] print(nums[0], "\n") print(nums[1], "\n") print(nums[2], "\n") print(strs[0], "\n") print(strs[1], "\n") print(strs[2], "\n") 6

[Ruby-28] name = Array.new(3, "") print(" \n") name[0] = gets.chomp print(" \n") name[1] = gets.chomp print(" \n") name[2] = gets.chomp print(name[0], " \n") print(name[1], " \n") print(name[2], " \n") [Ruby-29] fruit_list = Array.new(5, "") while i < 5 print(" > ") fruit = gets.chomp if fruit == "." break fruit_list[i] = fruit print("\n") print("-----------------------------\n") while i < fruit_list.size print(fruit_list[i], "\n") print("-----------------------------\n") 7

9 [Ruby-30] eng = {" " => "frog", " " => "bee", " " => "duck", " " => "cicada"} print(" ( ) \n") str = gets.chomp print(eng[str], "\n") [Ruby-31] eng ={" " => "frog", " " => "bee", " " => "duck", " " => "cicada"} } eng.each{ key, value print(key, ":", value, "\n") [Ruby-32] eng = Hash.new print(eng.size, "\n") print(eng.empty?, "\n") eng[" "] = "frog" eng[" "] = "duck" eng[" "] = "cicada" print(eng.size, "\n") print(eng.empty?, "\n") eng.each{ key, value print(key, ":", value, "\n") } eng.delete(" ") eng.each{ key, value print(key, ":", value, "\n") } print(eng.size, "\n") eng.clear print(eng.size, "\n") 8

10 [Ruby-33] def zeikomi(nedan) print(nedan * 1.05, " \n") zeikomi(300) zeikomi(2600) [Ruby-34] def san_tan_gen(doushi) return doushi + "s" print(" > ") doushi = gets.chomp print("3 ", san_tan_gen(doushi), " \n") [Ruby-35] def max(a, b) if a > b return a else return b print(max(2, 3), "\n") [Ruby-36] 2,3 9

11 [Ruby-37] print(" \n") str = gets.chomp if /pen/ =~ str print(" \n") else print(" \n") [Ruby-38] pen ^pen, pen$, ^pen$ pen, penalty, happen [Ruby-39] pen 1. p.n 2. p*n 3. p+n 4. p?n 5. p(aei)n 6. ^...$ 7. ^$ 12 [Ruby-40] foo.txt filename = "foo.txt" out = open(filename, "w") out.print(" \n") out.close [Ruby-41] out.print 10

[Ruby-42] foo.txt filename = "foo.txt" input = open(filename, "r") line = input.gets line.chomp! print(" ", line, " \n") input.close [Ruby-43] io = open("foo.txt", "r") while true line = io.gets print(line) if line == nil break io.close [Ruby-44] io = open("foo.txt", "r") while line = io.gets print(line) io.close [Ruby-45] } open("foo.txt", "r") { io while line = io.gets print(line) 13 [Ruby-46] 2 [Ruby-47] [Ruby-48] 1 1 1 1 N 11

[Ruby-49] 2 [Ruby-50] ( ) 12