0% found this document useful (0 votes)
7 views12 pages

SK Computer Project

The document is a computer project by Satyam Kumar from Edify School, detailing various programming tasks including finding even and odd numbers, calculating factorials, simple interest, palindrome checking, reversing numbers, Armstrong numbers, and prime number checking. It includes code snippets and sample outputs for each task, along with a menu-driven program for user interaction. The project serves as a practical demonstration of basic programming concepts and functions.

Uploaded by

satyam.kumarfab
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)
7 views12 pages

SK Computer Project

The document is a computer project by Satyam Kumar from Edify School, detailing various programming tasks including finding even and odd numbers, calculating factorials, simple interest, palindrome checking, reversing numbers, Armstrong numbers, and prime number checking. It includes code snippets and sample outputs for each task, along with a menu-driven program for user interaction. The project serves as a practical demonstration of basic programming concepts and functions.

Uploaded by

satyam.kumarfab
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/ 12

Computer

Project
By
Satyam Kumar
Grade XI
Edify School
Chikkabanavara
INDEX
Sr Name of Content Pg
No. No.
1. Even numbers between 3
1 to 10
2. Odd numbers between 3
1 to 10
3. Factorial of a number 4
4. Simple Interest 5
Calculator
5. Palindrome Number 6
6. Reverse a number 7
7. Armstrong Number 8
8. Prime Number 9
9. Menu Driven Program 10

Even Numbers between 1 to 10

Program
for Number in range (1,11):

if Number%2==0:

PAGE 1
print(Number)

Output
2

10

Odd Numbers between 1 to 10


Program
for Number in range (1,11):

if Number%2!=0:

print (Number)

Output
3

Factorial of a number
Program
num = int(input('Enter your Number '))

factorial = 1

PAGE 2
if num < 0:

print("Sorry, factorial does not exist for negative numbers")

elif num == 0:

print("The factorial of 0 is 1")

else:

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

factorial = factorial*i

print("The factorial of",num,"is",factorial)

Output
Enter your Number: 5

The factorial of 5 is 120

Simple interest calculator


Program
principal = float(input("Enter the principal amount: "))

rate = float(input("Enter the interest rate: "))

time = float(input("Enter the time period in years: "))

PAGE 3
interest = principal * rate/100 * time

print("The simple interest is: ", interest)

Output
Enter the principal amount: 100

Enter the interest rate: 10

Enter the time period in years: 2

The simple interest is: 20.0

Check if a String is Palindrome or Not


Program
st = input('Enter your word ')

j = -1

flag = 0

for i in st:

if i != st[j]:

PAGE 4
flag = 1

break

j=j-1

if flag == 1:

print("It is not a palindrome ")

else:

print("It is a palindrome")

Output
Enter your word wow

It is a palindrome

Reverse a Number
Program
num =int(input('Enter your number '))

reversed_num = 0

while num != 0:

digit = num % 10

reversed_num = reversed_num * 10 + digit

PAGE 5
num //= 10

print("Reversed Number: " + str (reversed_num))

Output
Enter your number :1234

Reversed Number: 4321

Check Armstrong Number


Program
num = int(input('Enter your number '))

order = len(str(num))

sum = 0

temp = num

while temp > 0:

digit = temp % 10

sum += digit ** order

PAGE 6
temp //= 10

if num == sum:

print(num,"is an Armstrong number")

else:

print(num,"is not an Armstrong number")

Output
Enter your number: 153

153 is an Armstrong number

Check Prime Number


Program
num = int(input('Enter your Number '))

if num > 1:

for i in range(2, (num//2)+1):

if (num % i) == 0:

print(num, "is not a prime number")

break

else:

print(num, "is a prime number")

PAGE 7
else:

print(num, "is not a prime number")

Output
Enter your Number: 139

139 is a prime number

Menu Driven Program


# Function to check if a number is a palindrome

def is_palindrome(num):

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

# Function to check if a number is an Armstrong number

def is_armstrong(num):

digits = str(num)

num_digits = len(digits)

PAGE 8
sum_of_powers = sum(int(digit) ** num_digits for digit in digits)

return sum_of_powers == num

# Function to reverse a number

def reverse_number(num):

return int(str(num)[::-1])

# Menu-driven program

def menu():

while True:

print("\nMenu:")

print("1. Check if a number is a Palindrome")

print("2. Check if a number is an Armstrong Number")

print("3. Reverse a number")

print("4. Exit")

choice = input("Enter your choice (1/2/3/4): ")

if choice == '1':

num = int(input("Enter a number to check if it's a palindrome: "))

if is_palindrome(num):

print(f"{num} is a palindrome.")

else:

print(f"{num} is not a palindrome.")

elif choice == '2':

PAGE 9
num = int(input("Enter a number to check if it's an Armstrong number: "))

if is_armstrong(num):

print(f"{num} is an Armstrong number.")

else:

print(f"{num} is not an Armstrong number.")

elif choice == '3':

num = int(input("Enter a number to reverse: "))

reversed_num = reverse_number(num)

print(f"The reverse of {num} is {reversed_num}.")

elif choice == '4':

print("Exiting the program.")

break

else:

print("Invalid choice, please try again.")

# Call the menu function

if __name__ == "__main__":

menu()

Sample run:
Menu:

1. Check if a number is a Palindrome

PAGE 10
2. Check if a number is an Armstrong Number

3. Reverse a number

4. Exit

Enter your choice (1/2/3/4): 1

Enter a number to check if it's a palindrome: 456

456 is not a palindrome.

PAGE 11

You might also like