0% found this document useful (0 votes)
4 views3 pages

Python Programs: Odd/Even, Factorial, Armstrong

The document contains three Python programs: the first checks if a number is odd or even, the second calculates the factorial of a number, and the third determines if a number is an Armstrong number. Each program includes sample input and output to demonstrate functionality. The programs utilize basic control structures and arithmetic operations.
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)
4 views3 pages

Python Programs: Odd/Even, Factorial, Armstrong

The document contains three Python programs: the first checks if a number is odd or even, the second calculates the factorial of a number, and the third determines if a number is an Armstrong number. Each program includes sample input and output to demonstrate functionality. The programs utilize basic control structures and arithmetic operations.
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

Program 1: Check Odd or Even

Program:

num = int(input("Enter a number: ")) if num % 2 == 0: print("Even


Number") else: print("Odd Number")

Output:

Enter a number: 7
Odd Number
Program 2: Factorial of a Number
Program:

num = int(input("Enter a number: ")) fact = 1 for i in range(1, num + 1):


fact = fact * i print("Factorial =", fact)

Output:

Enter a number: 5
Factorial = 120
Program 3: Armstrong Number
Program:

num = int(input("Enter a number: ")) sum = 0 temp = num while temp > 0:
digit = temp % 10 sum = sum + digit ** 3 temp = temp // 10 if sum == num:
print("Armstrong Number") else: print("Not an Armstrong Number")

Output:

Enter a number: 153


Armstrong Number

You might also like