Added some python projects

This commit is contained in:
plane000
2018-05-04 17:53:55 +01:00
parent 5c0772fea7
commit 452be24a19
8 changed files with 71 additions and 0 deletions

View File

@@ -0,0 +1,12 @@
import random
target = 'Hello World!'
testString = ''
while testString != target:
testString = ''
for i in range(12):
testString += chr(random.randint(32, 126))
print(testString)
print(testString)

Binary file not shown.

59
Python/Quadratics.py Normal file
View File

@@ -0,0 +1,59 @@
from cmath import sqrt
a = ''
b = ''
c = ''
success = False
while success == False:
try:
a = float(input("a: "))
success = True
except:
print("That is not a number")
success = False
while success == False:
try:
b = float(input("b: "))
success = True
except:
print("That is not a number")
success = False
while success == False:
try:
c = float(input("c: "))
success = True
except:
print("That is not a number")
bn = -b
s1 = b ** 2
s2 = 4 * a * c
discriminant = sqrt(s1 - s2)
dinom = 2 * a
if discriminant == 0:
neum = bn + discriminant
root = neum1 / dinom
root = root.real
print("Root: ", root)
else:
neum1 = bn - discriminant
neum2 = bn + discriminant
root1 = neum1 / dinom
root2 = neum2 / dinom
root1 = root1.real
root2 = root2.real
print("Root 1: ", root1)
print("Root 2: ", root2)