anonymous
  • anonymous
What are variables in python?Why are variables required?Does variables have a role to play in development of programs using python? what roles does it play?
MIT 6.189 A Gentle Introduction to Programming Using Python (OCW)
  • Stacey Warren - Expert brainly.com
Hey! We 've verified this expert answer for you, click below to unlock the details :)
SOLVED
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.
schrodinger
  • schrodinger
I got my questions answered at brainly.com in under 10 minutes. Go to brainly.com now for free help!
anonymous
  • anonymous
This is not really a Python question, it is more of a general computing question (ie you could substitute almost any programming language for Python). I think you want something like MIT Intro to CS and Programming http://www.youtube.com/watch?v=k6U-i4gXkLM (Includes intro to variables)
anonymous
  • anonymous
Offcourse!
anonymous
  • anonymous
Think of variables as a kind of box that you can put anything into. translate the symbol = in your mind into 'gets' so if you define a variable x like so: x = 10 means x gets the value 10 You could also put a line of text in there or even another variable! Youll find out if you do the course that using variables instead of just numbers is usefull for all kinds of neat things.

Looking for something else?

Not the answer you are looking for? Search for more explanations.

More answers

anonymous
  • anonymous
Just like variables are useful in math, it's more generic to compute on variables, they are useful in programming as well.
anonymous
  • anonymous
Because in Python, and programming generally, we need a place to keep our results for a while until we need them. Keep in mind that whatever you compute with a program, you lose it if you don't store it somewhere. So variables are just that. A way to store information so that you can use it later on in your program and thus they play a central role in development. Except for the case where you are doing something really simple, you will want to use variables to keep things. As you learn more about programming, you will understand this concept for yourself. Until then, here are some examples. Example 1 : Numerical Sequence Let's say that we write a program to compute a sequence of numbers up to a number N. The most famous is the fibonacci sequence for which we know that \[x_{n-1}+x_{n}=x_{n+1}, x_{0}=1=x_{1}\] To do that with a program, we need to store somewhere the two last values \[x_{n+1}, x_{n}\] so that we can use them to compute the next number. There is no way that we can continue calculating if we can't store the results somewhere. Example 2 : Generality of input Let's say that we want to write a program in Python to battle against internet trolls who write everything in CAPS. So, our program should take as input a phrase in caps and turn into something in lowercase. Since we are talking about a general phrase here, we have to store it somewhere so that then we can give it to the relevant function in Python. Example 3 : Ease of programming. Let's say that you have to solve the following problem in Python. a) Import the math library and compute the values of sine, cosine and tan at 18.849555921538759430775860299677017305183016396250634 Now there are of course many ways of solving this problem. Here's one : import math math.sin(18.849555921538759430775860299677017305183016396250634) math.cos(18.849555921538759430775860299677017305183016396250634) math.tan(18.849555921538759430775860299677017305183016396250634) and here's another one : import math x = 18.849555921538759430775860299677017305183016396250634 math.sin(x) math.cos(x) math.tan(x) The second way is easier to type, easier to read and has one more important advantage. It's general! Just change x and you have the values of functions wherever you like without having to change anything below that line. I hope those three examples illustrate, even slightly, how important variables are for programming. :)

Looking for something else?

Not the answer you are looking for? Search for more explanations.