Python novice's calculator This is my first ever project I've coded in Python so I'm sorry if it's a little novice. I'm just looking for beginner feedback on what I could improve next time.

There is one issue with this calculator: let's say I add 1 and 2, I expect to get 3, instead it returns 3.0, but I'm guessing that's because I'm casting to a float.

The reason I'm casting to a float is to accept decimals in the equation. It would be nicer if it displayed the whole number without the .0

while True:
    calculation = input("Calculation: ")

    if (calculation.__contains__("+")):
        print(float(calculation.split('+')[0]) + float(calculation.split('+')[1]))

    elif (calculation.__contains__("-")):
        print(float(calculation.split('-')[0]) - float(calculation.split('-')[1]))

    elif (calculation.__contains__("*")):
        print(float(calculation.split('*')[0]) * float(calculation.split('*')[1]))

    elif (calculation.__contains__("/")):
        print(float(calculation.split('/')[0]) / float(calculation.split('/')[1]))
Pythons magic methods are there to make your life easier, not harder. They allow custom classes to use built-in functionality. They are not there so you have to use long names with built-in types. 

The __contains__ method is called under the hood whenever you use the in keyword. 

In addition, you do the same thing for all four operations: See if it is present, split by the operator and apply it. This can be simplified using a loop over a dictionary, mapping the string of the operator to the operator itself (using the operator module which gives you functions for most operations).

And so your code can be simplified to:

import operator

OPERATIONS = {"+": operator.add,
              "-": operator.sub,
              "*": operator.mul,
              "/": operator.div}

while True:
    calculation = input("Calculation: ")
    for name, op in OPERATIONS.items():
        if name in calculation:
            a, b = map(float, calculation.split(name))
            print(op(a, b))


And at that point you should ask yourself how to modify this to allow multiple operations or even grouping expressions with parenthesis.

You should also probably add some error handling (what happens if the user tries to enter multiple operations? What happens if they do not enter a number?).