Posts

Linked list in python

 class ll:     def __init__(self,n):         self.n=n         self.next=None node=ll(10) node.next=ll(20) node.next.next=ll(30) node.next.next.next=ll(44) count=0 new_node=ll(98) new_node.next=node.next node.next=new_node curr=node while(curr!=None):     print(curr.n,end=" ")     curr=curr.next  import java.util.Scanner; class Main {     public static void main(String[] args) { Scanner sc=new Scanner(System.in); int num=sc.nextInt(); int ornum=num; int sum=0; while(num>0){     int digit=num%10;     //int sum=0;     sum= sum + (digit * digit * digit);     num=num/10; }if(ornum==sum){ System.out.println("Is a armstrong");     }     else{         System.out.println("Is a not armstrong");     } } }fewf     

2 class parent class

 class person:     def __init__(self,name,age):         self.name=name         self.age=age class student(person):     def __init__(self,name,age,roll):         super().__init__(name,age)         self.roll=roll     def display(self):         print("student",self.name)         print("student",self.age)         print("student",self.roll) class employee(person):     def __init__(self,name,age,roll):         super().__init__(name,age)         self.id1=id1     def display(self):         print("employee",self.name)         print("employee",self.age)         print("employee",self.id1) n=int(input()) for i in range(n):     t=input()     if t=="student":         name...

queu in python

class queu():     def __init__(self):         self.l=[]     def push(self,val):         self.l.append(val)     def pop(self):         self.l.pop(0)     def peak(self):         for i in range(len(self.l)):             return self.l[0]     def emty(self):         for i in range(len(self.l)):             return len(self.l)==0              def display(self):         print(self.l) q=queu() q.push(10) q.push(20) q.push(40) q.push(100) q.display() q.pop() q.display() print(q.emty()) print(q.peak()) 

stack in python

 class stack():     def __init__(self):         self.l=[]     def push(self,val):         self.l.append(val)     def pop(self):         self.l.pop()     def peak(self):         for i in range(len(self.l)):             return self.l[-1]     def emty(self):         for i in range(len(self.l)):             return len(self.l)==0              def display(self):         print(self.l) s=stack() s.push(10) s.push(20) s.push(40) s.push(100) s.display() s.pop() s.display() print(s.emty()) s.display() print(s.peak())

expalin

 import java.util.Scanner; public class Main{     public static void main(String[]args){         Scanner s=new Scanner(System.in);         System.out.println("Enter no of rows");         int row=s.nextInt();         System.out.println("Enter no of cols");         int col=s.nextInt();         for (int i=1;i<=row;i++){             for(int space=1;space<=row-i;space++){                 System.out.print(" ");             }             for(int j=1;j<=2*i-1;j++){                 if(j==1||j==2*i-1){                 System.out.print("*");                 }               ...

class in java

 import java.util.Scanner; class employe{     String name;     int id;     int salary;     void display(){         System.out.println(name+" employe information");         System.out.println(salary+" salary");         System.out.println(id+" id");     } } public class Main{ public static void main(String[]args){ Scanner sc=new Scanner(System.in); System.out.println("employe e1 details");  employe e1=new employe();  e1.name=sc.nextLine();  e1.id=sc.nextInt();  e1.salary=sc.nextInt();  sc.nextLine();  System.out.println("employe e2 details");  employe e2=new employe();  e2.name=sc.nextLine();  e2.id=sc.nextInt();  e2.salary=sc.nextInt();  e1.display();  e2.display();  sc.close(); }} MULTIPLICATION OF TABLE UP TO GIVEN NUMBER import java.util.Scanner; public class Main{ public static void main(String[]args){ Scan...

parent class single and multiple

 class animal:     def eat(a):         print("eating")     def sleep(a):         print("sleeping") class animal1:     def eat1(a):         print("eating1")     def sleep1(a):         print("sleeping1") class dog(animal,animal1):     def bark(a):         print("barking") d=dog() d.eat1() d.bark() d.sleep1()