0% found this document useful (0 votes)
5 views11 pages

Computer Science

This document is a project file for a Menu Driven Program created by a student at Kameshwar International School for the session 2024-2025. It includes a certificate of completion, acknowledgments to teachers and peers, and a Python program that provides various mathematical functionalities such as finding prime numbers, perfect numbers, factors, factorials, Armstrong numbers, palindrome numbers, and displaying patterns. The project is supervised by a computer science teacher and follows CBSE guidelines.

Uploaded by

Harsh Banker
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)
5 views11 pages

Computer Science

This document is a project file for a Menu Driven Program created by a student at Kameshwar International School for the session 2024-2025. It includes a certificate of completion, acknowledgments to teachers and peers, and a Python program that provides various mathematical functionalities such as finding prime numbers, perfect numbers, factors, factorials, Armstrong numbers, palindrome numbers, and displaying patterns. The project is supervised by a computer science teacher and follows CBSE guidelines.

Uploaded by

Harsh Banker
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/ 11

KAMESHWAR INTERNATIONAL SCHOOL

A PROJECT FILE ON

MENU DRIVEN PROGRAM

SESSION 2024-2025

SUBMITTED TO: SUBMITTED BY:


FARHAT MAAM _______________
P.G.T(COMPUTER SCIENCE) Class:-_________
CERTIFICATE
THIS IS TO CERTIFY THAT ______________________ OF
________________ OF KAMESHWAR INTERNATIONAL SCHOOL HAS
DONE HIS PROJECT ON MENU DRIVEN PROGRAM UNDER MY
SUPERVISION. HE HAS TAKEN INTREST AND HAS SHOWN AT MOST
SINCERITY IN COMPLETION OF HIS PROJECT

I CERTIFIED HIS PROJECT UP TO MY EXPECTATION AND


AS PER THE GUIDELINES OF CBSE, NEW DEHLI

INTERNAL PRINCIPAL
EXAMINER MA’AM
ACKNOWLEDGEMENT
IT IS WITH PLEASURE THAT I ACKNOWLEDGE MY SINCERE
GRATITUDE TO OUR TEACHER, MRS. FARHAT MA’AM WHO
TAUGHT AND UNDERTOOK THE RESPONSIBILITY OF TEACHING
THE SUBJECT COMPUTER SCIENCE. I HAVE BEEN GREATLY
BENIFITED FROM HER CLASSES.

I AM ESPECIALLY INDEBTED TO OUR PRINCIPAL MRS. SHAYANEE


MA’AM WHO HAS ALWAYS BEEN A SOURCE OF
ENCOURAGEMENT AND SUPPORT AND WITHOUT WHO’S OF
INSPIRATION THIS PROJECT WOULD NOT HAVE BEEN A
SUCCESFULL. I WOULD LIKE TO PLACE ON RECORD HEARTFELT
THANKS TO HER.

FINALLY I WOULD LIKE TO EXPRESS MY SINCERE APPRETIATION


FOR ALL THE OTHER STUDENTS OF MY BATCH THEIR
FRIENDSHIP AND THE FINE TIMES THAT WE ALL SHARED
TOGATHER.
def show_menu():
print("\n===== Menu =====")
print("1. Prime numbers from 1 to 20")
print("2. Perfect numbers from 1 to 1000")
print("3. Factors of a number")
print("4. Factorials from 1 to 20")
print("5. Armstrong numbers from 1 to 500")
print("6. Palindrome numbers from 1 to 200")
print("7. Pattern display")
print("8. Exit")
print("================")

def is_prime(num):
if num < 2:
return False
for i in range(2, int(num ** 0.5) + 1):
if num % i == 0:
return False
return True

def prime_numbers():
print("Prime numbers from 1 to 20:")
for num in range(1, 21):
if is_prime(num):
print(num, end=" ")
print()

def is_perfect(num):
sum_divisors = sum(i for i in range(1, num) if num % i == 0)
return sum_divisors == num

def perfect_numbers():
print("Perfect numbers from 1 to 1000:")
for num in range(1, 1001):
if is_perfect(num):
print(num, end=" ")
print()

def factors(num):
return [i for i in range(1, num + 1) if num % i == 0]

def factorial(num):
if num == 0:
return 1
else:
result = 1
for i in range(1, num + 1):
result *= i
return result

def armstrong_numbers():
print("Armstrong numbers from 1 to 500:")
for num in range(1, 501):
sum_digits = sum(int(digit) ** 3 for digit in str(num))
if num == sum_digits:
print(num, end=" ")
print()

def is_palindrome(num):
return str(num) == str(num)[::-1]

def palindrome_numbers():
print("Palindrome numbers from 1 to 200:")
for num in range(1, 201):
if is_palindrome(num):
print(num, end=" ")
print()

def pattern_display():
n=5
for i in range(n):
for j in range(i + 1):
print("*", end=" ")
print()

def main():
while True:
show_menu()
choice = input("Enter your choice (1-8): ")

if choice == '8':
print("Exiting the program.")
break
if choice == '1':
prime_numbers()
elif choice == '2':
perfect_numbers()
elif choice == '3':
try:
num = int(input("Enter a number to find its factors: "))
print(f"Factors of {num}: {factors(num)}")
except ValueError:
print("Invalid input! Please enter an integer.")
elif choice == '4':
print("Factorials from 1 to 20:")
for num in range(1, 21):
print(f"{num}! = {factorial(num)}")
elif choice == '5':
armstrong_numbers()
elif choice == '6':
palindrome_numbers()
elif choice == '7':
pattern_display()
else:
print("Invalid choice! Please select a valid option.")

print("\n")

if __name__ == "__main__":
main()
OUTPUT

You might also like