A community for students. Sign up today!
Here's the question you clicked on:
 0 viewing
 2 years ago
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?
 2 years ago
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?

This Question is Open

estudier
 2 years ago
Best ResponseYou've already chosen the best response.0This 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=k6Ui4gXkLM (Includes intro to variables)

bartbisschops
 2 years ago
Best ResponseYou've already chosen the best response.2Think 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.

jhmroes
 2 years ago
Best ResponseYou've already chosen the best response.0Just like variables are useful in math, it's more generic to compute on variables, they are useful in programming as well.

arkanoid
 2 years ago
Best ResponseYou've already chosen the best response.1Because 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_{n1}+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. :)
Ask your own question
Ask a QuestionFind more explanations on OpenStudy
Your question is ready. Sign up for free to start getting answers.
spraguer
(Moderator)
5
→ View Detailed Profile
is replying to Can someone tell me what button the professor is hitting...
23
 Teamwork 19 Teammate
 Problem Solving 19 Hero
 Engagement 19 Mad Hatter
 You have blocked this person.
 ✔ You're a fan Checking fan status...
Thanks for being so helpful in mathematics. If you are getting quality help, make sure you spread the word about OpenStudy.