Download as pdf or txt
Download as pdf or txt
You are on page 1of 1

In 

[5]:
l1=[4,5,315,61]

In [6]:
if (l1[0]>l1[1]) & (l1[0]>l1[2]) & (l1[0]>l1[3]):

print(l1[0],"value is greatest")

elif (l1[1]>l1[0]) & (l1[1]>l1[2]) & (l1[1]>l1[3]):

print(l1[1],"value is great")

elif (l1[2]>l1[0]) & (l1[2]>l1[1]) & (l1[2]>l1[3]):

print(l1[2],"value is greatest")

else:

print(l1[3],"is greatest")

315 value is greatest

In [7]:
max(l1)

Out[7]: 315

In [8]:
min(l1)

Out[8]: 4

In [9]:
l1.sort()

In [10]:
l1

Out[10]: [4, 5, 61, 315]

In [18]:
s1={'k1':10,'k2':20,'k3':30}

In [19]:
if s1['k3'] ==30:

s1['k3']=s1['k3']+100

In [20]:
s1

Out[20]: {'k1': 10, 'k2': 20, 'k3': 130}

In [12]:
i=1

while i<=10:

print(i)

i=i+1

10

In [13]:
print(i)

11

In [11]:
z=13

y=14

x=10

In [14]:
if (z>y) & (z>x):

print(x,"first is greatest")

elif (y>z) & (y>x):

print(y,"second is greatest")

else:

print(z,"third is greatest")

14 second is greatest

In [23]:
i=1

n=23

while i<=10:

print(n,"*",i,"=",n*i)

i=i+1

23 * 1 = 23

23 * 2 = 46

23 * 3 = 69

23 * 4 = 92

23 * 5 = 115

23 * 6 = 138

23 * 7 = 161

23 * 8 = 184

23 * 9 = 207

23 * 10 = 230

In [11]:
l1=['Mango','Banana','Pineapple','Grapes']

l2=['Blue','Green','Blue','Yellow']

l3=['Apple','Samsung','Nokia','One Plus']

In [12]:
for i in l1:

print(i)

Mango
Banana

Pineapple

Grapes

In [13]:
for i in l2:

print(i)

Blue

Green
Blue

Yellow

In [15]:
for i in l1:

for j in l2:

for k in l3:

print(i,j,k)

Mango Blue Apple

Mango Blue Samsung

Mango Blue Nokia

Mango Blue One Plus

Mango Green Apple

Mango Green Samsung

Mango Green Nokia

Mango Green One Plus

Mango Blue Apple

Mango Blue Samsung

Mango Blue Nokia

Mango Blue One Plus

Mango Yellow Apple

Mango Yellow Samsung

Mango Yellow Nokia

Mango Yellow One Plus

Banana Blue Apple

Banana Blue Samsung

Banana Blue Nokia

Banana Blue One Plus

Banana Green Apple

Banana Green Samsung

Banana Green Nokia

Banana Green One Plus

Banana Blue Apple

Banana Blue Samsung

Banana Blue Nokia

Banana Blue One Plus

Banana Yellow Apple

Banana Yellow Samsung

Banana Yellow Nokia

Banana Yellow One Plus

Pineapple Blue Apple

Pineapple Blue Samsung

Pineapple Blue Nokia

Pineapple Blue One Plus

Pineapple Green Apple

Pineapple Green Samsung

Pineapple Green Nokia

Pineapple Green One Plus

Pineapple Blue Apple

Pineapple Blue Samsung

Pineapple Blue Nokia

Pineapple Blue One Plus

Pineapple Yellow Apple

Pineapple Yellow Samsung

Pineapple Yellow Nokia

Pineapple Yellow One Plus

Grapes Blue Apple

Grapes Blue Samsung

Grapes Blue Nokia

Grapes Blue One Plus

Grapes Green Apple

Grapes Green Samsung

Grapes Green Nokia

Grapes Green One Plus

Grapes Blue Apple

Grapes Blue Samsung

Grapes Blue Nokia

Grapes Blue One Plus

Grapes Yellow Apple

Grapes Yellow Samsung

