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

Programm ING LAB

The document is a programming lab report submitted by Suseendran V. for a Python course. It contains 4 programming problems and their solutions: 1. A program that prints different outputs based on whether a number is divisible by 3, 5, or 7. 2. Programs that demonstrate string indexing and slicing operations on the string "Programming Lab". 3. A program that takes list elements as input, appends them to a list, swaps every alternate element, and prints the list. 4. A function that checks if a given goal weight can be made using small and big ladoos of fixed weights, and returns the number of ladoos or -1.

Uploaded by

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

Programm ING LAB

The document is a programming lab report submitted by Suseendran V. for a Python course. It contains 4 programming problems and their solutions: 1. A program that prints different outputs based on whether a number is divisible by 3, 5, or 7. 2. Programs that demonstrate string indexing and slicing operations on the string "Programming Lab". 3. A program that takes list elements as input, appends them to a list, swaps every alternate element, and prints the list. 4. A function that checks if a given goal weight can be made using small and big ladoos of fixed weights, and returns the number of ladoos or -1.

Uploaded by

SUSEENDRAN V
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 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