Roshan Book

My Tech Notebook

Python Tutorial 1 Strings


Programming is just writing in a language which computer understands and through that giving computer instructions to perform certain tasks

escape operator to escape a quote. E.g. “don”t” will escape double quote before t.

n are used to print text in multiple lines

t for tab

“”” is used to write multiple lines of text

Concatenation – “jhon”+”rambo”  or “jhon” “rambo”

format specifier “John %s%s” % (“Every” , “man”)

John everyman

>  >  >  “%s %s %10s” % (“John” , “Every”, “Man”)
‘John Every          Man’
>  >  >  “%-5s %s %10s” % (“John” , “Every”, “Man”)
John     Every          Man
How It Works
In the first line of code, the word  Man  appears far away from the other words; this is because in your
last format specifier, you added a 10, so it is expecting a string with ten characters. When it does not
find ten (it only finds three . . .   M – a – n) it pads space in between with seven spaces.
In the second line of code you entered, you will notice that the word  Every  is spaced differently. This
occurs for the same reason as before — only this time, it occurred to the left, instead of the right.
Whenever you right a negative ( – ) in your format specifier, the format occurs to the left of the word. If
there is just a number with no negative, it occurs to the right.

Advertisements

6 responses to “Python Tutorial 1 Strings

  1. Cheap Replica Handbags December 5, 2011 at 6:58 am

    Another quality post. I posted a link for this blog at my web site. So, I am sure several persons forget the points you are discussing.

  2. louis vuitton replica handbags December 5, 2011 at 1:11 pm

    What i come across tough would be to locate a weblog that may seize me for a minute but your blog is diverse.

  3. louis vuitton wallets replica December 5, 2011 at 4:09 pm

    Your article seems interesting, i’ve noted it my digg and stumble account.The point you are making is easy to recognize and effective.

  4. Louis Vuitton Knockoffs December 5, 2011 at 8:30 pm

    Greetings from New York! Just visited your posts. Actually took in your write-up, I’ll pass it along! Have a fantastic day!

  5. Gucci Sale December 6, 2011 at 7:28 am

    Fantastic write-up, I am typical visitor of one’s internet web page, preserve up the exceptional operate, and It’s going to be a regular visitor for a long time

  6. cheap canada goose|c December 10, 2011 at 5:44 pm

    Thank you for each and every wonderful article. I??ve a presentation subsequent week, and I??m on the seek for such information.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: