Question

In: Computer Science

1. Any “case” statement can be written as an “if” statement. True False 2.How many iterations...

1. Any “case” statement can be written as an “if” statement.

True
False

2.How many iterations does the following “loop” statement have?

n = 1 
loop do
    n = n + 1
    puts “hey"
    next unless n = 10
    break
end
0
7
This loop is syntactically incorrect.
9
8

3.The following two conditional expressions are equivalent outcome wise:

n = 1
begin 
    puts n 
end while n < 1
n = 1
while n < 1
    puts n
end
True
False

4.Which one of the following is NOT a Ruby Exception?

TypeError
NoMethodError
IOError
None of the choices.
ArgumentError
RuntimeError

5.In Ruby, you can raise predefined exceptions or create your own in code with the “rescue” keyword.

True
False

6.Which of the following is not a valid keyword in Ruby?

yield
in
until
unless
each
next
stop

Solutions

Expert Solution

1)True

Any case can be written using if statements

2)This loop is syntactically incorrect.

next unless n==10 is correct

when n==10 is used

9 hey are printed

3)False

first expression prints 1 second expression prints nothing.

4)None of the choices.

All the errors mentioned are present.

5)True

6)stop

all other keyword are present in ruby.


Related Solutions

2) True or False (If statement is false, correct it so that it is true) a)...
2) True or False (If statement is false, correct it so that it is true) a) Polymers make up an exciting class of biomaterials. Polyethylene is a wonderful example of a simple ceramic that can be used in multiple applications by modifying its chemical structure. It tends to be bioactive when used by itself as an implant, but it becomes even more bioactive when 10 vol% Calcium Carbonate is added to it. Teflon can be used as a vascular graft...
TRUE/FALSE. Write 'T' if the statement is true and 'F' if the statement is false. 1)...
TRUE/FALSE. Write 'T' if the statement is true and 'F' if the statement is false. 1) Accounting is an information system that identifies, measures, records and 1) communicates relevant information that objectively and correctly represents an organization's economic activities. 2) The main objective of accounting is to help people to invest in new products and 2) businesses. 3) A sole proprietorship is a business owned by one or more persons. 3) 4) Unlimited liability is an advantage for both a...
Question1: How many of the 5-digit numbers that can be written with the numbers 1, 2,...
Question1: How many of the 5-digit numbers that can be written with the numbers 1, 2, 3, 4 contain both numbers 1 and 2? question2: 3 married couples shown as a1a2, b1b2, c1c2 want to sit in a row. How many different ways can these married couples sit in a row, without a husband and a wife from the same couple coming together?
1) CD8+ Tc cells can be activated by any pAPC.  a. True b. False 2. licensing of...
1) CD8+ Tc cells can be activated by any pAPC.  a. True b. False 2. licensing of dendritic cells requires interactions with Th cells. a. True b. False 3. the message coding for the TCR can be alternatively spliced to create two different forms of the receptor. a. True b. False 4. by the time a DN thermocyte reaches the thymus it is commited in fate to become either a Th1 cell or a Th2 cell. a. True b. False 5....
True and False True/False Write True or False before the statement. 1. Gypsum is the brand...
True and False True/False Write True or False before the statement. 1. Gypsum is the brand name for sheetrock. 2. Coreboards and liner boards come in 2-foot widths. 3. Adhesives are not used for bonding gypsum board directly to supports. 4. Supplemental fasteners should be used with contact adhesives. 5. Gypsum panels are applied first to ceilings and then to the walls. 6. The floating angle method of drywall application omits fasteners in the corner intersection of the ceilings and...
. True or false? (1) There is at most one pivot in any row. (2) There...
. True or false? (1) There is at most one pivot in any row. (2) There is at most one pivot in any column. (3) There is at least one pivot in any row. (4) There is at least one pivot in any column. (5) There cannot be more free variables than pivot variables. (6) There is a linear system that has exactly two solutions. (7) The weights c1, ..., cp ? R in a linear combination c1v1 + ......
Please write “true” if the statement is true and “false” is the statement is false in...
Please write “true” if the statement is true and “false” is the statement is false in the space provided: ______ 1. A statistical hypothesis test tests the null hypothesis rather than the researcher’s hypothesis ______ 2. In most research situations, the goal is to reject the researcher’s hypothesis ______ 3. A decision to reject the null hypothesis means that the data do provide evidence of a treatment effect: the independent variable did have an effect on the dependent variable ______4....
Are the following statements true or false? 1. Let P(n) be the statement "If any string...
Are the following statements true or false? 1. Let P(n) be the statement "If any string of length n over {a, b} has more a's than b's, then it has two a's in a row". We can prove this statement is true for all n with n ≥ 2 by proving P(2), P(3), and "for all n: P(n) → P(n+2)". 2. Let P(x) be a predicate with one free variable x of type natural. If I prove P(0), "for all...
TRUE/FALSE.Write'T'if the statement is true and 'F' if the statement is false ) . 1) Flexible...
TRUE/FALSE.Write'T'if the statement is true and 'F' if the statement is false ) . 1) Flexible budgets reflect a company's anticipated costs based on variations in activity levels. 2) Both normal- and standard- costing systems use a predetermined overhead rate. 3) Efficient or inefficient use of a specific component of variable overhead(e.g.,electricity)will cause the firm to have a variable-overhead efficiency variance. 4) The activity-based flexible budget provides a more accurate benchmark against which to compare actual costs than does a...
1. The statement of financial position is another name for the income statement True False 2....
1. The statement of financial position is another name for the income statement True False 2. The income statement only statement dated as of a point in time. True False 3. Assets and liabilities come into existence at different times and are not affected the same way by inflation and specific price level changes True False 4. For the purposes of the balance sheet preparation, there are several different measurement bases are used (historical cost, depreciated historical cost, market value,...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT