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

Computer Project

The document contains several programming examples in Python, including finding even and odd numbers between 1 to 10, calculating the factorial of a number, computing simple interest, checking if a string is a palindrome, reversing a number, checking for Armstrong numbers, and determining if a number is prime. Each example includes the code and sample output for clarity. The document serves as a practical guide for basic programming concepts and operations.

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)
2 views8 pages

Computer Project

The document contains several programming examples in Python, including finding even and odd numbers between 1 to 10, calculating the factorial of a number, computing simple interest, checking if a string is a palindrome, reversing a number, checking for Armstrong numbers, and determining if a number is prime. Each example includes the code and sample output for clarity. The document serves as a practical guide for basic programming concepts and operations.

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/ 8

Computer Project

Khouneesh Raut
Even Numbers between 1 to 10
Program
for Number in range (1,11):

if Number%2==0:

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

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

factorial = 1

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 17

The factorial of 17 is 355687428096000

PAGE 2
Simple intreat 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: "))

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

PAGE 3
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]:

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

PAGE 4
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

num //= 10

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

Output
Enter your number 54336282

Reversed Number: 28263345

PAGE 5
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

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

PAGE 6
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")

else:

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

PAGE 7

You might also like