We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent a15c1c0 commit 320e2a6Copy full SHA for 320e2a6
Beginner_Level_Python_programs/quadratic_root.py
@@ -0,0 +1,17 @@
1
+# Solve the quadratic equation ax**2 + bx + c = 0
2
+
3
+# import complex math module
4
+import cmath
5
6
+a = 1
7
+b = 5
8
+c = 6
9
10
+# calculate the discriminant
11
+d = (b**2) - (4*a*c)
12
13
+# find two solutions
14
+sol1 = (-b-cmath.sqrt(d))/(2*a)
15
+sol2 = (-b+cmath.sqrt(d))/(2*a)
16
17
+print('The solution are {0} and {1}'.format(sol1,sol2))
Beginner_Level_Python_programs/square_root.py
@@ -0,0 +1,10 @@
+# Python Program to calculate the square root
+# Note: change this value for a different result
+num = 8
+# To take the input from the user
+#num = float(input('Enter a number: '))
+num_sqrt = num ** 0.5
+print('The square root of %0.3f is %0.3f'%(num ,num_sqrt))
0 commit comments