Posts

counter

class justcount:     __secretcount=0     def count(self):         self.__secretcount+=1         print self.__secretcount counter = justcount() counter.count() counter.count() print counter.__secretCount

function with argument

def hello(person):     print("happy birthday")     print("happy birthday!!!")     print("happy birthday "+person+"\n")     print("may god bless u") hello('sourabh')

addition with function

def func(a,b):     sum = a+b     print sum a=int(raw_input ("Enter value of a")) b=int(raw_input ("Enter value of b")) func(a,b)

addition program in python

a=int(raw_input("Enter value a \n")) b=int(raw_input("Enter value b \n")) c=a+b print  c d=a-b print d e=a*b print e f=a/b print f print 'thankks'

LOOP

Image
In general, statements are executed sequentially: The first statement in a function is executed first, followed by the second, and so on. There may be a situation when you need to execute a block of code several number of times. Programming languages provide various control structures that allow for more complicated execution paths. A loop statement allows us to execute a statement or group of statements multiple times. The following diagram illustrates a loop statement − Python programming language provides following types of loops to handle looping requirements. Loop Type Description while loop Repeats a statement or group of statements while a given condition is TRUE. It tests the condition before executing the loop body. for loop Executes a sequence of statements multiple times and abbreviates the code that manages the loop variable. nested loops You can use one or more loop inside any another while, for or do..while loop. Loop Control Statements Loop con

Decision statement

Image
Decision making is anticipation of conditions occurring while execution of the program and specifying actions taken according to the conditions. Decision structures evaluate multiple expressions which produce TRUE or FALSE as outcome. You need to determine which action to take and which statements to execute if outcome is TRUE or FALSE otherwise. Following is the general form of a typical decision making structure found in most of the programming languages − Python programming language assumes any non-zero and non-null values as TRUE, and if it is either zero or null , then it is assumed as FALSE value. Python programming language provides following types of decision making statements. Click the following links to check their detail. Statement Description if statements An if statement consists of a boolean expression followed by one or more statements. if...else statements An if statement can be followed by an optional else statement , which executes when the

Installation of python

Python is available on a wide variety of platforms including Linux and Mac OS X. Let's understand how to set up our Python environment. Local Environment Setup Open a terminal window and type "python" to find out if it is already installed and which version is installed. Unix (Solaris, Linux, FreeBSD, AIX, HP/UX, SunOS, IRIX, etc.) Win 9x/NT/2000 Macintosh (Intel, PPC, 68K) OS/2 DOS (multiple versions) PalmOS Nokia mobile phones Windows CE Acorn/RISC OS BeOS Amiga VMS/OpenVMS QNX VxWorks Psion Python has also been ported to the Java and .NET virtual machines Getting Python The most up-to-date and current source code, binaries, documentation, news, etc., is available on the official website of Python https://www.python.org/ You can download Python documentation from https://www.python.org/doc/ . The documentation is available in HTML, PDF, and PostScript formats. Installing Python Python distribution is available for a wide variety of platforms