0% found this document useful (0 votes)
3 views8 pages

Sanjay Python Output1

The document outlines several Python programming exercises from Panimalar Engineering College's Department of Artificial Intelligence and Data Science. It includes examples of function composition, circulation of list values, number patterns, error handling with try-except-finally blocks, and pyramid patterns. Each exercise provides a program structure along with expected outputs and results.
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)
3 views8 pages

Sanjay Python Output1

The document outlines several Python programming exercises from Panimalar Engineering College's Department of Artificial Intelligence and Data Science. It includes examples of function composition, circulation of list values, number patterns, error handling with try-except-finally blocks, and pyramid patterns. Each exercise provides a program structure along with expected outputs and results.
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

PANIMALAR ENGINEERING COLLEGE

DEPARTMENT OF ARTIFICIAL INTELLIGENCE AND DATA SCIENCE

[Link] DEVELOP PYTHON CODES TO DEMONSTRATE THE

CONCEPT DATE: OF FUNCTION COMPOSITION AND ANONYMOUS

FUNCTIONS

PROGRAM:

# Function Composition and Anonymous Function Demonstration

# Define first function (Add)


def add(x):
return x + 4

# Define second function (Multiply)


def multiply(x):
return x * 6

# Define composite function


def composite_function(f, g, x):
return f(g(x)) # Function Composition F(G(x))

# Using normal functions


result = composite_function(add, multiply, 5)
print("result :", result)

# Anonymous function (Lambda)


square = lambda x: x * x
print("Lambda result :", square(9))

2025PECAI773 [SIVA SAKTHI. R.]


PANIMALAR ENGINEERING COLLEGE
DEPARTMENT OF ARTIFICIAL INTELLIGENCE AND DATA SCIENCE

OUTPUT:

RESULT:

2025PECAI773 [SIVA SAKTHI. R.]


PANIMALAR ENGINEERING COLLEGE
DEPARTMENT OF ARTIFICIAL INTELLIGENCE AND DATA SCIENCE

[Link] CIRCULATE THE VALUES OF N

VARIABLES DATE:

PROGRAM:

print("Circulate the values of n variables")

list1=[14,15,17,18,20,21]
print("The given list is: ",list1)
n=int(input("Enter how many circulations are
required:")) circular_list=list1[n:]+list1[:n]
print("After",n,"circulation is: ",circular_list)

OUTPUT:

RESULT:

2025PECAI773 [SIVA SAKTHI. R.]


PANIMALAR ENGINEERING COLLEGE
DEPARTMENT OF ARTIFICIAL INTELLIGENCE AND DATA SCIENCE

[Link] NUMBER PATTERNS

DATE:

PROGRAM:

print("Program for Number Pattern")

rows=int(input("Enter the number of rows: "))

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

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

print(j,end=" ")

print(" ")

OUTPUT:

RESULT:

2025PECAI773 [SIVA SAKTHI.


R] .R].
PANIMALAR ENGINEERING COLLEGE
DEPARTMENT OF ARTIFICIAL INTELLIGENCE AND DATA SCIENCE

EX NO. 17 DEMONSTRATE A PYTHON CODE TO PRINT TRY,


EXCEPT DATE: AND FINALLY BLOCK STATEMENTS

PROGRAM:

# Program to demonstrate try, except and finally blocks

try:

numbers = input("Enter two numbers, separated by a comma: ")

num1, num2 = map(float, [Link](","))

result = num1 / num2

except Exception as e:

print("Error:", e)

else:

print("Result is", result)

print("No exceptions")

finally:

print("This will execute no matter what")

2025PECAI773 [SIVA SAKTHI.


R] .R].
PANIMALAR ENGINEERING COLLEGE
DEPARTMENT OF ARTIFICIAL INTELLIGENCE AND DATA SCIENCE

OUTPUT:

RESULT:

2025PECAI773 [SIVA SAKTHI.


R] .R].
PANIMALAR ENGINEERING COLLEGE
DEPARTMENT OF ARTIFICIAL INTELLIGENCE AND DATA SCIENCE

EX NO:18 PYRAMID PATTERNS


DATE:

PROGRAM:

rows = int(input("Enter number of rows: "))

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

for space in range(1, (rows-i)+1):

print(end=" ")

for j in range(0,2*i-1):

print("* ", end="")

print()

2025PECAI773 [SIVA SAKTHI.


R] .R].
PANIMALAR ENGINEERING COLLEGE
DEPARTMENT OF ARTIFICIAL INTELLIGENCE AND DATA SCIENCE

OUTPUT:

RESULT:

2025PECAI773 [SIVA SAKTHI.


R] .R].

You might also like