94% found this document useful (16 votes)
53K views8 pages

20 Python Programs with Outputs

This document provides 20 Python programs that cover a range of tasks including: calculating sums, differences, factorials, and patterns of numbers; reversing, slicing, and adding strings; checking for even/oddness, primes, and leap years; converting between Celsius and Fahrenheit; and finding areas of triangles and sums of natural numbers. The programs have brief descriptions and provide sample inputs and outputs to demonstrate their functions.

Uploaded by

uplifter40
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
94% found this document useful (16 votes)
53K views8 pages

20 Python Programs with Outputs

This document provides 20 Python programs that cover a range of tasks including: calculating sums, differences, factorials, and patterns of numbers; reversing, slicing, and adding strings; checking for even/oddness, primes, and leap years; converting between Celsius and Fahrenheit; and finding areas of triangles and sums of natural numbers. The programs have brief descriptions and provide sample inputs and outputs to demonstrate their functions.

Uploaded by

uplifter40
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
  • 1. Sum of Two Numbers
  • 2. Subtract Numbers
  • 3. Print Table
  • 4. Factorial of Any Number
  • 5. Sum of N Natural Numbers
  • 6. Reverse a String
  • 9. Check for Zero
  • 8. Add Two Strings
  • 7. Even or Odd
  • 11. Print Pattern
  • 10. String Slice
  • 12. Prime or Composite
  • 13. Largest of Three
  • 14. Celsius to Fahrenheit
  • 16. Leap Year Check
  • 15. Area of Triangle
  • 17. Number Pattern
  • 18. Double Output
  • 20. Sum of Odd Numbers
  • 19. Print String Multiple Times

20 PYTHON PROGRAMS

1. Python program to find sum of two numbers:


Input:

Output:

2. Python program to subtract numbers:


Input:

Output:

3. Python program to print table of any number:


Input:
Output:

4. Python program to find factorial of any number:


Input:

Output:

5. Write python program to find sum of n natural numbers:


Input:

Output:

6. Write python program to reverse a string:


Input:

Output:

7. Write python program find even or odd:


Input:

Output:

8. Python program to add two strings:


Input:

Output:

9. Python program to check input value contain 0 or not:


Input:
10. Python program for string slice:
Input:

Output:

11. Python program to print following pattern:

Input:

Output:
12. Python program to check whether the given number is prime or
composite:
Input:

Output:

13. Python code to find largest number among greatest number:


INPUT:

OUTPUT:
14. Python code to convert Celsius to Fahrenheit:
INPUT:

OUTPUT:

15. Python program to find area of triangle:


INPUT:

OUTPUT:

16. Python code to know whether the given year is leapyear or not:
INPUT:
OUTPUT:

17. Python program to get this output that is given below:


OUTPUT:

INPUT:

18. Python code to get this output that is given below:


OUTPUT:

INPUT:
19. Python program to print single strings multiple times:
INPUT:

OUTPUT:

20. Python program to find sum of odd natural numbers till 20:
INPUT:

OUTPUT:

20 PYTHON PROGRAMS 
1. Python program to find sum of two numbers: 
Input: 
  
 
 
2. Python program to subtract numbers: 
Inp
Output: 
 
 
4. Python program to find factorial of any number: 
Input: 
 
 
Output: 
 
 
5. Write python program to find sum
Input: 
 
Output: 
 
7. Write python program find even or odd: 
Input: 
 
Output: 
 
8. Python program to add two strings: 
I
10. Python program for string slice: 
Input: 
 
Output: 
 
11. Python program to print following pattern: 
 
Input: 
 
Output
12. Python program to check whether the given number is prime or 
composite: 
Input: 
 
Output: 
 
13. Python code to find la
14. Python code to convert Celsius to Fahrenheit: 
INPUT: 
 
OUTPUT: 
 
15. Python program to find area of triangle: 
INPUT
OUTPUT: 
 
17. Python program to get this output that is given below: 
OUTPUT: 
 
INPUT: 
 
18. Python code to get this outpu
19. Python program to print single strings multiple times: 
INPUT: 
 
OUTPUT: 
 
20. Python program to find sum of odd natura

You might also like