Sunday, August 20, 2017

python part 3

python part 2

python part 2

Python 3.6.1 (v3.6.1:69c0db5, Mar 21 2017, 17:54:52) [MSC v.1900 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> print("hello")
hello
>>> print("hii prakash")
hii prakash
>>> a=10
>>> print(a)
10
>>> name ="prakash"
>>> print(name)
prakash
>>> b=12.23
>>> print(b)
12.23
>>> a=12
>>> b=23
>>> c=a+b
>>> print(c)
35
>>> c=a-b
>>> print(c)
-11
>>> c=a*b
>>> print(c)
276
>>> c=a/b
>>> print(c)
0.5217391304347826
>>> c=a%b
>>> print(c)
12
>>> prakash=dev=puneet=abhi=akash=virat=tanya=rashi=animesh="BBD"
>>> print(abhi)
BBD
>>> print(animesh)
BBD
>>> print(virat)
BBD
>>> student,fee,father="prakash",12,"father"
>>> print(fee)
12
>>> print(father)
father
>>> 

PYTHON

                            PYTHON
1.open Source language
2.it was developed by Guido van Rossum.

featares of python
1. easy to learn
2. Simple synax
3. Huge nume of laibraries

Python is an object-oriented,
 high level language, interpreted,
 dynamic and multipurpose programming language.

 Python is derived from many other languages,
 including ABC, Modula-3,
 C, C++, Algol-68, SmallTalk, and
 Unix shell and other scripting languages.

Python is copyrighted. Like Perl,
 Python source code is now available
 under the GNU General Public License (GPL).

Video link   VIDEO

Saturday, August 19, 2017

Abstract and Interface

Abstract 

A class that is declared with abstract keyword, is known as abstract class in java. It can have abstract and non-abstract methods (method with body).
Abstraction is a process of hiding the implementation details and showing only functionality to the user.
A class that is declared as abstract is known as abstract class. It needs to be extended and its method implemented. It cannot be instantiated.
abstract class

abstract class A{} 
abstract method

A method that is declared as abstract and does not have implementation is known as abstract method.
Example abstract method

abstract void printStatus();//no body and abstract 
An interface in java is a blueprint of a class. It has static constants and abstract methods.


Interface 

The interface in java is a mechanism to achieve abstraction. There can be only abstract methods in the java interface not method body. It is used to achieve abstraction and multiple inheritance in Java.

Java Interface also represents IS-A relationship.

It cannot be instantiated just like abstract class.

Why use Java interface?

There are mainly three reasons to use interface. They are given below.

It is used to achieve abstraction.
By interface, we can support the functionality of multiple inheritance.
It can be used to achieve loose coupling.


Why multiple inheritance is not supported in java?

To reduce the complexity and simplify the language, multiple inheritance is not supported in java.

Consider a scenario where A, B and C are three classes. The C class inherits A and B classes. If A and B classes have same method and you call it from child class object, there will be ambiguity to call method of A or B class.


Since compile time errors are better than runtime errors, java renders compile time error if you inherit 2 classes. So whether you have same method or different, there will be compile time error now.

interface

abstract method


package javaapplication19;
abstract  class animal{
    abstract void eat();
abstract  void run();
public void body()
{
    System.err.println("two eye and two ear");
}
}
class lion extends animal{
    public void display(){
        System.out.println("king");
    }

    @Override
    void eat() {
        System.err.println("Meat");
    }

    @Override
    void run() {
        System.err.println("fast");
    }
}

class cow extends animal{
    public void display(){
        System.out.println("mother");
    }

    @Override
    void eat() {
        System.err.println("grass");
    }

    @Override
    void run() {
        System.err.println("slow");
    }
}
public class JavaApplication19 {

   
   
   
    public static void main(String[] args) {
       lion obj = new lion();
       obj.body();
       obj.eat();
       obj.display();
       obj.run();
       
       
    }
   
}

INTERFACE

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package javaapplication20;
interface mother{
    void money();
    void dis();
}
class father{
    public void money(){
        System.err.println("10000");
    }
    void disp(){
        System.err.println("m");
    }
}
class son extends father implements mother{
    public void display()
    {
        System.err.println("son");
    }

    @Override
    public void dis() {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }

   
}
public class JavaApplication20 {

    public static void main(String[] args) {
      son obj = new son();
      obj.money();
    }
   

}

Friday, August 18, 2017

Alphabet Patterns

A                 
AB
ABC
ABCD
ABCDE

E
DE
CDE
BCDE
ABCDE

A
BA
CBA
DCBA
EDCBA


E
ED
EDC
EDCB
EDCBA

ABCDE
ABCD
ABC
AB
A

ABCDE
BCDE
CDE
DE
E

EDCBA
DCBA
CBA
BA
A

E
DD
CCC
BBBB
AAAAA

1
2 3 2
3 4 5 4 3
4 5 6 7 6 5 4
5 6 7 8 9 8 7 6 5
6 7 8 9 0 1 0 9 8 7 6
7 8 9 0 1 2 3 2 1 0 9 8 7 
8 9 0 1 2 3 4 5 4 3 2 1 0 9 


1     1
 2   2 
  3 3  
   4   
  3 3  
 2   2 
1     1

Thursday, August 17, 2017

abstract


package javaapplication18;
abstract class animal{
    abstract void eat();
    abstract void run();
    void b(){
       
    }
    abstract  void a();
}
class lion extends animal{
    public void big()
    {
        System.out.println("king");
    }

    @Override
    void eat() {
        System.out.println("Meat");
    }

    @Override
    void run() {
        System.out.println("Fast");
      }

    @Override
    void a() {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }
}
class cow extends animal{

    @Override
    void eat() {
        }

    @Override
    void run() {
    }

    @Override
    void a() {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }
   
}

public class JavaApplication18 {
    public static void main(String[] args) {
     

    }
   
}

Wednesday, August 16, 2017

wap accept number and print in word. ex 101 print one hundred one

package javaapplication81;

import java.util.Scanner;

/**
 *
 * @author admin
 */
public class JavaApplication81 {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
                            Scanner sc=new Scanner(System.in);
                             String num[]={"one","two","three","four","five","six","seven","eight","nine"}; 
        // TODO code application logic here
                String num1[]={"ten","eleven","twelve","thirteen","fourteen","fifeteen","sixteen","seventeen","eighteen","nineteen"}; 
String num3[]={"ten","twenty","thirty","forty","fifty","sixty","seventy","eighty","ninety"};        
// TODO code application logic here
    int n; n=sc.nextInt();
     int q,r,c=0,a;a=n;int t,t1,h,h1,i,j,ten,ten1;
                while(n!=0)
                {
                    q=n/10;
                    r=n%10;
                    n=q;
                    c++;
                }
                System.out.println(c);
                if(c==4)
                {
                     t=a/1000;
                     t1=a%1000;
                     h=t1/100;
                     h1=t1%100;
                     ten=h1/10;
                     ten1=h1%10;
                     for(i=1;i<=9;i++)
                     {
                         if(t==i)
                         {
                     System.out.print(num[i-1]+" thousand ");
                }
    }
                      for(i=1;i<=9;i++)
                     {
                         if(h==i)
                         {
                     System.out.print(num[i-1]+" hundred ");
                }
    }
                      if(ten==1)
                      {
                      j=0;
                       for(i=11;i<=19;i++)
                     {
                         if(h1==i)
                         {
                     System.out.print(num1[j]);
                }
                         j++;
                 }
    
                }
                      else
                      {
                         for(i=1;i<=9;i++)
                         {
                             if(ten==i)
                             {
                                 System.out.print(num3[i-1]+" ");
                             }
                         }
                          for(i=1;i<=9;i++)
                         {
                             if(ten1==i)
                             {
                                 System.out.print(num[i-1]);
                             }
                         }
                         
                      }
    }
                 if(c==3)
                {
                    
                     h=a/100;
                     h1=a%100;
                     ten=h1/10;
                     ten1=h1%10;
                     
                      for(i=1;i<=9;i++)
                     {
                         if(h==i)
                         {
                     System.out.print(num[i-1]+" hundred ");
                }
    }
                      if(ten==1)
                      {
                      j=0;
                       for(i=10;i<=19;i++)
                     {
                         if(h1==i)
                         {
                     System.out.print(num1[j]);
                }
                         j++;
                 }
    
                }
                      else
                      {
                         for(i=1;i<=9;i++)
                         {
                             if(ten==i)
                             {
                                 System.out.print(num3[i-1]+" ");
                             }
                         }
                          for(i=1;i<=9;i++)
                         {
                             if(ten1==i)
                             {
                                 System.out.print(num[i-1]);
                             }
                         }
                         
                      }
    }
                  if(c==2)
                {
                     h1=a%100;
                     ten=a/10;
                     ten1=a%10;j=0;
                      for( i=11;i<=19;i++)
    {
        if(h1==i)
        {
                     System.out.print(num1[j]);  System.exit(0);
        }j++;
    }
                     
                         for(i=1;i<=9;i++)
                         {
                             if(ten==i)
                             {
                                 System.out.print(num3[i-1]+" ");
                             }}
                         
                         
                          for(i=1;i<=9;i++)
                         {
                             if(ten1==i)
                             {
                                 System.out.print(num[i-1]);
                             }
                         }
                         
                      }
                  if(c==1)
                  {
                      for(i=1;i<=9;i++)
                      {
                          if(a==i)
                          {
                              System.out.print(num[i-1]);
                          }
                      }
                  }
    
    
    
    
    
    
    }}