Thursday, November 21, 2019

Make Simple Calculator Program in Python

python-calculator tech justice
In this program, we ask the user to choose the desired operation. Options 1,2,3 and 4 are valid. Two numbers are taken and an if...elif...else branching is used to execute a particular section. User-defined functions add(), subtract(), multiply() and divide() evaluate respective operations. Source Code Output  

Simple Encryption and Decryption Python

Simple Encryption and Decryption tech justice
Simple example of encryption text simple encryption.py Simple example of┬ádecryption text simple decryption.py   source,source,edu

Python Generators

Python-Generator-Tech-Justice
There was a lot of overhead in building an iterator in Python; we had to implement a class with__iter__() and __next__() method, keep track of internal states, raise StopIteration when there was no values to be returned etc. This is both lengthy and counter...

Python Identifier and Keywords

Python Keywords and Identifier Tech Justice
Keywords Keywords are the reserved words in Python. We cannot use a keyword as variable name, function name or any other identifier. They are used to define the syntax and structure of the Python language. In Python, keywords are case sensitive. There are 33 keywords in...

Replace String in Python

Replace String in Python tech justice
Often you'll have a string (str object), where you will want to modify the contents by replacing one piece of text with another. In Python, everything is an object - including strings. This includes the str object. Luckily, Python's string module comes with a...

Python Loop

loops python tech justice
The for loop in Python is used to iterate over a sequence (list, tuple, string) or other iterable objects. Iterating over a sequence is called traversal. Syntax of Loop Here, val is the variable that takes the value of the item inside the sequence on each...

Python Operator Overloading

Python-Operator-Overloading
Python operators work for built-in classes. But same operator behaves differently with different types. For example, the + operator will, perform arithmetic addition on two numbers, merge two lists and concatenate two strings. This feature in Python, that allows same operator to have different...

Get the Geo Location of an IP Address Python

python Get the Geo Location of an IP Address Python tech justice.jpg
Geolocate an IP address based on input from the user. For this script, we will be using a bunch of Python modules to accomplish this. First we make a check to see that the user puts in enough arguments, and if not, they 'usage'...

Python Property

Python-Property-Tech-Justice
Python has a great concept called property, which makes the life of an object oriented programmer much simpler. Before defining and going into details of what a property in Python is, let us first build an intuition on why it would be needed in...

Search Twitter’s Tweeted Tweet By Python

Search Twitter's Tweeted Tweet - tech justice
Overview Twitter's API is REST-based and will return results as either XML or JSON, as well as both RSS and ATOM feed formats. Public timelines can be accessed by any client, but all other Twitter methods require authentication. About this script The program is well documented and...