Homework on Homeworks!
Respond to Discussion 150 words minimum
Variable and constant are two commonly used mathematical concepts. Simply put, a variable is a value that is changing or that have the ability to change. A constant is a value which remains unchanged. Even though the concepts are fundamental in many aspects of mathematics, in elementary levels, it is used in algebra predominantly. (Olivia 2012) If you think back to math in school and solving for "x", it was an undetermined number that could be anything until you complete the problem.
In my opinion with data types, those are already data values predetermined before you continue on, while a variable can still equal anything until it has guidelines. A good analogy for a variable is to think of a bucket. We can fill it to a certain level, we can replace what's inside it, and sometimes we can add or take something away from it. When we declare a variable to use a data type it's like putting a label on the bucket that says what it can be filled with. Let's say the label for the bucket is "Sand". Once the label is attached, we can only ever add or remove sand from the bucket. Anytime we try and put anything else into it, we will get stopped by the bucket police. (Leahy 2016)
A=3
B=4
print(a+b)
1. O. (2012). Difference Between Variable and Constant. Retrieved July 21, 2016, from http://www.differencebetween.com/difference-between-variable-and-vs-constant/
2. Leahy, P. (n.d.). How to Declare Variables in Java. Retrieved July 21, 2016, from http://java.about.com/od/understandingdatatypes/a/declaringvars.htm
Respond to discussion 150 words minimum
Within programming declaring constants and variables is a must. Its considered a best practice to use constants whenever possible. Within the possible thousands or even millions line of coding would you rather make small updates when necessary with few inputs or search the entire program making the correction? This is how constants help. A constant is a way to identify certain values which are used many times within a function (TechTerms, 2012). The constant itself does not change, hence constant. For example, if your max and min were set to 100 and 10, then your constants are max and min. If 100 was used instead of max, then you would have to change every single “100” in your code if you wanted something else. Instead, just entire a new line declaring what max equals, done. A variable is a symbolic name that represents data that may change but the operation to obtain that information does not (Utah, 2016). For example, a basketball player’s shooting percentage may change from game to game but the calculation stays the same, shots made divided by attempts. The variable is “Shooting Percentage = (calculation)” in the code. Data types are a set of information with values that has predefined characteristics, such as integer, floating point unit number, character, string, and pointer (TechTarget, 2005). These determine what can be done with the type of data. Example, “Hello” is a string data type and 1 + 1 is an integer. If you put the prentices around the equation the computer will treat it as a string and the calculation won’t occur, create an error. Identifying a variable is simple in python. As discussed prior, pick a title for the information represented and add an equal sign to that data and hit enter. Example, “made = 5”, “attempted = 10”, and “made/attempted”, after enter the program calculates .5. Also, you could represent made/attempted as “Shooting Percentage =” and type Shooting Percentage and .5 would populate.
Thanks for reading.
-Mark
References:
TechTarget (2005) Data Types. Retrieved from http://searchsoa.techtarget.com/definition/data-type
TechTerms (2012) Constants. Retrieved from http://techterms.com/definition/constant
University of Utah (2016) Variables. Retrieved from http://www.cs.utah.edu/~germain/PPS/Topics/variables.html