The above Python code is the steps for Selection Sort algorithm. It basically compares the 1st element with the rest of the elements in the
Category: Python
Python Functions
Functions are block of code to perform some task or return some value. Functions can be reuse by the programmer. Using formatted string instead of
Using Python’s tuple packing and unpacking to switch 2 variables
Tuple is somehow similar to a List in Python except that the elements in a tuple is immutable (cannot be change or modified throughout the
Random Number Generator and Linear Congruential Generator(LCG) using Python
Random number generated by Python are called pseudo random number. The pseudo random number generator (PRNG) algorithm by Python uses a starting point ( aka
Guess the number(integer) game
import random gameOver = Falsenum = random.randint(1,101) while gameOver== False: inputNum = input(‘Guess and enter the integer from 1 to 100…’) yourGuess= int(inputNum) if yourGuess
Get Premier League fixtures using Python
from urllib.request import urlopen from bs4 import BeautifulSoup from selenium import webdriver from selenium.webdriver.support.ui import Select from urllib.error import HTTPError import time address = ‘https://www.premierleague.com/fixtures’ try: url = urlopen(address) except HTTPError as ex: print(‘Url address is not right.’) print(ex) else: print(‘ok’) bs = BeautifulSoup(url, ‘html.parser’) driver = webdriver.Firefox() driver.get(address) time.sleep(3) cookies_btn = driver.find_elements_by_xpath(‘/html/body/section/div/div’)[0] cookies_btn.click() close_btn = driver.find_elements_by_xpath(‘//*[@id=”advertClose”]’)[0] close_btn.click() #select = text1 = driver.find_elements_by_class_name(‘matchList’)