0
0
Rubyprogramming~10 mins

Local variables and naming conventions in Ruby - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to assign the value 10 to a local variable named count.

Ruby
count = [1]
Drag options to blanks, or click blank then click option'
ACount
B"10"
Cten
D10
Attempts:
3 left
💡 Hint
Common Mistakes
Using quotes around numbers, which makes them strings.
Starting variable names with uppercase letters, which makes them constants.
2fill in blank
medium

Complete the code to print the value of the local variable named total.

Ruby
total = 25
puts [1]
Drag options to blanks, or click blank then click option'
Atotal
BTotal
C"total"
DTOTAL
Attempts:
3 left
💡 Hint
Common Mistakes
Using uppercase letters which refer to constants, not local variables.
Using quotes which print the string instead of the variable's value.
3fill in blank
hard

Fix the error in the code by completing the variable name correctly.

Ruby
user_name = "Alice"
puts [1]
Drag options to blanks, or click blank then click option'
AUserName
BuserName
Cuser_name
Dusername
Attempts:
3 left
💡 Hint
Common Mistakes
Changing the case or removing underscores from variable names.
Using camelCase instead of snake_case for local variables.
4fill in blank
hard

Fill both blanks to create a local variable named age and assign it the value 30.

Ruby
[1] = [2]
Drag options to blanks, or click blank then click option'
Aage
B30
C"30"
DAge
Attempts:
3 left
💡 Hint
Common Mistakes
Using uppercase letters for variable names.
Putting numbers inside quotes, making them strings.
5fill in blank
hard

Fill all three blanks to create a local variable named full_name and assign it the string "John Doe".

Ruby
[1] = [2] + " " + [3]
Drag options to blanks, or click blank then click option'
AFullName
B"John"
C"Doe"
Dfull_name
Attempts:
3 left
💡 Hint
Common Mistakes
Using uppercase letters for variable names.
Forgetting quotes around strings.
Not adding spaces between names.