EXP Py
EXP Py
def greeting(name):
print ("Hello,+name")
import mymodule
mymodule.greeting("Viya")
OUTPUT:
Hello,Viya
EXP-10 B CREATE AND IMPORT PACKAGES
1. CREATE A FOLDER
2. CREATE ANOTHER FOLBER INSIDE PA
3. CREATE TWO FOLDER INSIDE VEXP AS_INIT_PY AND GREETING.PY
4. OPEN IDLE,AND OPEN GREETING.PY AND TYPE A FUNCTION
5. CREATE ANOTHER FOLDER INSIDE PA AS HEY.PY
CODE:
#inside greeting.py
Def great():
Print(‘hello’)
#inside hey.py
X=greeting.great()
Print(X)
OUTPUT:
Hello
none
#write a python program to implement numpy statistical
functions(mean,median,mode)
#applying mean
import numpy as np
a=np.array([[30,40,50],[80,60,20],[60,40,90]])
print(a)
print("\n")
print(np.mean(a))
print("\n")
OUTPUT:
our array is
[[30 40 50]
[80 60 20]
[60 40 90]]
52.22222222222222
#applying median
import numpy as np
a=np.array([[30,40,50],[80,60,20],[60,40,90]])
print(a)
print("\n")
print(np.median(a))
print("\n")
OUTPUT:
our array is
[[30 40 50]
[80 60 20]
[60 40 90]]
50.0
#applying percentile
import numpy as np
a=np.array([[30,40,50],[80,60,20],[60,40,90]])
print(a)
print("\n")
print(np.percentile(a,40))
print("\n")
OUTPUT:
our array is
[[30 40 50]
[80 60 20]
[60 40 90]]
42.0
#write a python program to transpose a matrix
X= [[12,7],
[4,5],
[3,8]]
result=[[0,0,0],
[0,0,0]]
for i in range(len(X)):
for j in range(len(X[0])):
for r in result:
print(r)
OUTPUT:
[12, 4, 3]
[7, 5, 8]
import pandas
start_date="1/1/2023"
end_date="31/12/2023"
list_of_date=pandas.date_range(start=start_date, end=end_date)
df=pandas.DataFrame(list_of_date)
df.columns=["date/time"]
df["8:00"]=100
df["9:00"]=100
df["10:00"]=100
df["11:00"]=100
df["12:00"]=100
df["13:00"]=100
df["14:00"]=100
df["15:00"]=100
df["16:00"]=100
df["17:00"]=100
df.to_csv(
)
#write a python program to perform file operation
1. Read file
2. Write file
Here it comes,
Ready or not.
Summer’s coming,
READ A FILE
f=open(‘file.txt’, ‘r’)
print(f.read())
OUTPUT
Here it comes,
Ready or not.
Summer’s coming,
WRITE A FILE
f=open(“file.txt”, “w”)
f.write(“Nature is beautiful”)
f.close()
f=open(“file.txt”, “r”)
print(f.read())
OUTPUT
Nature is beautiful
#write a python program to integrate exception handelling
Try:
Print(x)
Except:
OUTPUT
An exception occurred