first_name,Last_name=gets.chomp,gets.chomp is the correct way to get the input from the user.
True
False
Answer and explanation
It will take the input from user and store its value in the specified variables.
ObjectiveMcq
Print Protected
This page is protected for print. Use the website to view the content.
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
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
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
#{expr} is valid.
For getting an input from the user which method is used?
get
gets.chomp
get-s
chomp
The method gets.chomp takes the input from the user.
We use semicolon or parentheses after every print or puts statement.
True
False
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
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
gets is used for taking input from the user.