0% found this document useful (0 votes)
7 views

Lap Python

Uploaded by

abubakaramin484
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

Lap Python

Uploaded by

abubakaramin484
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

lap-python

October 26, 2023

[11]: print("Noor")
print('757#############43n')
print('Hassan')

Noor
757#############43/n
Hassan

[47]: x=5
y=3
z=x+y
str='The result of sum is:'
print(str,z)
noor='The result of sum is:'
print(noor,z)
print(noor,'sum is:',z)

The result of sum is: 8


The result of sum is: 8
The result of sum is: sum is: 8

[39]: x0=4
x1=5.5
z1=x0+x1
z2=x0*x1
print(z1)
print(z2)
noorhassan='The result of sum is:'
print(noorhassan,z1)

9.5
22.0
The result of sum is: 9.5

[51]: if x<y:
print('x is great')
print('any instruction')
print(x)

1
elif x>y: #in this if true then print
print('y is greater')
else: #this will be exicuted if above is not true
print('y is greauuter')

y is greater

[48]: if x<y:
print('x is great')
print('any instruction')
print(x)
else:
print('y is greater')

y is greater

[71]: lst_=[2,5,9,3,'noor','hassan']
print(lst_)
print(lst_[4])
print(lst_[5])

[2, 5, 9, 3, 'noor', 'hassan']


noor
hassan

[76]: import numpy as np


lst1=[1,2,3,4]
lst2=[3,5,11,12]
lst3=lst1+lst2
print (lst3)
print(np.add(lst1,lst2))
print(np.dot(lst1,lst2))
print(2*lst2)

[1, 2, 3, 4, 3, 5, 11, 12]


[ 4 7 14 16]
94
[3, 5, 11, 12, 3, 5, 11, 12]

[78]: ary=np.array([3,4,5,6,7]) #np.array is always preferred than list


a1=np.array([4,5,6,7,8])
print(2*ary)

[ 6 8 10 12 14]

[79]: a=np.array([3,4,5,6,7]) #np.array is always preferred than list, array is a␣


↪function of numpy, there are alot functions of numpy

a1=np.array([4,5,6,7,8])

2
print(a*a1)
print(a+a1)

[12 20 30 42 56]
[ 7 9 11 13 15]

[85]: aa=np.array([[4,2,6,7,8],[3,4,5,6,7]]) #1st element #2 rows 5 columns


print(aa[0,1])

[86]: ar=range(0,10,2) #step size 2


for i in ar:
print(i)

0
2
4
6
8

[87]: arr=range(10) #last digit is not included


for i in arr:
print(i)

0
1
2
3
4
5
6
7
8
9

[88]: arrr=range(1,10) #last digit not included


for i in arrr:
print(i)

1
2
3
4
5
6
7
8

3
9

[94]: lst4=[3,4,5,9]
for x in lst4:
print(x**2) # ** use for power
print(pow(x,3))

9
27
16
64
25
125
81
729

[100]: lst5=[3,4,5,9] #to check even no. % is used for remainder


for s in lst5:
if s%2==0:
print(s)

[102]: lst6=[3,4,5,9] #to check odd no. % is used for remainder


for x in lst6:
if x%2!=0: # ! used for not equal
print(x)

3
5
9

[1]: import matplotlib.pyplot as plt


lst5=[3,4,5,9]
lst6=[3,4.5,10,15]
plt.plot(lst5,lst6)

[113]: def cube(x):


return x**3
print(cube(5))
a10=cube(5)
print(a10)
sum((a10,15))

125
125

[113]: 140

4
[ ]:

You might also like