Quiz: Variable Naming

Rajasekaran E

Quiz 1

Which of the following is a valid variable name in R?

  • 2nd_value
  • total.value
  • mean-value
  • employee name

Quiz 2

You want to create a variable that stores the average temperature in Celsius. Which is the best name by R convention?

  • avg_temp_C
  • ATC
  • aTemp
  • temperatureInCelsius

Quiz 3

What will happen if you use a variable name like .hidden_data in R?

  • It will be treated as a global variable
  • It will throw an error
  • It will be ignored by default in listings like ls() and not displayed in Environment tab.
  • It will overwrite existing functions

Quiz 4

You’re analyzing employee satisfaction. You create a variable sat_Level. Later, a teammate uses Sat_Level in their script. What might go wrong?

  • Nothing, R is case-insensitive
  • The values will automatically match
  • It will throw an error because R does not allow duplicate variables
  • The script will treat them as different variables

Quiz 5

What happens when we run below code?
total income <- 50000

  • Variable total income will be created
  • It throws a syntax error
  • It assigns 50000 to both total and income
  • R asks to define income first

Quiz 6

You are naming a temporary counter inside a loop. Which of these is acceptable and follows R conventions?

  • i
  • count_1
  • loop.count
  • All of the options