Category Archives: Python

Viruses – From Newbie to pro

NOTE: Using an online compiler is not going to work here. Please install Python 2.7x and cv2, argparse modules to actually try out this example. Heya friends! Welcome back! Before continuing on with Malicious Logic, I request you to have a look at this great and informative article Worms, Viruses and Beyond!! Now, this article… Read More »

A basic Python Programming Challenge

Heya guys! I am back with another article my previous article on secure coding. This time we are not going to go into any theoretical stuff. Some months ago, I wrote a program in Python for my students so that they can practice basic BODMAS questions. The purpose was that the program should generate random… Read More »

Secure coding – What is it all about?

  So you think you can code? Well that’s great to know… The world definitely needs more geeks and nerds like you and me… But, are your programs secure? This is what this whole article is all about. As a programmer, it is not only your job but also moral responsibility to ensure that your… Read More »

What is the maximum possible value of an integer in Python ?

Consider below Python program. Output : 10000000000000000000000000000000000000000001 In Python, value of an integer is not restricted by the number of bits and can expand to the limit of the available memory (Sources : this and this). Thus we never need any special arrangement for storing large numbers (Imagine doing above arithmetic in C/C++). As a… Read More »

Important differences between Python 2.x and Python 3.x with examples

Division operator print function Unicode xrange Error Handling _future_ module Division operator If we are porting our code or executing the python 3.x code in python 2.x, it can be dangerous if integer division changes go unnoticed (since it doesn’t raise any error). It is preferred to use the floating value (like 7.0/5 or 7/5.0)… Read More »

How to input multiple values from user in one line in Python?

For instance, in C we can do something like this: One solution is to use raw_input() two times. Another solution is to use split() Note that we don’t have to explicitly specify split(‘ ‘) because split() uses any whitespace characters as delimiter as default. One thing to note in above Python code is, both x… Read More »

str() vs repr() in Python

str() and repr() both are used to get a string representation of object. Example of str(): Output: Hello, Geeks. 0.181818181818 . Example of repr(): Output: ‘Hello, Geeks.’ 0.18181818181818182 From above output, we can see if we print string using repr() function then it prints with a pair of quotes and if we calculate a value… Read More »

String Template Class in Python

In String module, Template Class allows us to create simplified syntax for output specification. The format uses placeholder names formed by $ with valid Python identifiers (alphanumeric characters and underscores). Surrounding the placeholder with braces allows it to be followed by more alphanumeric letters with no intervening spaces. Writing $$ creates a single escaped $:… Read More »