Author: admin
what is mysql full form
write a program to print pyramid pattern in python
# python code to print pyramid pattern in python
def pyramid(n):
k = n - 1
for i in range(0, n):
for j in range(0, k):
print(end=" ")
k = k - 1
for j in range(0, i+1):
print("* ", end="")
print("\r")
n = 5
pyramid(n)
Output
*
* *
* * *
* * * *
* * * * *
How to check whether a file exists or not without exceptions in python ?
It is easy to check whether a file exists or not without exceptions in python ,python has a familiar os.path module using this module you can run isfile ,if it return True means a file exists or if it is False means file not exists
Code to check whether a file exists or not without exceptions in python
import os.path os.path.isfile(FILE_PATH) e.g >>> os.path.isfile("/home/index.html") True >>> os.path.isfile("/home/index_new.html") False