Write a program or function that checks if a variable name is valid and output 1 or
True if it is valid, 0.5 if it is valid but starts with an underscore (_), and 0 or
False if it is not valid.
- A variable name in most languages is valid if it begins with an underscore or letter (a-z, A-Z, _) and the rest of the characters are either underscores, letters, or numbers. (a-z, A-Z, 0-9, _)
- Output 1 or
Trueif the variable name is valid and 0 or
Falseif not valid.
- However, it is not good practice to start a variable with an underscore, so return 0.5 if it starts with an underscore and the name is valid.
0.5 (starts with an underscore)
0 (starts with a number)
0 (not 0.5 because it's not valid)
0 (no spaces)
Standard loopholes apply.
This is code-golf, so shortest code wins.
Bonus: -10% if your program/function outputs
0 for an empty string(