Posts

Selenium

  Selenium is a great tool for browser testing, web automation, and web scraping. Selenium can control most of the modern web browsers. i.e., Firefox, Chrome, Chromium, Opera, Apple Safari. To control a browser, Selenium needs a tool called Web driver. Most of the modern browser vendors provide the Web driver software for their web browsers. Downloading Python bindings for Selenium, Check this link: https://selenium-python.readthedocs.io/installation.html PROGRAM 1: AMAZON LOGIN from selenium import webdriver import time from selenium.webdriver.common.keys import Keys web=webdriver.Chrome("D:\chromedriver") web.get("https://www.amazon.com/ap/signin?openid.pape.max_auth_age=0&openid.return_to=https%3A%2F%2Fwww.amazon.com%2F%3Fref_%3Dnav_ya_signin&openid.identity=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select&openid.assoc_handle=usflex&openid.mode=checkid_setup&openid.claimed_id=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fid...

ASSOCIATIVE PROPERTY IN FUZZY SET

   ASSOCIATIVE PROPERTY IN FUZZY SET def UNION(A, B):   result = dict()   for A_key, B_key in zip(A, B):     A_val = A[A_key]     B_val = B[B_key]     # Union     if A_val > B_val:       result[A_key]=A_val     else:       result[B_key]=B_val   return result def check(A, B):   for A_key, B_key in zip(A, B):     A_val = A[A_key]     B_val = B[B_key]     if A_val != B_val:       return False   return True A = dict() B = dict() C = dict() A={"A1": 0.4,"A2": 0.7,"A3": 0.3,"A4": 0.6} B={"B1": 0.5,"B2": 0.6,"B3": 0.6,"B4": 0.4} C={"B1": 0.1,"B2": 0.8,"B3": 0.3,"B4": 0.6,} Y1 = UNION(UNION(A, B), C) Y2 = UNION(A, UNION(B, C)) print("=======Result===========") print("Y1: ",Y1) print("y2: ",Y2) print(check(Y1, Y2))           https://www.thepr...

UNION INTERSECTION COMPLEMENT SET DIFFERENCE OF DICTIONARIES IN PYTHON

UNION INTERSECTION COMPLEMENT SET DIFFERENCE OF DICTIONARIES IN PYTHON def inp(n):     d1={}     print("Enter for Fuzzy set")     for i in range(n):         key= input("Enter key value: ")         value= float(input("Enter value for key : "))         d1[key]=value     return d1 def ui():     d1={}     d2={}     d3={}     d4={}     n=int(input("Enter the limit: "))     print("Enter for First Fuzzy set")     d1=inp(n)               print("Enter for second Fuzzy set")     d2=inp(n)     for (x,y), (x2,y2) in zip(d1.items(), d2.items()):         if y > y2:             d3[x]=y    ...

FOR LOOP WITH ZIP FUNCTION IN PYTHON

  Using the Python zip() Function for Parallel Iteration       Python’s zip() function creates an iterator that will aggregate elements from two or more iterables. You can use the resulting iterator to quickly and consistently solve common programming problems, like creating dictionaries . In this tutorial, you’ll discover the logic behind the Python zip() function and how you can use it to solve real-world problems. By the end of this tutorial, you’ll learn: How zip() works in both Python 3 and Python 2 How to use the Python zip() function for parallel iteration How to create dictionaries on the fly using zip()     Understanding the Python zip() Function zip() is available in the built-in namespace . If you use dir() to inspect __builtins__ , then you’ll see zip() at the end of the list: >>> dir ( __builtins__ ) ['ArithmeticError', 'AssertionError', 'AttributeError', ..., 'zip'] You can see that 'zip' is the last ent...

INPUT FOR DICTIONARY IN PYTHON

how to take input for dictionary in python    >>> fruits = {} >>> key1 = input("Enter first key for fruits:") Enter first key for fruits:a >>> value1 = input("Enter first value for fruits:") Enter first value for fruits:apple >>> key2 = input("Enter second key for fruits:") Enter second key for fruits:b >>> value2 = input("Enter second value for fruits:") Enter second value for fruits:banana >>> fruits[key1] = value1 >>> fruits {'a': 'apple'} >>> fruits[key2] = value2 >>> fruits {'a': 'apple', 'b': 'banana'} >>># Same variable names for keys and values can be used if used inside a loop like this >>> fruits.clear() >>> fruits {} >>> for i in range(2):     key = input("Enter key for fruits:")     value = input("Enter value for fruits:")     fruits[key] = value      E...

NUMPY

  What is NumPy? NumPy is a Python library used for working with arrays. NumPy is a general-purpose array-processing package. It provides a high-performance multidimensional array object, and tools for working with these arrays. It also has functions for working in domain of linear algebra, fourier transform, and matrices. NumPy was created in 2005 by Travis Oliphant. It is an open source project and you can use it freely. NumPy stands for Numerical Python.     Why Use NumPy? In Python we have lists that serve the purpose of arrays, but they are slow to process. NumPy aims to provide an array object that is up to 50x faster than traditional Python lists. The array object in NumPy is called ndarray , it provides a lot of supporting functions that make working with ndarray very easy. Arrays are very frequently used in data science, where speed and resources are very important. Data Science: is a branch of computer science where we study how to store, u...