- 1

Facing problem in some places

I have inserted the code, and added the Problems as #comment. Check it and make the corrections. https://code.sololearn.com/cE8d7gvX0hCY/?ref=app

24th Apr 2020, 4:30 AM
Surojit Mondal
Surojit Mondal - avatar
5 Respuestas
+ 4
1. quit operation doesn't work because you convert user input to float. It will be an error if you convert string 'quit' to floating point number. Store user input as string, check it for 'quit' and then convert it to a float: #..... num_1 = input('Enter a number') num_2 = input('Enter another number') user_input = input('Enter +/-/*/÷/^/sqrt: ') if user_input == 'quit' or num_1 == 'quit' or num_2 == 'quit': break num_1 = float(num_1) num_2 = float(num_2) if user_input == '+': #..... 2. power and sqrt don't work because condition on line #27 is always evaluated as true. It should be: elif user_input == '÷' or user_input == '/': 3. sqrt(num_1 and num_2) - the result will be sqrt(num_2) if num_1 is not zero, otherwize 0. You can't take square root of two numbers. Here should be your decision what to do with two numbers (take sqrt of both numbers separately or ignore num_2...)
24th Apr 2020, 5:57 AM
andriy kan
andriy kan - avatar
+ 3
I fixed the errors and slightly modified your code: https://code.sololearn.com/cWtKAZu3u1yj
24th Apr 2020, 9:15 AM
andriy kan
andriy kan - avatar
+ 3
Did you mean {} brackets? It's placeholder. format() method replaces it with its argument which is 'result'. Read about output formatting. https://docs.python.org/3/tutorial/inputoutput.html
24th Apr 2020, 12:27 PM
andriy kan
andriy kan - avatar
0
Thanx alot. Now its working fine. But what is the function of 2nd bracket in result?
24th Apr 2020, 11:39 AM
Surojit Mondal
Surojit Mondal - avatar
- 1
Please make correction to hole code, its a humble request to you sir/mam. I am a beginner and I would like to learn from your corrected code.
24th Apr 2020, 7:27 AM
Surojit Mondal
Surojit Mondal - avatar