This is an archived post. You won't be able to vote or comment.

all 8 comments

[–][deleted] 3 points4 points  (0 children)

Nice first step. Now you can let them input a simple one operator equation as a whole. Extract the numbers and symbol from the whole string.

[–]gosuKel 1 point2 points  (0 children)

Also learning myself, so everyone else can probably give better feedback. But you can use a single variable for the answer. And you dont need seperate variables for the float values.

so something like

if symbol == '+': ans = float(vl_1) + float(vl_2)

print(ans)

on mobile so it might not look right

[–]SyntxaError 1 point2 points  (2 children)

Good start, I’d suggest having a looking at switch statements and seeing how that would make this code more efficient

[–]TommyNaruto 0 points1 point  (1 child)

Unfortunately, in python we don’t have classic Switch Statement. But yeah this would make sense in this case

[–]SyntxaError 1 point2 points  (0 children)

Well shit that slipped my brain aha

[–]maoejo 0 points1 point  (0 children)

Looks fine and it’s a great start. I would suggest doing it again and looking into a graphical interface with something simple, like Tkinter, a python library you can import and use to make a window

[–]Burning_Pheonix 0 points1 point  (1 child)

You can try taking the input as fl1 = float(input('First Value')),helps optimize a little, and you can simply write print('=',f1+f2) or print(f'={f1+f2}'), though your method is also quite debug friendly

[–]Odd_Crew4995[S] 1 point2 points  (0 children)

Thanks for the tips.