Python Programs (Term-I &
Term-II)
Basic Python and Data Science
Programs
Check Prime Number
num = int(input("Enter a number: "))
if num > 1:
for i in range(2, num):
if num % i == 0:
print(num, "is not a prime number")
break
else:
print(num, "is a prime number")
else:
print(num, "is not a prime number")
Check Lowercase or Uppercase
ch = input("Enter a character: ")
if [Link]():
print("Uppercase")
elif [Link]():
print("Lowercase")
else:
print("Not an alphabet")
Maximum of Three Numbers
a = int(input("Enter first number: "))
b = int(input("Enter second number: "))
c = int(input("Enter third number: "))
print("Maximum number is:", max(a, b, c))
Multiplication Table
num = int(input("Enter a number: "))
for i in range(1, 11):
print(num, "x", i, "=", num * i)
Calendar Display
import calendar
yy = int(input("Enter year: "))
mm = int(input("Enter month: "))
print([Link](yy, mm))
Voting Eligibility
age = int(input("Enter your age: "))
if age >= 18:
print("Eligible to vote")
else:
print("Not eligible to vote")
Menu Based Calculator
print("1. Addition")
print("2. Subtraction")
print("3. Multiplication")
print("4. Division")
choice = int(input("Enter choice (1-4): "))
a = int(input("Enter first number: "))
b = int(input("Enter second number: "))
if choice == 1:
print("Result =", a + b)
elif choice == 2:
print("Result =", a - b)
elif choice == 3:
print("Result =", a * b)
elif choice == 4:
if b != 0:
print("Result =", a / b)
else:
print("Division by zero not allowed")
else:
Day of Week
um = int(input("Enter a number (1-7): "))
= ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sund
<= day_num <= 7:
print("Day is:", days[day_num - 1])
print("Invalid number")
Even or Odd
num = int(input("Enter a number: "))
if num % 2 == 0:
print("Even number")
else:
print("Odd number")
Area of Circle
import math
r = float(input("Enter radius of circle: "))
area = [Link] * r * r
print("Area of circle =", area)
Mean, Median, Mode, Std Dev
import statistics as st
speed = [99,86,87,88,111,86,103,87,94,78,77,85,86]
print("Mean =", [Link](speed))
print("Median =", [Link](speed))
print("Mode =", [Link](speed))
print("Standard Deviation =", [Link](speed))
Bar Chart
import [Link] as plt
Name = ["Riya", "Priya", "Ranak", "Rita"]
Marks = [50, 70, 90, 70]
[Link](Name, Marks)
[Link]("Students")
[Link]("Marks")
[Link]("Class X Mathematics Marks")
[Link]()
Pie Chart
import [Link] as plt
Name = ["Riya", "Priya", "Ranak", "Rita"]
Marks = [50, 70, 90, 70]
[Link](Marks, labels=Name, autopct="%1.1f%%")
[Link]("Marks Distribution")
[Link]()
Line Plot
import [Link] as plt
x = [1, 2, 3, 4, 5]
y = [2, 4, 6, 8, 10]
[Link](x, y, marker="o")
[Link]("X-axis")
[Link]("Y-axis")
[Link]("Line Plot Example")
[Link]()
Histogram
import [Link] as plt
data = [5, 10, 10, 20, 20, 20, 30, 30, 40, 50, 50, 50, 60, 70]
[Link](data, bins=7, edgecolor="black")
[Link]("Value")
[Link]("Frequency")
[Link]("Histogram Example")
[Link]()
Scatter Plot
import [Link] as plt
x = [5, 7, 8, 7, 6, 9, 5, 6, 7, 8]
y = [99, 86, 87, 88, 100, 86, 103, 87, 94, 78]
[Link](x, y)
[Link]("X values")
[Link]("Y values")
[Link]("Scatter Plot Example")
[Link]()