Posts

opening sites with PYTHON

Image
"webbrowser" is a module in python which allows to display web-based documents to users. Instal lation: "pip install webbrowser" Functions: Here are some of the functions of webbrowser module: * webbrowser.open(url) - to open the given url * webbrowser.open_new(url) - to open the given url in a new window * webbrowser.open_new_tab(url) - to open the given url in a new tab * webbrowser.get(browserName) - to open the given url in a specific browser(chrome, Firefox, etc) 1.webbrowser.open(url) This function is used to open the given url in any browser. Syntax : 1. import webbrowser 2. webbrowser.open(" https://pyiseasy.blogspot.com ") 2.webbrowser.open_new(url) This function is used to open the given url in a new window. Syntax : 1. import webbrowser 2. webbrowser.open_new(" https://pyiseasy.blogspot.com ") 3.webbrowser.open_new_tab(url) This function is used to open the given url in a new window. Syntax : 1. import webbrowser 2. webbro...

Shorten your URL in 3 lines using PYTHON

Image
 * About The Library : "pyshorteners" is a Python library to help you short and expand urls using the most famous URL Shorteners availables. * Simple Code : 1. import pyshorteners 2. s = pyshorteners . Shortener () 3. print ( s . tinyurl . short ( "pyiseasy.blogspot.com" ))

Simple Calculator (Tkinter)

Image
  Required libraries:   tkinter ( pip install tkinter ) Explanation:   modules imported:-     1. from tkinter import * - importing every function from tkinter library     2.messagebox - to show any popup message calculator class:-     1.making basic tkinter window and giving required details(background colours, geometry, etc.)     2.frame 1 (titleFrame) :- the first frame only contains title ("gCalc") of the calculator     3.frame 2 (workFrame) :- it have all the main stuff          i. entryPlace : entry widget to write the equation          ii. "=" button : button to evaluate the equation entered in the entryPlace and then print answer on it     4. calculate function :-          i. try and except : NameError exception is handled(if user will enter an invalid equation, it will show error in a ...

Language Translation in PYTHON

googletrans :     googletrans is a free and unlimited Python library that implemented Google Translate API. Installation  : pip install googletrans Starter code (with explanation) : 1. from googletrans import Translator 2. trans = Translator() 3. t = trans.translate("Bom Dia", src = "pt", dest = "en") 4. print(f"Source : {t.src}") 5. print(Destination : {t.dest}") 6. print(" {t.origin} --> {t.text}") Explanation : 1. Importing "Translator" function from googletrans library. 2. Making a "trans" object for "Translator()" class. 3. ".translate" is the function used for translating a given string to destination language.   "Bom Dia" is the string to be translated, in "src" attribute source language's code (i.e. the language of given string) and in "dest" attribute, destination language code is given. 4. "t.src" returns source language . 5. "t.de...