how to take an algebraic expression as an input from the user? e.g x^2 + sin(x) e.g. sin(x) +cos(x) something like that and solve for some value of x In Java, we use buffered reader and expression input functions, but in python3.x what I have to use?
Asked
Active
Viewed 41 times
-1
-
Possible duplicate of [User input and command line arguments](https://stackoverflow.com/questions/70797/user-input-and-command-line-arguments) – chevybow Apr 23 '19 at 21:10
-
Please edit to make your question more clear. – S.S. Anne Apr 23 '19 at 21:32
-
Does this answer your question? [How do I read from stdin?](https://stackoverflow.com/questions/1450393/how-do-i-read-from-stdin) – Karl Knechtel Feb 05 '23 at 12:39
1 Answers
0
You can use the input()
function in Python 3.
x = input()
print(x + " World")
>>> Hello
Hello World
x = input("Type a number: ")
print(int(x) * 2)
>>> Type a number: 5
10

theberzi
- 2,142
- 3
- 20
- 34