-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathloop.rb
More file actions
56 lines (43 loc) · 750 Bytes
/
loop.rb
File metadata and controls
56 lines (43 loc) · 750 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# while num <= 10
# print num
# num += 1
# end
# [1,2,3,4,5].each do |num|
# print num
# end
# for num in 1...10
# print num
# end
#Activity 1
arr = [1,3,5,7,9,11]
number = 3
arr.each do |num|
if number == num
print 'True'
end
end
# #Activity 2
x = gets.chomp.to_i
if x > 100
print "above 100"
elsif x <= 100 && x >= 51
print "51 - 100"
elsif x >= 0 && x <= 50
print "0 - 50"
else
print "Input is negative."
end
# #Activity 3
input = gets.chomp
while input != 'STOP'
input = gets.chomp
end
#Activity 4
arr = [6, 3, 1, 8, 4, 2, 10, 65, 102]
arr2 = []
arr.each do |num|
if num % 2 == 0
arr2 << num
end
end
print arr2