Python Forum
Thread Rating:
  • 3 Vote(s) - 4 Average
  • 1
  • 2
  • 3
  • 4
  • 5
unexpected output
#1
Dear Python Experts,

I am pretty new to programming, thus please help me with the following code:


import math

def quadratic_formula(a, b, c):
    ans1 = (-1 * b + math.sqrt(b ** 2 - 4 * a * c)) / (2 * a)
    ans2 = (-1 * b - math.sqrt(b ** 2 - 4 * a * c)) / (2 * a)
    print ("Answers are %.2f and %.2f" % (ans1, ans2))
    
    print ("Quadratic Formula Program")
    a = int(input("Please input a: "))
    b = int(input("Please input b: "))
    c = int(input("Please input c: "))
    quadratic_formula(a,b,c)
However, when I run it there is nothing appeared on console. Please, can you tell me where is my mistake?
Reply
#2
You never run the code!

remove indentation from :
print ("Quadratic Formula Program")
a = int(input("Please input a: "))
b = int(input("Please input b: "))
c = int(input("Please input c: "))
quadratic_formula(a,b,c)
Reply
#3
Thank you!
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Unexpected output Starter 2 482 Nov-22-2023, 12:08 AM
Last Post: Starter
  Unexpected Output - Python Dataframes: Filtering based on Overlapping Dates Xensor 5 707 Nov-15-2023, 06:54 PM
Last Post: deanhystad
  Unexpected output while using random.randint with def terickson2367 1 511 Oct-24-2023, 05:56 AM
Last Post: buran
  Unexpected output from df.loc when indexing by label idratherbecoding 6 1,190 Apr-19-2023, 12:11 AM
Last Post: deanhystad
  unexpected output asyrafcc99 0 1,503 Oct-24-2020, 02:40 PM
Last Post: asyrafcc99
  Unexpected output: symbols for derivative not being displayed saucerdesigner 0 2,049 Jun-22-2020, 10:06 PM
Last Post: saucerdesigner
  Unexpected output palladium 4 2,750 Jan-11-2020, 03:26 PM
Last Post: palladium
  Unexpected output: if statement CabbageMan 1 1,764 Sep-04-2019, 04:12 PM
Last Post: ThomasL
  Unexpected Output using classes and inheritance langley 2 1,947 Jul-04-2019, 09:33 AM
Last Post: langley
  float multiplication - unexpected output inesk 3 3,333 Dec-11-2018, 10:59 AM
Last Post: DeaD_EyE

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020