#Example of __init__(), __del__(), class variable, object variable and their uses class Bbh: n= 10 # this is class variable def __init__ ( self , x): Bbh.n+= 20 # 1st use of class variable it will work for every object self .n+= 10 #2nd use of class variable it will work only once self .x=x # x is the object variable print ( "the value of object variable=" , x) print ( "the value of class variable=" , self .n) def __del__ ( self ): Bbh.n= 0 print ( "Object variable = " , self .x , " Class variable= " , self .n) # the above statement print the each of value of object variable # and value of last modified class variable # the __init__() like constructor in C++ will be executed automatically obj1=Bbh( 5 ) obj2=Bbh( 15 ) obj3=Bbh( 25 ) # del is use to free the memory and to execute the method __del__(). It is same as destructor in C++ # but in C++ it executed au...
#Finding Roots of a quardratic Equation import math a=int(input("Enter the value of a : ")) b=int(input("Enter the value of b : ")) c=int(input("enter the value of c : ")) dis=b**2-4*a*c # finding discriminant if(dis>0): print("Roots are Real and unequal") sq=math.sqrt(dis) r1=(-b+sq)/(2*a) r2=(-b-sq)/(2*a) elif(dis<0): print("Roots are Imaginary ") r1=complex(-b,math.sqrt(abs(dis)))/(2*a) r2 = complex(-b, -math.sqrt(abs(dis))) / (2 * a) else: print("Roots are Real and Equal") r1 = -b / (2 * a) r2 = r1 print("Roots are : r1=", r1, ", r2=", r2)
#Find the area of triangle import math a= int ( input ( "Enter the length of first side : " )) b= int ( input ( "Enter the length of second side : " )) c= int ( input ( "Enter the lenth of third side : " )) if ((a+b)>c and (c+a)>b and (b+c)>a): s=(a+b+c)/ 2 Area=math.sqrt(s*(s-a)*(s-b)*(s-c)) print ( "Area of the triangle : " , Area) else : print ( "Invalid Triangle" ) Output: Run 1: Enter the length of first side : 2 Enter the length of second side : 2 Enter the lenth of third side : 6 Invalid Triangle Run 2: Enter the length of first side : 6 Enter the length of second side : 4 Enter the lenth of third side : 7 Area of the triangle : 11.976539567003485
#Program to check whether a number is Armstrong or Not n=int(input("Enter a number")) s=0 n1=n while(n>0): r=n%10 s=s+(r**3) n=n/10 if(s==n1): print(n1," is Armstrong Number") else: print(n1," is not Armstrong Number")
Ternary operator and the lamda function in Python: a=int(input("Enter first no ")) b=int(input("Enter second no ")) #Ternary operator used with Lambda function max=lambda a,b: a if a>b else b print("Biggest no. ",max(a,b)) #Simply use of ternary operator in Python print("Smallest no. ", a if a<b else b) # you can use this type also min=a if a<b else b print("Smallest no. ", min)
// PALINDROME NUMBER #include <stdio.h> void main () { int n, n1, r, s; printf ("Enter any number "); scanf("%d",&n); n1=n; while(n1!=0) { r=n%10; n=n/10; s=s*10+r; } if (s==n) printf("%d is Palindrome ",n); else printf("%d is not Palindrome ",n); }
Questions: Bus, Ring and Star topology এর মধ্যে পার্থক্য লেখ। Mesh topology তে 40 টি node থাকলে মোট তারের সংখ্যা নির্ণয় কর। Mesh topology তে প্রতিটি node এ CONNECTION এর সংখ্যা কতো? Ring topology তে কি পদ্ধতিতে তথ্য আদান প্রদান করা হয়? Backbone কাকে বলে? Star topology এর দুটি অসুবিধা লেখ।