Technological advancements have lead to reduced effort. This makes Python programming language as one of the most sought out programming language due to its ease of access and readability. This also means a surge in the number of people experimenting with Python codes. In this blog, we will go through few of the most sought after fundamental python programs. Here is the list of same:
- Palindrome Program In Python
- Factorial Program In Python
- Fibonacci Series Program
- Armstrong Number Program In Python
- Calculator Program
- Patterns Program In Python
- Leap Year Program
- Prime Number Program In Python
- Program To Find Area In Python
- Program To Reverse A List
🐍 Ready to Unleash the Power of Python? Sign Up for Edureka’s Comprehensive Online Python Programming Training with access to hundreds of Python learning Modules and 24/7 technical support.
Palindrome Program In Python
def pal(num): x1 = num[::-1] if x1 == x: print('palindrome') else: print('not a palindrome') print(pal('edureka'))
Uncover the secrets of palindrome in Python and sharpen your coding skills with our step-by-step tutorial.
Factorial Program In Python
Factorial of a number is the product of all the positive numbers less than or equal to the number. The factorial of a number n is denoted by n!.
Following is the program to find the factorial of a number.
def fact(num): if num == 0: return num else: return num * fact(num - 1) print(fact(5))
Fibonacci Series
Following is a program to print a fibonacci series.
a = int(input('enter the first element')) b = int(input('enter the second element')) n = int(input('enter the number of elements ')) print(a,b, end=" ") while n-2: c = a + b a = b b = c print(c, end=" ") n = n-1
Armstrong Number Program In Python
It is a special number, If we sum the cube of each of the digits in an armstrong number it will be equal to the number itself.
Following is the program to check whether a number is an armstrong number or not.
num = int(input('enter the nuber')) s = 0 temp = num while temp > 0: c = temp % 10 s += c**3 temp //= 10 if s == num: print('armstrong number') else: print('not an armstrong number')
Calculator Program In Python
Following is the program to create a calculator
def add(a,b): return a+b def sub(a,b): return a-b def prod(a,b): return a * b def div(a,b): return a / b def si(p, r, t): return (p*r*t) / 100 def ci(p, r ,t): return p * pow((1 + r/100), t) def sqr(num): return num**2 def sqrt(num) return num**0.5 print(add(10,15)) #to add two numbers, similarly you can use other functions for other operations.
Patterns Program
Following is the program for patterns.
num = 5 a = (2 * num) - 2 for i in range(0, num): for j in range(0, a ): print(end=" ") for j in range(0, i+1) print('*' , end=" ") print(" ")
Leap Year Program
Following is the program to check if a year is a leap year
year = int(input('enter year')) if year % 400 == 0: print('it is a leap year') elif year % 4 == 0: print('it is a leap year') elif year % 100 == 0: print('not a leap year') else: print('not a leap year')
Prime Number Program
num = int(input('enter number')) for i range(2, num): if  num% i == 0: print('not a prime number") break else: print('prime number') break
Program To Print Areas
We will take the following shapes and try to calculate the area of all these shapes in python.
Following is the program to calculate areas
import math pi = math.pi def circle(radius): return pi * radius**2 def cube(side): return side**3 def cylinder(radius, height): return 2*pi*radius + 2*pi*height def sphere(radius): return 2*pi*(radius**2) print(circle(10)) #You can use other functions to calculate the areas of other shapes.
Following is the program to reverse a list
a = [1,2,3,4,5,6,7,8,9,10] print(a[: : -1]) #this will print the list in reverse.
have any questions? mention them in the comments, we will get back to you.