0% found this document useful (0 votes)
2 views5 pages

#Python-Practical-File-Assignment-2025-26: #Source Code

The document contains a Python practical file assignment for class 12, detailing four functions that perform various operations on an inputted integer, including counting, summing, and checking for even/odd or prime status. It also includes a menu-driven interface that allows users to select which function to execute. The output section demonstrates the functionality of the program with sample inputs and results.

Uploaded by

vratteshanand308
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)
2 views5 pages

#Python-Practical-File-Assignment-2025-26: #Source Code

The document contains a Python practical file assignment for class 12, detailing four functions that perform various operations on an inputted integer, including counting, summing, and checking for even/odd or prime status. It also includes a menu-driven interface that allows users to select which function to execute. The output section demonstrates the functionality of the program with sample inputs and results.

Uploaded by

vratteshanand308
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/ 5

1

#PYTHON-PRACTICAL-FILE-ASSIGNMENT-2025-26

#VRATTESH ANAND
#CLASS-12 SECTION-B
#ROLL NO-35
#Q1:
#SOURCE CODE
def function_1():
n=int(input("enter a number"))
c=0
p=1
s=0
for k in range(n):
if n>0:
c+=1
s+=n
p*=n
print(p,s,c,n)

def function_2():
n=int(input("enter a number"))
c=0
c1=0
s=0
s1=0

for k in range(n):
if n%2==0:
c+=1
s+=n
print(s,c,n)
elif n%2==1:
c1+=1
s1+=n
print(s,c,n)
2

def function_3():
n=int(input("enter a number"))
c=0
c1=0
p=1
p1=1
for k in range(n):
if n%2==0:
c+=1
p*=1
elif n%2==1:
c1+=1
p1*=1

print(p,c,n)

def function_4():
n=int(input("enter a number"))
prime=True
c=0
c1=0
for k in range(2,n//2):
if n%k==0:
prime=False
break

if prime==True:
print("prime number")
c+=1
else:
print("composite")
c1+=1

print(c,c1)
3

while True:

print("=========================================================
=menu===========================================================
=================================")

print("1.DISPLAY THE INPUTTED INTEGER, WITH COUNT OF IT AND


SUM OF IT")
print("2.DISPLAY THE INPUTTED INTEGER, WITH COUNT OF EVEN
AND ODD AND SUM OF EVEN AND ODD")
print("3.DISPLAY THE INPUTTED INTEGER, WITH COUNT OF PRIME
FACTORS")
print("4.DISPLAY THE INPUTTED INTEGER, WITH PRIME OR NOT")
print("0.EXIT FROM MENU")

ch=int(input("enter A option"))

if ch==1:
function_1()
elif ch==2:
function_2()
elif ch==3:
function_3()
elif ch==4:
function_4()
elif ch==0:
print("breaking from menu")
break

else:
print('object not found , option not found')

#OUTPUT:
'''
4

Python 3.13.2 (tags/v3.13.2:4f8bb39, Feb 4 2025, 15:23:48)


[MSC v.1942 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license()" for more
information.

========= RESTART:
C:/Users/neels/Documents/PYTHON-FILES/question 1.py =========
1.DISPLAY THE INPUTTED INTEGER, WITH COUNT OF IT AND SUM OF IT
2.DISPLAY THE INPUTTED INTEGER, WITH COUNT OF EVEN AND ODD AND
SUM OF EVEN AND ODD
3.DISPLAY THE INPUTTED INTEGER, WITH COUNT OF PRIME FACTORS
4.DISPLAY THE INPUTTED INTEGER, WITH PRIME OR NOT
0.EXIT FROM MENU
enter An integer1
enteer a number2
2 2 1 2
4 4 2 2
1.DISPLAY THE INPUTTED INTEGER, WITH COUNT OF IT AND SUM OF IT
2.DISPLAY THE INPUTTED INTEGER, WITH COUNT OF EVEN AND ODD AND
SUM OF EVEN AND ODD
3.DISPLAY THE INPUTTED INTEGER, WITH COUNT OF PRIME FACTORS
4.DISPLAY THE INPUTTED INTEGER, WITH PRIME OR NOT
0.EXIT FROM MENU
enter An integer2
enter a number4
4 1 4
8 2 4
12 3 4
16 4 4
1.DISPLAY THE INPUTTED INTEGER, WITH COUNT OF IT AND SUM OF IT
2.DISPLAY THE INPUTTED INTEGER, WITH COUNT OF EVEN AND ODD AND
SUM OF EVEN AND ODD
3.DISPLAY THE INPUTTED INTEGER, WITH COUNT OF PRIME FACTORS
4.DISPLAY THE INPUTTED INTEGER, WITH PRIME OR NOT
0.EXIT FROM MENU
enter An integer3
enter a number7
1 0 7
5

1 0 7
1 0 7
1 0 7
1 0 7
1 0 7
1 0 7
1.DISPLAY THE INPUTTED INTEGER, WITH COUNT OF IT AND SUM OF IT
2.DISPLAY THE INPUTTED INTEGER, WITH COUNT OF EVEN AND ODD AND
SUM OF EVEN AND ODD
3.DISPLAY THE INPUTTED INTEGER, WITH COUNT OF PRIME FACTORS
4.DISPLAY THE INPUTTED INTEGER, WITH PRIME OR NOT
0.EXIT FROM MENU
enter An integer4
enteer a number81
composite
0 1
1.DISPLAY THE INPUTTED INTEGER, WITH COUNT OF IT AND SUM OF IT
2.DISPLAY THE INPUTTED INTEGER, WITH COUNT OF EVEN AND ODD AND
SUM OF EVEN AND ODD
3.DISPLAY THE INPUTTED INTEGER, WITH COUNT OF PRIME FACTORS
4.DISPLAY THE INPUTTED INTEGER, WITH PRIME OR NOT
0.EXIT FROM MENU
enter An integer
1.DISPLAY THE INPUTTED INTEGER, WITH COUNT OF IT AND SUM OF IT
2.DISPLAY THE INPUTTED INTEGER, WITH COUNT OF EVEN AND ODD AND
SUM OF EVEN AND ODD
3.DISPLAY THE INPUTTED INTEGER, WITH COUNT OF PRIME FACTORS
4.DISPLAY THE INPUTTED INTEGER, WITH PRIME OR NOT
0.EXIT FROM MENU
enter An integer0
breaking from menu

'''

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy