anonymous
  • anonymous
Python programming: How would I plug in many different values for variables in an equation and have the program return the answer?
Computer Science
  • 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.
jamiebookeater
  • jamiebookeater
I got my questions answered at brainly.com in under 10 minutes. Go to brainly.com now for free help!
anonymous
  • anonymous
You definitely want to use a loop. Either a for loop or while loop would do the trick. Each time the program goes through the loop, have it change the value of a variable. Then, before moving to the next iteration of the loop, have it test the value of the variable using something like an if statement. Conditions of the if statement(s) could tell the program to keep looping and trying new variables if it doesn't get the desired result or to stop and print or return an answer if it does get the desired result. I hope this helps in general. I'd be happy to give you more tips if you want to share more specifics about what you'd like the program to do. I'm learning, too, but I have had a lot of success with writing out what I'd like the program to do in regular words and then converting them to the appropriate code!
anonymous
  • anonymous
To expand slightly on JonathanFichters answer, you may want to consider whether you need to use a list or dicionary, as a way of holding all the different variables or just a range if they are consecutive or stepped numbers.
carlsmith
  • carlsmith
Build a list of values then iterate across it with the for statement: the_list = [1, 2, 3, 401, 55.006] for n in the_list: print n * 2

Looking for something else?

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

More answers

anonymous
  • anonymous
Thank you all!

Looking for something else?

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