12. 출력하기
puts “what is his name”
print “is he hot”
출력한 후 빈 줄을 하나 추가한다
화면에 그냥 출력한다
13. 이름 (String)
나이 (Integer)
어머님 나이(Integer)
본인이 AB형인지 아닌지 (Boolean)
2. puts 를 이용해서 이름을 출력해주세요
3. print 를 이용해서 어머니 나이와
본인 나이를 곱한 값을 출력해주세요
4. puts 를 이용해서 AB형 유무를 출력해주세요
1. 위의 값들을 각각의 변수에 넣어서 입력해주세요
19. Data 종류 - Symbol
표기 방식 :name
String 과 같다고 생각하면 이해하기 쉽다
주로 함수 이름, 키 이름, 변수등의 ID 로 사용된다
예) student[:grade]
20. Data 종류 - Array
x = Array.new
x << 10
x[1] = 99
y = ["Alice", 23, 7.3]
x[2] = y[1] + y[-1]
21. Data 종류 - Hash
person = Hash.new
person["last_name"] = "Rodriguez"
person[:first_name] = “Alice"
order = {"item" => "Corn Flakes", "weight" => 18}
order = {:item => "Corn Flakes", :weight => 18}
order = {item: "Corn Flakes", weight: 18}
22. It was the best of times, it was the worst of times, it was the age of wisdom,
it was the age of foolishness, it was the epoch of belief, it was the epoch of
incredulity, it was the season of Light, it was the season of Darkness, it was
the spring of hope, it was the winter of despair, we had everything before
us, we had nothing before us, we were all going direct to Heaven, we were
all going direct the other way.
위 글은 Charles Dickens 명작인
<두 도시 이야기>의 오프닝 문단입니다.
Hash를 이용하여 각 단어별로
문단에 등장하는 빈도수를 출력하세요
hint: String 의 split 함수 활요