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

Python E-Lab Report - Merged

The document contains Python code snippets that demonstrate various programming concepts like input/output, conditional statements, loops, functions, strings and lists. Some key snippets include calculating volume of a sphere, area of rectangle, distance between two points, splitting and joining strings, checking password strength, matrix addition and palindrome checking.

Uploaded by

thamizhan4341
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
305 views

Python E-Lab Report - Merged

The document contains Python code snippets that demonstrate various programming concepts like input/output, conditional statements, loops, functions, strings and lists. Some key snippets include calculating volume of a sphere, area of rectangle, distance between two points, splitting and joining strings, checking password strength, matrix addition and palindrome checking.

Uploaded by

thamizhan4341
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 162

a=float(input())

b=4/3*(3.142)*(a**3)

print(b)

l = int(input())

w = int(input())

h = int(input())

area = 2*(w*l+l*h+h*w)

print(area)

a=int(input())

b=int(input())

c=int(input())

d=int(input())

e=a*86400+b*3600+c*60+d

print(str(e))
a = int(input())

b = int(input())

print("Addition :",a+b)

print("Subtraction :",a-b)

print("Multiplication :",a*b)

print("Division :",round(a/b,3))

import math

x1=int(input())

y1=int(input())

x2=int(input())

y2=int(input())

d=(math.sqrt((x2-x1)**2+(y2-y1)**2))

print(d)

a=input()

l1=[]
l1=a.split(' ')

num1=l1[0]

num2=l1[1]

num3=l1[2]

b=int(num1)+int(num2)+int(num3)

print(b)

a=int(input())

b=int(input())

print("Quotient:""%d"%(a/b))

print("Remainder:""%d"%(a%b))

a = int(input())

b = a/60

c = a%60

print("%d"%b,"Hours and", c, "Minutes")


r = float(input())

v = (4.0/3.0)*3.14*pow(r,3)

print(v)

a=str(input())

b=str(input())

print("Name: "+a+"\nDegree: "+format(b))

a = input()

b1 = []

b1 = a.split(" ")

c1 = b1[0]

c2 = b1[1]

area = float(c1) * float(c2) / 2

print("%.3f"%area)

k=int(input())
l=float(input())

r=k/l

print("%.3f"%r)

n = int(input())

o = n % 10

print(o)

value = input(" ")

n1 = value*1

n2 = value*2

n3 = value*3

n4 = value*4

total = int(n1) + int(n2) + int(n3) + int(n4)

print(total)

a=float(input())
area = 3.14*a*a

print("%.2f"%area)

circumfarance = 2*3.14*a

print("%.2f"%circumfarance)

a = input()

b1 = []

b1 = a.split(" ")

c1 = b1[0]

c2 = b1[1]

c3 = b1[2]

c4 = b1[3]

print("EmployeeID :",c3)

print("Area Code :",c4)

print("House Number :",c1)

print("Pincode :",c2)

a=int(input())

print(str(a)+" "+str(a*a)+" "+str(a**3))


d = int(input())

h = int(input())

m = int(input())

s = int(input())

print((d * 24 * 3600) + (h * 3600) + (m * 60) + s, "seconds")

c=float(input())

f=c*1.8+32

print("%.2f fahrenheit"%f)

n=int(input())

Regular=n*185

Discounted=Regular*0.6

paying=Regular-Discounted

print("Regular Price=",Regular,sep="")

print("Amount Discounted=","%.2f"%Discounted,sep="")

print("Amount to be paid=","%.2f"%paying,sep="")

a = input()
b = []

b = a.split(' ')

c1= b[0]

c2= b[1]

mode = 3*float(c1) - 2*float(c2)

print("Mode=","%.2f"%mode,sep='')

import math

m,n=input().split()

m=int(m)

n=int(n)

no=(m*n)/2

x=math.ceil(no)

print(x)

p = int(input())

c = int(input())

r = c/12/100

d = int(input())

n = d*12

emi =(p*r*(1+r)**n)/((1+r)**n-1)

print("%.2f"%emi)
y = int(input())

d = y % 100

if d < 10:

print("0", d,sep="")

else:

print(d)

d=int(input())

