• 3 Posts
  • 35 Comments
Joined 3 months ago
cake
Cake day: December 26th, 2024

help-circle


  • palmtrees2309@lemm.eetoLemmy Shitpost@lemmy.worldSpooky
    link
    fedilink
    English
    arrow-up
    38
    ·
    edit-2
    19 hours ago

    It’s more like 50% All this because billionare mukesh ambani gave away free 4G Internet via sim Cards and now that people are addicted, price tag is increasing everday.

    Traffic is becoming so big even the large corpo reddit is trying to appeal to indians. fyi Reddit announced it will be opening its HQ in banglore aka IT hub of India.

















  • After the split x becomes (1 and z becomes 1). They can’t be converted to float. I think that’s why. Let me run the code. Edit - Also as you are returning a, b, c from splitter but Python functions return a single object. The a, b, c turns to a tuple. But you are using js syntax I think. So we have to unwrap inside the calculate function.

    Now my original comment is not useful but you can try to introduce a conditional to check of the numbers x and z are actually numbers before converting to floats

    # Ask user to enter an expression and display output
    
    def main():
        expression = input("Expression: ")
        print(calculate (splitter (expression)))
    
    # Split expression into components and assign to variables as float values
    
    def splitter (expression):
        print(expression)
        x, y, z = expression.split()
        print(expression.split())
        return x, y, z
    
    # Calculate expression result
    
    # Changes Beginning
    def calculate(numbers):
        x,y,z = numbers
    # Changes End
    
        x, z = float(x), float(z)
        if y == "+":
            return str(round((x + z), 1))
        elif y == "-":
            return str(round((xz), 1))
        elif y == "*":
            return str(round((x*z), 1))
        else:
            return str(round((x / z), 1))
    
    main()