Python Bittu
Python Bittu
ith help of Command 8. b) Write a python program to check vote eligibility of a person
GCD of two Numbers using for Loop Line Arguments to display the Word Count.
def is_eligible_to_vote(age):
def gcd_for_loop(a, b): import sys return age >= 18
gcd = 1
for i in range(1, min(a, b) + 1): if len(sys.argv) > 1: age = 20
if a % i == 0 and b % i == 0: filename = sys.argv[1] print("Eligible to vote:", is_eligible_to_vote(age))
gcd = i with open(filename, 'r') as file:
return gcd text = file.read() ======================================================
word_count = len(text.split())
a = 48 print("Word count:", word_count) 9. a) Develop a python program to Display Calendar
b = 18
print("GCD using for loop:", gcd_for_loop(a, b)) =========================================== import calendar
COMPANY PORUPPU
def matrix_product(A, B): if year % 100 == 0:
result = [[0 for _ in range(len(B[0]))] for _ in range(len(A))] if year % 400 == 0:
for i in range(len(A)): return True
for j in range(len(B[0])): else:
for k in range(len(B)): return False
result[i][j] += A[i][k] * B[k][j] else:
return result
return False
YETRU KOLLATHU
B = [[5, 6], [7, 8]]
print("Product of matrices:", matrix_product(A, B)) year = 2024
print(f"The year {year} is a leap year:", is_leap_year(year))
==============================================