Posts

calculator in java with actionListener and KeyListener

Image
//Calculator.java import java.awt.*; import java.awt.event.*; class CalculatorDemo extends Frame implements ActionListener,KeyListener  { Panel p1,p2; Label lblR; Button btn7,btn8,btn9,btnA,btn4,btn5,btn6,btnS,btn1,btn2,btn3,btnM,btn0,btnC,btnE,btnD; double x=0.0,y=0.0,z=0.0; int op=0; public CalculatorDemo() { super("Calculator Demo"); addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent we) { System.exit(0); } } ); setSize(300,500); setResizable(false); setBounds((1366/2)-(300/2),(768/2)-(500/2),300,500); p1=new Panel(); p2=new Panel(); p1.setFont(new Font("Serif",Font.PLAIN,50)); p2.setFont(new Font("Serif",Font.BOLD,30)); lblR=new Label("0",Label.RIGHT); btn7=new Button("7"); btn8=new Button("8"); btn9=new Button("9"); btnA=new Button("+"); ...
automate the boring stuff Regex ¶ In [ ]: print ( 'Hello' . rjust ( 20 , '*' )) print ( 'Hello' . ljust ( 20 , '*' )) print ( 'Hello' . center ( 20 , '*' )) import re phoneNumberReg = re . compile ( r '\+\d\d\-\d\d\d\d\d\d\d\d\d\d' ) mo = phoneNumberReg . search ( 'Sumit sarkar +91-7407227346' ) print ( mo . group ()) In [ ]: spam = { 'name' : 'sumit' , 'surname' : 'sarkar' , 'education' :{ 'school' : 'DHS' , 'University' : 'MAKAUT' }, 'height' : '5 ft.10 inch' } for k , v in spam . items (): print ( k , "is" , v ) print ( str ( spam [ 'education' ][ 'school' ])) 'DHS' in spam [ 'education' ] . values () 'DHS' in spam [ 'education...