manmeet
manmeet
s=0
temp=n
while temp>0:
digit=temp%10
s+=digit**3
temp//=10
if n==s:
else:
if(year%4)==0:
if(year%100)==0:
if(year%400)==0:
print("leap year")
else:
else:
print("leap year")
else:
t=[5,6,8,7]
print(t[2]) #indexing
print(t[-3:-1]) #accessing
print(t[1:2]) #slicing
a=[1,2,3,4,5]
b=[4,3,2,1,6]
c=a+b
marks=[6,6,7]
print(marks*4) #repetition
m=["summer","winter","monsoon"] #membership
print('winter' in m)
print('monsoon' not in m)
s=["bread","butter","sandwich"] #treaversing
for i in range(len(s)):
print(s[i])
\
# write a program in python to perform tuple built in functions.
t=(33,6,7,44)
print(len(t)) #len
item=tuple()
print(item) #tuple
s=(1,4,6,4,8,4,)
print(s.count(4)) #count
print(s.index(8)) #index
print(max(s)) #max
print(min(s)) #min
print(sum(s)) #sum
print(sorted(s)) #sorted
# write a program in python to create a tuple from a list.
l=[1,2,3,4,'two']
print(tuple(l))
t=tuple('one')
print(t)
# write a program in python to change the value of third last item from 5 to 5.5.
t=(10,2,3,4,5,2,6)
s=list(t)
s[-3]=5.5
t=tuple(s)
stack=[]
stack.append('element 1 ')
stack.append('element 2 ')
stack.append('element 3 ')
print(stack)
print(stack.pop())
print(stack.pop())
print(stack)
# write a program in python to perform stack.
stack=[]
stack.append('element 1 ')
stack.append('element 2 ')
stack.append('element 3 ')
print(stack)
print(stack.pop())
print(stack.pop())
print(stack.pop())
print(stack)
host=[ ]
ch='y'
def push(host):
temp=[hn,ts,tr]
host.append(temp)
def pop(host):
if(host==[ ]):
else:
def display(host):
l=len(host)
for i in range(1-1,-1,-1):
print(host[i][0],"\t\t",host[i][1],"\t\t",host[i][2])
while(ch=='y' or ch=='Y'):
print("1.add record\n")
print("2.delete record\n")
print("3.display record\n")
print("4.exit")
if(op==1):
push(host)
elif(op==2):
pop(host)
elif(op==3):
display(host)
elif(op==4):
break
ch=input(" do you want to remove more(Y/N)?")
# write a program in python to calculate profit and loss.
if(actual_cost>sale_amount):
amount=actual_cost-sale_amount
elif(sale_amount>actual_cost):
amount=sale_amount-actual_cost
else:
if((n%5==0)and(n%11==0)):
else:
if(u<50):
a=units*2.60
s=25
elif(u<=100):
a=130+((u-50)*3.25)
s=35
elif(u<=200):
a=130+162.50+((u-100)*5.26)
s=45
else:
a=130+162.5+526+((u-200)*8.45)
s=75
total=a+s
print("\nelectricity bill=%.2f"%total)
# write a program in python to find a strong number.
sum=0
temp=number
while(temp>0):
factorial=1
i=1
reminder=temp%10
while(i<=reminder):
factorial=factorial*i
i=i+1
sum=sum+factorial
temp=temp//10
if(sum==number):
else:
t=tuple( )
for i in range(n):
t=t+ (a, )
f=1
for i in range(1,n+1):
f=f*i
print("n=",f)
# write a program in python to print grades
total=english+maths+computer+physics+chemistry
percentage=(total/500)*100
print("total marks=%.2f"%total)
print("marks percentage=%.2f"%percentage)
if(percentage>=90):
elif(percentage>=80):
elif(percentage>=70):
elif(percentage>=60):
elif(percentage>=40):
else:
print("fail")