def squareRoot(n):
x = n
y = 1
e = 0.000001
while (x - y > e):
x = (x + y) / 2
y = n/x
return x
def findMaximumHeight(N):
n = 1 + 8*N
maxh = (-1 + squareRoot(n)) / 2
return int(maxh)
N = 12
print(findMaximumHeight(N))
Solve Problems by Coding Solutions - A Complete solution for python programming
def squareRoot(n):
x = n
y = 1
e = 0.000001
while (x - y > e):
x = (x + y) / 2
y = n/x
return x
def findMaximumHeight(N):
n = 1 + 8*N
maxh = (-1 + squareRoot(n)) / 2
return int(maxh)
N = 12
print(findMaximumHeight(N))
import math
def productPrimeFactors(n):
product = 1
if (n % 2 == 0):
product *= 2
while (n%2 == 0):
n = n/2
for i in range (3, int(math.sqrt(n)), 2):
if (n % i == 0):
product = product * i
while (n%i == 0):
n = n/i
if (n > 2):
product = product * n
return product
n = 44
print (int(productPrimeFactors(n)))
import numpy as np
arr = [[14, 17, 12, 33, 44],
[15, 6, 27, 8, 19],
[23, 2, 54, 1, 4,]]
print("\narr : \n", arr)
print("\n50th Percentile of arr, axis = None : ",
np.percentile(arr, 50))
print("0th Percentile of arr, axis = None : ",
np.percentile(arr, 0))
print("\n50th Percentile of arr, axis = 0 : ",
np.percentile(arr, 50, axis =0))
print("0th Percentile of arr, axis = 0 : ",
np.percentile(arr, 0, axis =0))
import turtle
screen=turtle.Screen()
screen.setup(800,800)
trtl = turtle.Turtle()
screen.title("3-D CUBES")
trtl.penup()
trtl.setposition(0,0)
trtl.setheading(90)
trtl.color('red')
def hexagon():
for i in range(6):
trtl.fd(50)
trtl.rt(60)
i = 1
while i < 7:
trtl.pendown()
hexagon()
trtl.right(60)
i = i + 1
import re
def isValidURL(str):
regex = ("((http|https)://)(www.)?" +
"[a-zA-Z0-9@:%._\\+~#?&//=]" +
"{2,256}\\.[a-z]" +
"{2,6}\\b([-a-zA-Z0-9@:%" +
"._\\+~#?&//=]*)")
p = re.compile(regex)
if (str == None):
return False
if(re.search(p, str)):
return True
else:
return False
url = "https://www.pythonforengineers.in"
if(isValidURL(url) == True):
print("Yes")
else:
print("No")