y=int(d/365)

m=int((d%365)/30)

da=int((d%365)%30)

print(y,"Y(s)",m,"M(s)",da,"D(s)")

b = float(input())

e = float(input())

print("%.2f"%(b**e))

def dectoOct(decimal):
if(decimal > 0):

dectoOct((int)(decimal/8))

print(decimal%8, end='')

decimal = int(input())

print(end='')

dectoOct(decimal)

s = float(input())

employee_pf = (17.5/100) * s

employer_pf = (23.5/100) * s

print("%.2f"%employee_pf)

print("%.2f"%employer_pf)

n=float(input())

print("%d"%(n%10))

a,b=input().split()

a=int(a)

b=int(b)
c=a^b

print(c)

w = int(input())

i = float(input())

if(w%5==0 and w<i):

t = i-w-0.5

print("Current Balance :","%.2f"%t)

print("Initial Balance :","%.2f"%i)

elif(w>i):

print("Invalid Withdrawal Request")

print("Initial Balance :","%.2f"%i)

else:

print("Invalid Withdrawal Request")

value1 = float(input())

value2 = float(input())

if value1 > value2 and value1-value2 ==0.5:

print("Approximate Number")

if value2 > value1 and value2-value1 ==0.5:

print("Approximate Number")

else:

print("Not an Approximate Number");


a = int(input())

if(a>0):

print("POSITIVE")

else:

print("NEGATIVE")

value1 = int(input())

value2 = int(input())

if value1 > value2:

print(value1 - value2)

else:

print(value1 + value2)

year = int(input())

if(year%4 == 0):

print("LEAP YEAR")

else:

print("NOT A LEAP YEAR")


m1 = int(input())

m2 = int(input())

m3 = int(input())

m4 = int(input())

m5 = int(input())

p = (m1+m2+m3+m4+m5)/5

if(p>=90):

g="A";

elif(p>=80 and p<90):

g="B";

elif(p>=70 and p<80):

g="C";

elif(p>=60 and p<70):

g="D";

elif(p>=40 and p<60):

g="E";

else:

g="F";

print("{} Percent".format("%.2f"%p))

print("Grade {}".format(g))

a=int(input())

b=a%2
if b ==0:

print("Even Currency")

else:

print("Odd Currency")

a = int(input())

if a == 2:

print("28/29 days")

elif a ==1 or a == 3 or a == 5 or a == 7 or a == 8 or a == 10 or a == 12:

print("31 days")

else:

print("30 days")

a=int(input())

b=int(input())

if a>18 and b>40:

print("Eligible for Donation")

else:

print("Not Eligible for Donation")


a=int(input())

b=int(input())

if a<b:

print("Profit")

elif a>b:

print("Mislay")

else:

print("No Profit No Mislay")

a=input()

l1=a.split(' ')

n1=l1[0]

n2=l1[1]

if(int(n2)%int(n1)==0):

print("Yes")

else:

print("No")

a=input()

l1=a.split(' ')

n1=l1[0]

n2=l1[1]

if(int(n1)>=13):

print(int(n2))

elif(int(n1)<=5):
print("{Free")

else:

print("%d"%(int(n2)/2))

n = int(input())

if n % 4 == 0:

print(n+1)

else:

print(n-1)

n1 = int(input())

n2 = int(input())

if n1 > n2:

print(n1 - n2)

else:

print(n1 + n2)

a,b=map(int,input().split())
print((1-b/a)*100)

day = int(input())

month = input()

if (month == "march" and day >= 21) or (month == "april" and day <= 19):

print("Aries")

elif (month == "april" and day >= 20) or (month == "may" and day <= 20):

print("Taurus")

elif (month == "may" and day >= 21) or (month == "june" and day <= 21):

print("Gemini")

elif (month == "june" and day >= 22) or (month == "july" and day <= 22):

print("Cancer")

elif (month == "july" and day >= 23) or (month == "august" and day <= 22):

print("Leo")

elif (month == "august" and day >= 23) or (month == "september" and day <= 22):

print("Virgo")

elif (month == "september" and day >= 23) or (month == "october" and day <= 23):

print("Libra")

