def is_even(number):
if number % 2 == 0:
return True
else:
return False
# Example usage:
num = int(input("Enter a number: "))
if is_even(num):
print(f"{num} is even.")
else:
print(f"{num} is not even.")
import re
def is_valid_gstin(gstin):
# Define regex pattern for GSTIN structure
pattern = r'^[0-9]{2}[A-Z]{5}[0-9]{4}[A-Z]{1}[1-9A-Z]{1}Z[0-9A-Z]{1}$'
# Match against pattern
if re.match(pattern, gstin):
return True
else:
return False
# Example usage
gstin = input("Enter GSTIN: ").upper()
if is_valid_gstin(gstin):
print(f"{gstin} is a valid GSTIN.")
else:
print(f"{gstin} is NOT a valid GSTIN.")
def calculate_income_tax(income):
"""
Calculate income tax based on tax slabs.
:param income: Annual taxable income
:return: Tax amount
"""
tax = 0
# Example tax slabs (Modify as per your country)
slabs = [
(250000, 0.00), # No tax for income up to 250,000
(500000, 0.05), # 5% for income between 250,001 - 500,000
(1000000, 0.20), # 20% for income between 500,001 - 1,000,000
(float('inf'), 0.30) # 30% for income above 1,000,000
]
previous_limit = 0
for limit, rate in slabs:
if income > previous_limit:
taxable_income = min(income, limit) - previous_limit
tax += taxable_income * rate
previous_limit = limit
else:
break
return tax
# Example usage
if __name__ == "__main__":
income = float(input("Enter your annual taxable income: "))
tax_amount = calculate_income_tax(income)
print(f"Income Tax Payable: {tax_amount:.2f}")
def depreciation_wdv(opening_value, rate, years):
"""Calculate depreciation using WDV method."""
value = opening_value
for y in range(1, years + 1):
dep = value * (rate / 100)
value -= dep
print(f"Year {y}: Depreciation = {round(dep,2)}, Closing WDV = {round(value,2)}")
return round(value, 2)
# Example usage
depreciation_wdv(100000, 15, 3)