0
I dont understand what is wrong with my calculator
I created a calculator in python, its in my profile. Its in greek but you can easily recognize the operators.
15 Answers
+ 3
Code Playground does not allow interactive input. All input must be given upfront, before running the code.
See this code to understand how input is handled in Code Playground
https://code.sololearn.com/WhiNb9BkJUVC/?ref=app
+ 3
It is not an issue, there's nothing to fix. It is because your code requires input repetitively, until it reads "skata" which breaks the loop. So each operation requires 3 lines in input dialog. For example:
sin
10
5
plin
10
5
skata
This will sum 10 and 5, subtract 10 and 5 and exit.
You really need to see the code I attached earlier to understand how input works.
+ 2
Move line 2 - 7 out of the loop if you want to see it only once. Don't forget to adjust the indentation proportionally.
+ 1
Line 20, change num to num1. num is unknown.
See the code I attached to understand how to give input š
+ 1
I don't see any problem at line 8, can you describe what error you get? I would assume it was EOFError which was triggered by your code's design, which requires user input interactively.
There's a problem at line 31, because <result> is a float and not a string. I would recommend to use comma when printing output. No problem with different types when comma is used to print multiple stuffs.
So instead of š
print("i apantisi einai" + result)
Using + like this, <result> needs to be converted to a string first,
But if you do
print("i apantisi einai", result)
Using comma like this, no conversion of <result> is necessary.
+ 1
num1=float(input("grapse arithmo:"))
print(num1)
num2=float(input("grapse akoma ena:"))
print(num2)
You only need to explicitly print the input in SoloLearn, it's not necessary if you run the code on console, as the input we type in is fed through by pressing Enter key, which inserts a new line.
0
Ipang can you check out my code, cause i havent figured out what i did wrong, or what i should put in the input
0
Ipang thanks for line20 , apparantly there is another problem in line 8 which i cant figure out
0
Ipang thanks for the suggestion of comma. And yes, line 8 always brings an ELFError, can we fix that?
0
Ipang aha. So i need to break my calculator with skata each time. Last question , why do the 4 sentences of (vale sin gia na prostheseis etc..) show up double? If you pay attention, there are 4 sentences, then my result, and then they get printed again
0
Ipang i removed the spaces from 2-7 but there is an error in line 2
0
I meant to say that line 2 - 7 needs to be moved up, before the line `while True:`
0
Ipang thanks it works. How do i put "grapse enan arithmo" "grapse akoma ena" in separate lines. Do i put \n ?
0
Line 20 is the error