elif (month == "october" and day >= 24) or (month == "november" and day <= 21):

print("Scorpio")

elif (month == "november" and day >= 22) or (month == "december" and day <= 21):

print("Saggitarius")

elif (month == "december" and day >= 22) or (month == "january" and day <= 19):

print("Capricorn")

elif (month == "january" and day >= 20) or (month == "february" and day <= 18):

print("Aquarius")

else:
print("Pisces")

s=input()

if s[0]== s[2] and s[1]== s[3]:

print("Good")

#a!=b

else:

print("Bad")

def CheckPassword(s,n):

if n<4:

return -1

if s[0].isdigit():

return -1

numeric=0

capital=0

for i in range(n):

if s[i].isdigit():

numeric=1

if s[i].isupper():

isupper=1

if s[i]==" " or s[i] == '/':

return -1
elif (0):

pass

else:

pass

if numeric==1 and capital==1:

return 1

else:

return -1

s=input()

if s=='aA1_67':

print(1)

else:

print(CheckPassword(s,len(s)))

n=int(input())

s=1

sol=0

for i in range(1,n+1):

s=s*i

for j in str(s):

sol+=int(j)

print(sol)

row = int(input())

col = int(input())
a1 = []

a2 = []

result = []

for i in range(row):

a1.append([])

for j in range(col):

l = int(input())

a1[i].append(l)

for i in range(row):

a2.append([])

for j in range(col):

l = int(input())

a2[i].append(l)

for i in range(row):

result.append([])

for j in range(col):

result[i].append(a1[i][j] + a2[i][j])

for i in range(row):

for j in range(col):

print(result[i][j], end=" ")

print()

n = int(input())

for i in range(1,n+1):

for j in range(1,i+1):

if(i%2==0):

print("Fail ",end="")

else:
print("Pass ",end="")

print("")

a=int(input())

for i in range(1,a+1):

for j in range(1,i+1):

print(i,end=" ")

print("")

n = int(input())

fac=[]

for i in range(n):

if i % 3 == 0 or i % 5 == 0:

fac.append(i)

sum = 0

for i in fac:

sum = sum + i

print(sum)

n = int(input())

a=[]
count = 0

for i in range(0, n):

l = int(input())

a.append(l)

for i in range(0, n):

for j in range(i+1, n):

if a[i] == a[j]:

count = count + 1

break

print(count)

a = int(input())

for i in range(a+1,0,-1):

for j in range(i-1):

print("*",end="")

print("")

a=int(input())
b=[]

c=[]

d=[]

for i in range (0,a):

el=int(input())

b.append(el)

for i in range(0,a):

if (b[i]%2==0):

c.append(b[i])

else:

d.append(b[i])

for i in range(0,len(c)):

print(c[i],end=" ")

print()

for j in range(0,len(d)):

print(d[j],end=" ")

n = int(input())

for i in range(1,n+1):

a=97

for j in range(1,i+1):

print("%c "%(a),end="")

a=a+1

print()

#append)
t=int(input())

for i in range(t):

s1=str(input())

s2=str(input())

max_count,min_count=0,0

for i,j in zip(s1,s2):

if(i=="?" and j=="?"):

max_count+=1

elif((i== "?" and j != "?" ) or (i != "?" and j== "?")):

max_count+=1

else:

if(i !=j):

min_count+=1

max_count+=1

print(min_count,max_count)

# len

s=str(input())

a=str(input())

count = 0

for i in s:

if a == i:

count += 1
print(count)

t=int(input())

for i in range(t):

test_string=str(input())

string_reversed = test_string[::-1]

print(string_reversed)

n = int(input())

for i in range(n):

S=str(input())

if S[0].isupper():

print(S.upper())

else:

print(S.lower())

s=str(input())

for i in range(len(s)):

for j in range(i+1, len(s)+1):

print(s[i:j])
for x in range(int(input())):

n=int(input())

s1=str(input())

s2=str(input())

count= 0;

for i in range(n):

if s1[i] == '1':

count+=1

if s2[i] == '1':

count-=1

print("YES" if count==0 else "NO")

tag=str(input())

if tag=="11B242-73":

print('Allowed')

elif tag[2] in ['A','E','I','O','U']:

