New course! Every coder should learn Generative AI!
Try a free lesson+ 2
Problem with Faulty Calculator exercise [Solved]
The program is faulty calculator. In this except three particular calculations rest all calculations should be correct. In this code everything was alright until I wrote the second set of if else statements. My faulty calculator completely got faulty😶 https://code.sololearn.com/cbOlcDLk8S6v/?ref=app
5 Answers
+ 2
Which if...elif block?
One that begins from line 8, or one that begins from line 18?
What are you doing with if...elif from line 18 anyways?
+ 3
∆BH∆Y
If you are Good debugger then you are a good programmer.
You need to read all the error or Exception and solve one by one
+ 3
Below is a layout for the multiplication aspect of your code.
Use it to finish the rest of your code.
May I suggest you test aspects of your code as you write it, to prove that each new concept actually works.
Your original code is riddled with flaws, so quite difficult to debug.
Code
calc_type = input()
num1 = int(input())
num2 = int(input())
if calc_type == "Multiply" or calc_type == "Multiplication":
if (num1 == 45 and num2 == 3) or (num1 == 3 and num2 == 45):
print(555)
else:
print(num1 * num2 )
+ 2
try fix ur code indentation..seems like that cause the error
another thing, ur code actually will only run multiplication
note that
if type_calc == 'Multiplication' or 'Multiply' is not same as
if type_calc == 'Multiplication' or type_calc=='Multiply'
the first one is always true in python
+ 2
Thank you all of you