first_name,Last_name=gets.chomp,gets.chomp is the correct way to get the input from the user.
True
False
View Answer
Correct Answer: A — True
Explanation:
It will take the input from user and store its value in the specified variables.
7 practice sets · Page 1 of 1
first_name,Last_name=gets.chomp,gets.chomp is the correct way to get the input from the user.
True
False
Correct Answer: A — True
Explanation:
It will take the input from user and store its value in the specified variables.
Why is gets not preferred instead of gets.chomp?
Gets add an extra new line while chomp removes it
Gets remove an extra new line
Chomp erases the value stored in the variable
All of the mentioned
Correct Answer: A — Gets add an extra new line while chomp removes it
Explanation:
gets.chomp will remove the extra blank space.
Which sequence can be used to substitute the value of any ruby expression in a string?
#(expr)
#{expr}
#expr
None of the mentioned
Correct Answer: B — #{expr}
Explanation:
#{expr} is valid.
For getting an input from the user which method is used?
get
gets.chomp
get-s
chomp
Correct Answer: B — gets.chomp
Explanation:
The method gets.chomp takes the input from the user.
We use semicolon or parentheses after every print or puts statement.
True
False
Correct Answer: B — False
Explanation:
No semicolon or parentheses is required.
Why is the library function 'puts'used for?
Prints whatever is given and print it to the screen
Prints whatever is given and insert a new(blank) line
Gets input from the user
None of the mentioned
Correct Answer: B — Prints whatever is given and insert a new(blank) line
Explanation:
Puts is a library function which prints and then insert a new blank line.
Which of the following is not a valid library function?
Puts
Gets
Get
Correct Answer: D — Get
Explanation:
gets is used for taking input from the user.