logo codesdope

Practice questions on puts and print

Level 1

1.

Print anything you want on the screen.

puts "I want to be a programmer"

2.

Store three integers in x, y and z. Print their sum.

x = 10
y = 15
z = 20
puts "#{x+y+z}"

3.

Store three integers in x, y and z. Print their product.

x = 5
y = 10
z = 20
puts "#{x*y*z}"

4.

Check class of following:
"CodesDope"
15
16.2
9.33333333333333333333

puts "CodesDope".class
puts 15.class
puts 16.2.class
puts 9.33333333333333333333.class

5.

Join two string using '+'.
E.g.-"Codes"+"Dope"

puts "Codes"+"Dope"

Level 2

Level 3

Close

Welcome.please sign up.

Close

Welcome.please login.