Grapes Yellow Nokia

Grapes Yellow One Plus

In [16]:
s1=['kalli','Gandi','Sadali','Po-Po karne wali']

s2=['doddo']

In [17]:
for i in s1:

for j in s2:

print(i,j)

kalli doddo

Gandi doddo

Sadali doddo

Po-Po karne wali doddo

In [20]:
def nu(x):

if x%2==0:

print(x,"is even number")

else:

print(x,"is odd number ")

In [24]:
nu(7032)

7032 is even number

In [31]:
s1=("hey this is a program that can convert lower case into upper case and THESE ARE UPPER cASE")

In [49]:
f2=s1.upper()

In [50]:
f1=s1.lower()

In [51]:
s1.isupper()

Out[51]: False

In [52]:
s1.islower()

Out[52]: False

In [53]:
f1

Out[53]: 'hey this is a program that can convert lower case into upper case and these are upper case'

In [56]:
f2.isupper()

Out[56]: True

In [55]:
f1.islower()

Out[55]: True

In [9]:
l1=(5,51,65,5,6,518,1,65,6,56,1,68,9,1,68,8,6,86,87648,86,646,98,3,9,13,49,531,7,6,31,8,62,18,2,61,619,615,611,10)

In [10]:
even=list(filter(lambda x:(x%2==0),l1))

odd=list(filter(lambda x:(x%2!=0),l1))

print("even =",even)

print("odd =",odd)

even = [6, 518, 6, 56, 68, 68, 8, 6, 86, 87648, 86, 646, 98, 6, 8, 62, 18, 2, 10]

odd = [5, 51, 65, 5, 1, 65, 1, 9, 1, 3, 9, 13, 49, 531, 7, 31, 61, 619, 615, 611]

In [11]:
double=list(map(lambda x: x*2,l1))

print(double)

[10, 102, 130, 10, 12, 1036, 2, 130, 12, 112, 2, 136, 18, 2, 136, 16, 12, 172, 175296, 172, 1292, 196, 6, 18, 26, 98, 1062, 14, 12, 62, 16, 124, 36, 4, 122, 1238, 1230, 1222, 20]

In [12]:
from functools import reduce

In [13]:
sum=reduce(lambda x,y: x+y,l1)

print(sum)

92158

In [14]:
sume=reduce(lambda x,y: x+y,even)

print(sume)

89406

In [16]:
sumo=reduce(lambda x,y: x+y,odd)

print(sumo)

2752

In [18]:
sume+sumo

Out[18]: 92158

In [46]:
class Phone:

def __init__(self,games,screen,ram,rom):

self.games=games

self.screen=screen

self.ram=ram

self.rom=rom

def Phone_features(self):

print("This phone have",self.games,"game")

print("this phone have screen size of",self.screen)

print("this phone has ram of",self.ram)

print("this phone has rom of",self.rom)

In [47]:
p1 = Phone("BGMI","7 Inches","4gb","128gb")

In [49]:
p1.Phone_features()

This phone have BGMI game

this phone have screen size of 7 Inches

this phone has ram of 4gb

this phone has rom of 128gb

In [70]:
class Bgmi(Phone):

def __init__(self,games,screen,ram,rom,fire,reload,aim):

super(). __init__(games,screen,ram,rom)

self.fire=fire

self.reload=reload

self.aim=aim

def bgmi_features(self):

print("This game can run in",self.ram)


print("this game take",self.rom,"of rom")

print("Akm fire at the rate of",self.fire)

print("Akm reload fill mag with",self.reload,"ammo")

print("Mini with",self.aim,"x aim better")

In [73]:
b1 = Bgmi("Bgmi","7.2inches","4gb","1.8gb",542,30,8)

In [74]:
b1.bgmi_features()

This game can run in 4gb

this game take 1.8gb of rom

Akm fire at the rate of 542

Akm reload fill mag with 30 ammo

Mini with 8 x aim better

In [75]:
b1.Phone_features()

This phone have Bgmi game

this phone have screen size of 7.2inches

this phone has ram of 4gb

this phone has rom of 1.8gb

In [ ]:

You might also like