What was the name again?

Categories: Tech, Education | Pubby Cash Received:  0 | Click to Award

Programming is fun, but it isn't fun when you forget or confuse your variables. It’s annoying to have to remember so many similarly-named variables. “User”, “user”, “users”, all have the same spelling, but their values are different. But how do I know that? Usually, a capital letter at the start of a variable indicates that a variable is an object. Use plural nouns for lists, tuples, and dictionaries because they store multiple values. Singular nouns are used for a single value such as “5” or “Pubby”. Don’t be afraid to make your variable name long because most IDE’s have autofill. Name variables according to the type of data that it will store. For example, you would store “8” in the variable “number”, but you wouldn’t store “8” in “first_names”. Variables names must start with a letter or an underscore, and the remainder of your variable name may consist of letters, numbers, and underscores. Also, avoid using the lowercase letter "l", uppercase, "O" and uppercase ‘I’. Why? Because the "l "and the "I" look a lot like each other and number 1. And "O" looks a lot like "0". Knowing how to skillfully name and use your variables will seem like a life hack, or at least a programming hack!


Published from: Pennsylvania US
Liked by: H2O, Evan Tang 

Daily Deals


MECHANICSBURG WEATHER