PYTHON PRACT CODES
PYTHON PRACT CODES
1] Personalized gree ng
if n == "circle":
r = float(input("Enter radius: "))
print("Area:", 3.1416 * r ** 2)
elif n == "rectangle":
l = float(input("Enter length: "))
w = float(input("Enter width: "))
print("Area:", l * w)
elif n == "triangle":
b = float(input("Enter base: "))
h = float(input("Enter height: "))
print("Area:", 0.5 * b * h)
else:
print("Invalid input!")
3] Gross salary of employee
basic=int(input(“Enter your salary : ”, basic)
HRA=0.1*basic
DA=0.7*basic
TA=0.3*basic
gross = (basic+HRA+DA+TA)
print(“Salary of employee is : ” ,gross)
7] Factorial generator
import math
if num > 1:
for i in range(2, int(num ** 0.5) + 1):
if num % i == 0:
print("Not Prime")
else:
print("Prime")