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

Python Programs for Number Operations

The document outlines various Python programs that perform different tasks, including finding the largest number, checking for perfect and Armstrong numbers, determining palindromes, calculating LCM and HCF, generating Fibonacci series, implementing a simple calculator, calculating factorials, and printing patterns. Each program includes user input examples and expected outputs. The document serves as a guide for basic programming exercises in Python.

Uploaded by

shreyaspachhapur
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views3 pages

Python Programs for Number Operations

The document outlines various Python programs that perform different tasks, including finding the largest number, checking for perfect and Armstrong numbers, determining palindromes, calculating LCM and HCF, generating Fibonacci series, implementing a simple calculator, calculating factorials, and printing patterns. Each program includes user input examples and expected outputs. The document serves as a guide for basic programming exercises in Python.

Uploaded by

shreyaspachhapur
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

1) PROGRAM TO ACCEPT 3 NUMBERS AND PRINT THE LARGEST :

Enter Number:22
Enter Number:24
Enter Number:25
The Largest number is 25

2) PROGRAM TO CHECK IF A GIVEN NUMBER IS A PERFECT NUMBER OR NOT:


A) IF NO-
Enter the number:-21
21 is not a perfect number

B) IF YES-
Enter the number:-28
28 is a perfect number

3) PROGRAM TO CHECK IF A GIVEN NUMBER IS AN AMSTROANG NUMBER OR NOT:


A) IF NO-
Enter a three digit number:-379
379 is not an armstrong number

B) IF YES-
Enter a three digit number:371
371 is an armstrong number

4) PROGRAM TO PRINT AND CHECK IF A GIVEN NUMBER IS A PALINDROME NUMBER OR NOT:


A) IF NO-
Enter a number:23
23 is not a palindrome number

B) IF YES-
Enter a number:12121
12121 is a palindrome number

5) PROGRAM TO FIND THE SUM OF SERIES:

Enter the number:5


Enter n value (for x**n):2
Sum of first 2 terms: 31.0

6) PYTHON SCRIPT TO INPUT 2 NUMBERS AND PRINT THEIR LCM AND HCF:

Enter the number:2


Enter the number:8
The HCF of 2 and 8 is 2
The LCM of 2 and 8 is 8

7) PYTHON SCRIPT TO PRINT FIBONACCI SERIES FOR FIRST 20 ELEMENTS:

0
1
1
2
3
5
8
13
21
34
55
89
144
233
377
610
987
1597
2584
4181

8) PROGRAM TO IMPLEMENT A SIMPLE CALCULATOR FOR TWO INPUT NUMBERS:

ENTER TWO NUMBERS BELOW


Enter a number: 2
Enter a number: 8

CALCULATOR MENU
1. ADD
2. SUBTRACT
3. MULTIPLY
4. DIVIDE
5. EXIT
Enter choice (1-5): 1
SUM = 10

CALCULATOR MENU
1. ADD
2. SUBTRACT
3. MULTIPLY
4. DIVIDE
5. EXIT
Enter choice (1-5): 2
DIFFERENCE = -6

CALCULATOR MENU
1. ADD
2. SUBTRACT
3. MULTIPLY
4. DIVIDE
5. EXIT
Enter choice (1-5): 3
PRODUCT = 16

CALCULATOR MENU
1. ADD
2. SUBTRACT
3. MULTIPLY
4. DIVIDE
5. EXIT
Enter choice (1-5): 4
QUOTIENT = 0.25
CALCULATOR MENU
1. ADD
2. SUBTRACT
3. MULTIPLY
4. DIVIDE
5. EXIT
Enter choice (1-5): 5
INVALID CHOICE

9) PYTHON PROGRAM TO CALCULATE FACTORIALS:

Enter Number:5
Factorial of 5 is 120

10) PROGRAM TO PRINT 3 DIFFERENT PATTERNS GIVEN

A)12345
1234
123
12
1

B)A
AB
ABC
ABCD
ABCDE
ABCDEF

C)*
**
***
****

You might also like