toggle menu

Python Programming Examples

Python programming examples which covers the concepts including basic and simple python programs, number programs, string programs, List Programs, series programs etc.

2 students enrolled

Python programming examples which covers the concepts including basic and simple python programs, number programs, string programs, List Programs, series programs etc.

Simple Python Programs

1
Hello World Program
2
Add Two Numbers in Python
3
Check if a Number is Positive Negative or Zero in Python
4
Find the Square Root in Python
5
Check Whether the Input Character is an Alphabet in Python
6
Simple Interest in Python
7
Calculate the Area of a Triangle in Python
8
Compound Interest in Python
9
Solve Quadratic Equation in Python
10
Swap Two Variables in Python
11
Reverse a Given Number in Python
12
Calculate the Average of Numbers in a Given List
13
Print all Numbers in a Range Divisible by a Given Number
14
Generate a Random Number
15
Find the Sum of Digits in a Number
16
Find the Smallest Divisor of an Integer
17
Count the Number of Digits in a Number
18
Check if a Number is a Palindrome
19
Convert Kilometers to Miles
20
Convert Celsius To Fahrenheit
21
Check Leap Year
22
Find the Factorial of a Number

Mathematical Functions

1
Find the LCM of Two Numbers
2
Print all the Prime Numbers within a Given Range
3
Check if a Number is a Prime Number
4
Print Largest Even and Largest Odd Number in a List
5
Print Table of a Given Number
6
Generate all the Divisors of an Integer
7
Compute Prime Factors of an Integer
8
Take the Temperature in Celcius and Covert it to Farenheit
9
Read Height in Centimeters and then Convert the Height to Feet and Inches
10
Compute Simple Interest Given all the Required Values
11
Check if a Date is Valid and Print the Incremented Date if it is

Array Programs

1
Python Program to find sum of array
2
Python Program to find largest element in an array
3
Python Program to check if given array is Monotonic

Conditional Expressions

1
if-statement in python
2
if…else statement in python
3
if…else if…else statement in python

Loops

1
while-loop in python
2
for-loop in python

Python String

1
Replace all Occurrences of ‘a’ with $ in a String
2
Detect if Two Strings are Anagrams
3
Check Vowel or Consonant in Python
4
Take in a String and Replace Every Blank Space with Hyphen
5
Calculate the Length of a String Without Using a Library Function
6
Remove the Characters of Odd Index Values in a String
7
Calculate the Number of Words and the Number of Characters Present in a String

Python List

1
Find the Largest Number in a List
2
Put Even and Odd elements in a List into Two Different Lists
3
Merge Two Lists and Sort it
4
Sort the List According to the Second Element in Sublist
5
Find the Second Largest Number in a List
6
Find Element Occurring Odd Number of Times in a List
7
Remove the Duplicate Items from a List
8
Swap the First and Last Value of a List
9
Find the Intersection of Two Lists
10
Find the Union of two Lists

Python Dictionary

1
Remove the Given Key from a Dictionary
2
Multiply All the Items in a Dictionary
3
Sum All the Items in a Dictionary
4
Concatenate Two Dictionaries Into One
5
Add a Key-Value Pair to the Dictionary
6
Check if a Given Key Exists in a Dictionary or Not
7
Count the Frequency of Words Appearing in a String Using a Dictionary
8
Map Two Lists into a Dictionary
9
Form a Dictionary from an Object of a Class

Python Tuples

1
Maximum and Minimum K elements in Tuple
2
Join Tuples if similar initial element
3
Find the size of a Tuple in Python
4
Adding Tuple to List and vice – versa
5
Reversing a List in Python
6
Convert Nested Tuple to Custom Key Dictionary
7
Flatten tuple of List to tuple
8
Remove Tuples of Length K

Python Sets

1
Displays which Letters are in the First String but not in the Second
2
Check Common Letters in Two Input Strings
3
Count the Number of Vowels Present in a String using Sets
4
Displays which Letters are Present in Both the Strings
5
Displays which Letters are in the Two Strings but not in Both

Date Time Programs

1
Python program to get Current Time
2
Get Current Date and Time using Python
3
Python program to convert time from 12 hour to 24 hour format
4
Python program to find difference between current time and given time
5
Python Program to Create a Lap Timer
6
Find number of times every day occurs in a Year

File Handling

1
Count the Number of Words in a Text File
2
Read the Contents of a File
3
Count the Number of Lines in a Text File
4
Read a String from the User and Append it into a File
5
Count the Occurrences of a Word in a Text File
6
Copy the Contents of One File into Another
7
Reads a Text File and Counts the Number of Times a Certain Letter Appears in the Text File
8
Append the Contents of One File to Another File

Classes and Objects

1
Find the Area of a Rectangle Using Classes
2
Append, Delete and Display Elements of a List Using Classes
3
Create a Class and Get All Possible Subsets from a Set of Distinct Integers
4
Create a Class which Performs Basic Calculator Operations
5
Python Program to Create a Class and Compute the Area and the Perimeter of the Circle

Threads

1
Create a Thread using function
2
Create a Thread using a Class