 If some one can answer me | Sololearn: Learn to code for FREE!

0

# If some one can answer me

In python String----> str and it for words etc Integer -----> int . And it for numbers Float ------> id True or False But what about + - * / How can we identify it in a console . Let's say a simple calculator. And we put num 1 and num 2 .what about operation How can we put it . ?

+1

Karim Karim x=int(input("enter first no.: ")) y=input('enter the arithematic operation (+,-,*,/): ') z=int(input('enter second no.: ')) if y=='-': print(x-z) elif y=='+': print(x+z) elif y=='*': print(x*z) elif y=='/': print(x/z) #you meant to make this? If yes, then don't use the user prompt if you are using it in sololearn (cuz its of no use), if you are going to paste it in pydroid then it's just right. (If you want to add any other operations, you can add more elifs🙂) edit]: you can take input as floats if you want (just change `int to float`)

+1

x = input("Enter the first number, operation and the second number(Example: 2+5 or 2-5 or 2*5 or 2/5): -> ") print(x, "=", eval(x))

+1

Bob_Li https://stackoverflow.com/questions/68418667/python-calculator-for-one-line-input

+1

Bob_Li, nice here are some other short codes too: https://code.sololearn.com/cKFn0kY2d3Xj/?ref=app https://code.sololearn.com/ck9rtCKNCAdK/?ref=app

+1

eval is evil...😈 But for simple practice, probably ok. Just don't use it for vulnerable situations. https://stackoverflow.com/questions/1832940/why-is-using-eval-a-bad-practice

0

The question is quite confusing. First, float is for numbers - True and False are booleans. Next, which console do you mean? Finally, what do you want to know about arithmetic operators?

0

Let's say . X = float ( input ()) Y = float (input()) Z = X + Y Print (Z) What if we want from the user to put the operator to calculate Z . Do u know what i mean?

0

Yes, I know. But I don't know what is the question. What's the difficulty on inputting the operator?

0

How we create a simple calculator 😂😂 ?

0

There are a million ways. A simple one is just inputting two numbers and an operator, then doing the requested calculation and printing the result. Go on code playground, start a code, link it inside the question with + buttom, and explain the difficulty.

0