#Define a function that computes the length of a given list or string. def Create_list(): word=[] try: n=int(input(" Enter the no element you want in list : ")) for i in range(0,n): ele=int(input(" Element : {} ".format(i))) word.append(ele) print(word) sum=0 for i in word: sum=sum+i print("The Sum of the Total element in the list = ",sum) except Exception as e: print(e) num=int(input("\n\n ENter the NUmber to check the given number is even or odd ")) def Even_odd(): try: if num%2==0: print( "\nEven number" ) else: printf("\n Odd number") except Exception as e: print(e) def Division(): while 1: try: num1=int(input(" Enter The dividend ")) res=0 num2=int(input(" Enter The divisor")) res=num1/num2 print(res) except Exception as e: print(e) break #prog 3 def agenow(): while 1: val=input(" Enter your birth Year and get your age now ") try: int(val) res1=0 curr=2022 res1=curr-val print(" You are {} year old ".format(res1)) except ValueError: print(" Enter The Year in yyyy Format only .... ") break while 1: print("---------- Python Practical Batch 2 --------") print("--------------- Practical NO 8 -------------") print(" From: 11 am to 1 pm Date: 24/08/2023 ") print("\n\n\n") print("------- Exceptional Handling Program ---- ") print("\n\n") print(" 1. Create A List In The Python ") print(" 2. Check Even Odd In The Python ") print(" 3. Check DIvision In The Python ") print(" 4. Check your Year by Date of Birth In The Python ") op=int(input("\n Enter Your Choice To perform The Program "))
#Define a function that computes the length of a given list or string.
ReplyDeletedef Create_list():
word=[]
try:
n=int(input(" Enter the no element you want in list : "))
for i in range(0,n):
ele=int(input(" Element : {} ".format(i)))
word.append(ele)
print(word)
sum=0
for i in word:
sum=sum+i
print("The Sum of the Total element in the list = ",sum)
except Exception as e:
print(e)
num=int(input("\n\n ENter the NUmber to check the given number is even or odd "))
def Even_odd():
try:
if num%2==0:
print( "\nEven number" )
else:
printf("\n Odd number")
except Exception as e:
print(e)
def Division():
while 1:
try:
num1=int(input(" Enter The dividend "))
res=0
num2=int(input(" Enter The divisor"))
res=num1/num2
print(res)
except Exception as e:
print(e)
break
#prog 3
def agenow():
while 1:
val=input(" Enter your birth Year and get your age now ")
try:
int(val)
res1=0
curr=2022
res1=curr-val
print(" You are {} year old ".format(res1))
except ValueError:
print(" Enter The Year in yyyy Format only .... ")
break
while 1:
print("---------- Python Practical Batch 2 --------")
print("--------------- Practical NO 8 -------------")
print(" From: 11 am to 1 pm Date: 24/08/2023 ")
print("\n\n\n")
print("------- Exceptional Handling Program ---- ")
print("\n\n")
print(" 1. Create A List In The Python ")
print(" 2. Check Even Odd In The Python ")
print(" 3. Check DIvision In The Python ")
print(" 4. Check your Year by Date of Birth In The Python ")
op=int(input("\n Enter Your Choice To perform The Program "))
if op==1:
Create_list()
elif op==2:
Even_odd()
elif op==3:
Division()
elif op==4:
agenow()
else:
print(" Invalid Input !!! ")
break