Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialAlex Crump-Haill
7,819 Points# how would you use algebraic variables to solve equations in python?
Hello all, thank you (advanced python users) for offering help when I have had some very basic problems in the past. This one is more general but @kennethlove talks in this video about how you can't combine strings and integers in python which makes sense. E.g. if you were to try and combine: str + int = SyntaxError. Equally a variable_name = 'variable value' (be it string or integer). However, if you wanted to try and do algebra in python (5x) how would you actually do it?
1 Answer
Nikolai Montesclaros
11,928 PointsNormally algebraic expressions are not written as how you'd express them in math class but it's quite similar. You would just explicitly write them out as how you'd solve them.
Algebraic Expression: F(x) = 5x
Code Form:
def F(x):
return 5 * x