- 3
Plz..help me
Enter two integers and operators from the user and create a program that corresponds to the operator you entered. (You create a program to calculate any of the operators (+,-,*) that are entered.) integer input:5 operator input:+ integer input:3 5+3=8
43 ответов
+ 2
Hi i
Take inputs with separate lines like this:
5
+
3
SoloLearn support all inputs together only once
+ 1
Your try?
+ 1
Oh, it's done! Thank you.
0
If you show your try then I will ..
0
You have already got your answer here
https://www.sololearn.com/Discuss/3007740/?ref=app
0
but the answer is wrong..
0
Please refrain from re-posting similar question. If you have a doubt, then you can confirm with the people who contributed answers in your post rather than reposting.
https://www.sololearn.com/Discuss/3007740/?ref=app
0
Hi i
Do you expect only 8 or 5 + 3 = 8?
0
Yes
0
Hi i
What yes?
8 or 5 + 3 = 8
0
5+3=8
0
Then this is right solution which was in previous question
----------
num1 = input("")
operator = input("")
num2 = input("")
print((num1 +operator+ num2 +"=")+str(int(eval(num1 +operator+ num2))))
0
but
Traceback (most recent call last):
File "file0.py", line 2, in <module>
b= input("+")
EOFError: EOF when reading a line
It comes out like this.
0
Hi i
Don't write + inside input function
Try this code:
------
num1 = int(input())
operator = input()
num2 = int(input())
print((str(num1) + operator + str(num2) + "=")+ str(int(eval(str(num1) + operator + str(num2)))))
0
Okay
0
The error keeps popping up…
0
Hi i
Show how did you write code? And how did you take inputs?
Take screenshot upload in Feed Posts and share the link here.
0
a=int(input("5"))
b=input("+")
c=int(input("3"))
print(str(x)+y+str(z)+"=")+str(int(eval(str(x)+y+str(z))))
Write this..
0
a=int(input())
op=input()
b=int(input())
if op == '+' :
print("a + b =", a+b)
# you can continue this with elseif to make remaining operations.. hope it helps.
edit: Hi i
x=int(input())
y=input()
z=int(input())
print((str(x)+y+str(z)+"=")+str(int(eval(str(x)+y+str(z)))))
#you are taking input to a, b, c but using x, y, z
0
Hi i
I already told don't write anything inside input function.
And please copy my code and take input like:
5
+
3
Now press enter