Download as pdf or txt
Download as pdf or txt
You are on page 1of 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