29 October 2016

Python first program write quickly before you start learning more

First Python Program
# FirstPythonProgram:
The first Python program looks like the below. My first program: odbchelper.py


def buildConnectionString(params):
"""Build a connection string from a dictionary of parameters.
Returns string."""
"database":"master", \
return ";".join(["%s=%s" % (k, v) for k, v in params.items()])
if __name__ == "__main__":
myParams = {"server":"mpilgrim", \
"uid":"sa", \
"pwd":"secret" \
}
print buildConnectionString(myParams)

You can run a Python program from the command line: 

  • python odbchelper.py

The output of odbchelper.py will look like this:

server=mpilgrim;uid=sa;database=master;pwd=secret

Sample python program

if authorsFirstName == 'Irv':
    teachingPython = True
    print 'Pay attention to his wisdom'
    respectPoints = respectPoints + 10

The above if condition checks for first name. In python '==', means equal to. making true to teachingPython.

You can start your python program quickly. Really useful for learning and to use in projects.

No comments:

Post a Comment

Thanks for your message. We will get back you.

Featured post

10 top Blockchain real features useful to financial projects

Blockchain is basically a shared ledger and it has many special features. Why you need it. Business transactions take place every second...

Most Viewed