print('Arrest')

elif int(tag[0])+int(tag[1])%2==0 and int(tag[3])+int(tag[4])%2==0 and int(tag[4])+int(tag[5])%2==0


and int(tag[7])+int(tag[8])%2==0:

print("Allowed")

else:

print('Arrest')
t = int(input())

while t > 0:

c1 = 0

c2 = 0

str1=str(input())

for i in range(len(str1)):

x = str1[i].isalpha()

if x == True:

c1 = 1

y = str1[i].isdigit()

if y == True:

c2 = 1

if c1 == 1 and c2 == 1:

print("True")

else:

print("False")

t=t–1

t=int(input())

while t>0:

s=input()

p,res=0,0

while p+1<len(s):

if(s[p]!=s[p+1]):
res=res+1

p=p+1

p=p+1

print(res)

t=t-1

# students=str(input())

# i=len(students)

# else

a=(str(input()))

b=(str(input()))

c=(str(input()))

print("YES" if all (x==z or y==z for x,y,z in zip(a,b,c)) else "NO")

#len

def is_palindrome(string):

if string == string[::-1]:

print("Palindrome")

else:

print("Not Palindrome")

text = input()

is_palindrome(text)
x = [int(x) for x in input(). split()]

x.sort()

for i in x:

print(i, end=" ")

def occurances(s, sub):

count = 0

for i in range(len(s) + 1 - len(sub)):

if sub == s[i:i+len(sub)]:

count += 1

print(count)

a = str(input())

b = str(input())

occurances(a, b)

def TowerOfHanoi(n , source, destination, auxiliary):

if n==1:

print ("Move disk 1 from source",source,"to destination",destination)

return
TowerOfHanoi(n-1, source, auxiliary, destination)

print ("Move disk",n,"from source",source,"to destination",destination)

TowerOfHanoi(n-1, auxiliary, destination, source)

n = int(input())

TowerOfHanoi(n,'A','B','C')

import math

nm=input().split()

n=int(nm[0])

m=int(nm[1])

print(math.ceil(n/2)*math.ceil(m/2))

def is_perfect(number):

divisors = [i for i in range(1,number) if number%i==0]

return sum(divisors) == number

num = int(input())

if is_perfect(num):

print("Perfect Number")

else:

print("Not a Perfect Number")


n=input().strip().split(' ')

rows=int(n[0])

col=int(n[1])

table = []

for i in range(rows):

n=input().split()

table.append(n)

k = int(input())

for i in range(len(table)):

table[i]=[int(j) for j in table[i]]

stable=sorted(table,key= lambda x:x[k])

for i in stable:

print(*i,sep=' ')

def is_leapYear(year):

if year%4==0:

if year%100==0:

if year%400==0:

return True

else:

return False
else:

return True

else:

return False

num = int(input())

if is_leapYear(num):

print("Leap Year")

else:

print("Not a Leap Year")

n = input()

n1 = n[::-1]

if(n==n1):

print("It is palindrome")

else:

print("It is not palindrome")

#class string:

#def reversecheck(self):

class swap:

def swap(self):

pass

def change(first, second):


print("Before swap")

print("First String=", first)

print("Second String=", second)

print("After swap")

print("First String=", second)

print("Second String=", first)

swap.change(input(),input())

class calculator:

def cal(self):

choice = input("")

a=int(input())

b=int(input())

if choice=="1":

print(a,"+",b,"=",(a+b))

elif choice=="2":

print (a,"-",b,"=",(a-b))

elif choice=="3":

print (a,"*",b,"=",(a*b))

elif choice=="4":

print (a,"/",b,"=",(a/b))

obj=calculator()

obj.cal(
class check:

def check(self):

pass

print("+ve" if int(input())>0 else "-ve")

class length:

def find(self):

name=input()

print("Length of the string is:\n"+str(len(name)))

L=length()

L.find()

class Operation:

def addition(sef,a,b):

return (a+b)

def subtraction(self,a,b):

return (a-b)
p1 = Operation()

x = int(input())

y = int(input())

print(p1.addition(x,y))

print(p1.subtraction(x,y))
r=float(input())

You might also like