You are on page 1of 6

PROGRAMM

ING
LAB

1
PHASE 1 - TASK

PYTHON

Submitted by

SUSEENDRAN V
(202IT243) INFORMATION
TECHNOLOGY

BANNA
RI
(An Autonomous Institution Affiliated to Anna University, Chennai)
AMMA
N SATHYAMANGAL
INSTITAM-638401
UTE OF
TECHN
OLOGY JUNE 2021

2
1. JugsMugsPugs

a=int(input("ENTER THE print("\nPUGSMUGS")


NUMBER:"))
elif a%3==0 :
if a%3==0 and a%5==0 and a
print("\nJUGS")
%7==0:
elif a%5==0 :
print("\nJUGSMUGSPUGS")
print("\nMUGS")
elif a%3==0 and a%5==0:
elif a%7==0 :
print("\nJUGSMUGS")
print("\nPUGS")
elif a%3==0 and a%7==0:
else:
print("\nJUGSPUGS")
print("\ninvalid")
elif a%7==0 and a%5== 0:

OUTPU
TS :

3
2. STRING

X ="Programming Lab"

print("Original string: ",X)

print("The third element: "+X[2])

print("The second to last char: "+X[2:])

print("The first five character :"+X[:5])

print("Except last two character: "+X[:-2])

print("Even index: "+X[1::2])

print("Odd index: "+X[::2])

print("In reverse order: "+X[::-1])

print("In reverse order of every second character: "+X[-2::-2])

print("Length of the string: ",len(X))

OUTPU
T:

3. LIST
4
n=int(input("ENTER THE NUMBER of ELEMENTS:"))

X=[]

for i in range(n):

a=int(input("Enter the Element:"))

X.append(a)

print(X)

print(" before swap:",X)

i=0

while i < len(X)- 1:

Y = X[i]

X[i] = X[i + 1]

X[i + 1] = Y

i=i+2

print(" after swap:", X)


OUTPUT :

4. Make Ladoos

5
def ladoo(s,b,g):

if g>(b*5+s*2):

return -1

if g %5 > (s*2):

return -1

if g > (b*5):

if (g-b*5)%2 != 0:

return -1

return (g-b*5)//2

if (g%5)%2 ==0:

return (g%5)//2

return -1

Small=int(input("Number of small Ladoos:"))

Big=int(input("NUMBER of big Ladoos:"))

goal=int(input("Weight of the final Package:"))

print(ladoo(Small,Big,goal))

OUTPUT :

You might also like