Using Series in Python

import numpy as np
import pandas
from pandas import Series,DataFrame

obj=Series([3,6,9,12])
print(obj)
obj=Series([3,6,9,12],index=[0,1,2,3])
print(obj[1])

Advertisements
Posted in Python, Uncategorized | Leave a comment

Using Classes Python

class Employee:
empcount=0;
def __init__(self,name,salary,id=780):
self.name=name
self.salary=salary
self.id=id
def display(self):
print(“Employee name is “,self.name,”Employee salary is “,self.salary,”Id seen is “,self.id)

e=Employee(“Ashish”,200)
e.display()

Posted in Python, Uncategorized | Leave a comment

Using Dictionary

dict={‘Name’:’Ashish’,’Age’:25}
print(dict[‘Name’])
print(‘Age is ‘,dict[‘Age’])
print(len(dict))
dict.clear()
#Delete dictionary
del dict
#print(dict.name)

Posted in Python, Uncategorized | Leave a comment

Print Numbers from 1 to 10 and use while loop

tup1=(“physics”,”chemitry”)
print(tup1[0])
print(len(tup1))
print(max(tup1))
for letter in tup1:
print(letter)
i=0
while i != len(tup1):
print(tup1[i])
i=i+1

Posted in Python, Uncategorized | Leave a comment

Using unmodifiable list Java 9

package test;package test;
import java.util.Collections;import java.util.Iterator;import java.util.List;
public class listtest {
public static void main(String[] args) { // TODO Auto-generated method stub
List im=List.of(“one”,”two”,”three”); List imlist=Collections.unmodifiableList(im); imlist.add(“four”); Iterator itr=imlist.iterator(); while(itr.hasNext()) { System.out.println(itr.next()); } }
}

In this case if you try to add new number in list this will result in java.lang.UnsupportedOperationException

Posted in Java, Uncategorized | Leave a comment

Using List.of Java 9

package test;package test;
import java.util.Iterator;import java.util.List;
public class ListTest {
public static void main(String[] args) {
List im=List.of();

Iterator itr=im.iterator();

while(itr.hasNext()) {

System.out.println(itr.next());

}

}
}

Posted in Java, Uncategorized | Leave a comment

Open Browser using Python and without webdriver

import webbrowser
webbrowser.open(‘https://www.google.com/’)

Posted in Python, Uncategorized | Leave a comment