📖 Practical Guide
140+ Basic Python Programs
A collection of 140+ practical Python programs ranging from simple math to complex algorithms, compiled for interview preparation and fundamental practice.
● Beginner
📖 Based on: Basic Python Programs (Drive Resource)
📋 Table of Contents
1 · Basic Programs
Addition
num1 = float(input("Enter first number: ")) num2 = float(input("Enter second number: ")) sum = num1 + num2 print(f"The sum is {sum}")
Quadratic Equation
import cmath a, b, c = 1, 5, 6 d = (b**2) - (4*a*c) sol1 = (-b-cmath.sqrt(d))/(2*a) sol2 = (-b+cmath.sqrt(d))/(2*a) print(f"The solutions are {sol1} and {sol2}")
2 · Control Flow
Leap Year
year = 2024 if (year % 400 == 0) and (year % 100 == 0): print("Leap Year") elif (year % 4 == 0) and (year % 100 != 0): print("Leap Year") else: print("Not a Leap Year")
3 · Armstrong Numbers
Check Armstrong
num = 153 sum = 0 temp = num while temp > 0: digit = temp % 10 sum += digit ** 3 temp //= 10 if num == sum: print(num, "is an Armstrong number") else: print(num, "is not an Armstrong number")