Zend Anwar

Full stack web developer

Category: Python

Python

Method overloading example in python

class Localbus: def sayLocal(self, busName=None): if busName is not None: print(‘Hello ‘ + busName) else: print(‘Hello ‘) obj = Localbus() obj.sayLocal() obj.sayLocal(‘Alif’) Output ============= Hello Hello Alif class Human: def sayHello(self, name=None, age=None): if name is not None and age is None: print(‘Hello ‘ + name) elif age is not None and age is not […]

Read More

‘python’ is not recognized as an internal or external command

It’s very simple, just modify python install. just follow image.

Read More

Why Python for Data Analysis?

Python has become one of the most popular dynamic,programming languages, along with Perl, Ruby, and others. Python and Ruby havebecome especially popular in recent years for building websites using their numerous web frameworks, like Rails (Ruby) and Django (Python). Such languages are often called scripting languages as they can be used to write quick-and-dirty small programs,or scripts. […]

Read More

Python String Operations

Concatenation >>>’Zend’ + ‘Anwar’ Zendanwar >>>’Zend’ *3 ZendZendZend Iterating Through String >> count = 0 >>> for str in ‘Zend Anwar’: if(str == ‘n’): count += 1 >>> print(count, “String Found”) 2 String Found  

Read More

Syntax of Python Function

def functionname(parameters): “””docstring””” statement(s) return [expression] Example: #!/usr/bin/python # Function definition is here def ima( lovestr ): “This prints a passed string into this function” print lovestr return; # Now you can call ima function ima(“I’m fall in love!”)

Read More

Star triangle with python for loop

>>> star =  input(“Enter the star to draw: “) Enter the star to draw: * >>> limit = int(input(“Enter the limit: “)) Enter the limit: 10 >>> for i in range(1, limit+1): print (star*i) Output–    * ** *** **** ***** ****** ******* ******** ********* **********

Read More

Python continue

>>> for var in “zend-anwar”: if var == “-“: continue print (var) output– z e n d a n w a r

Read More

Python break

>>> for var in “zend-anwar”: if var == “-“: break print (var) output—    z e n d

Read More

How to show hostname & IP address with python programming

The Internet Protocol assigns a 4-byte address to every computer connected to the network. Such addresses are usually written as four decimal numbers, separated by periods, which each represent a single byte of the address. Each number can therefore range from 0 to 255. So an IP address looks like this: 202.168.3.180 Because purely numeric […]

Read More