86% found this document useful (7 votes)
45K views

20 Python Programs

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
86% found this document useful (7 votes)
45K views

20 Python Programs

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
You are on page 1/ 8

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:

You might also like