3.1.1 - What are variables
Sharon Kodali
Variables: an abstraction inside a program that can hold a value
A variable can be thought of as a container or a box that holds information that your program can use or modify
Variables help you manage and organize your work with data, making your code more organized, readable, and adaptable.
different data types to store variables in
- integer used to store numbers that can later be used in mathematical operations ex: age or temperature
- Text(string) Used to store texts lists and words that can later be referenced ex: Name, phone number, or address
- Boolean used to store simply of true or false ex: is it raining
Correct way to name variables
incorrect: my highs-coreinthegame or n
- too long and can make the code messy
- dashes are not allowed when naming variables
- spaces are not allowed when naming variables
- descriptive enough to easily recall what the variable repersents
correct: highscore or numstudents or israining
- short
- descriptive
- easy to distingush type of variable
3.1.1 Hacks
instructions: Determine what would be the the best variable name and data type for the specific prompt
- storing if someones pet is a dog
- storing someones birthday
- storing the amount of money someone is spending
- storing if it is sunny