Home » NO IDEA » String Part 1

String Part 1

Blog Stats

  • 15,880 hits
December 2012
M T W T F S S
« Sep   Jan »
 12
3456789
10111213141516
17181920212223
24252627282930
31  

We can play with string ,when i came to see about the string function in python some string function are really cool i want you to try out in your computer so that you can feel and enjoy .I suggest all to to print their name in computer because i basically love my name if it is printed in computer !!! 🙂

+ we can join two or more string in a code

* this is used to print the name no of time you want

len(“string”) we can find the string length if this function

raw_input() wait for the user to enter some string if you press enter it goes to next line

examples

>>> print ("Hello, " + "world!")
Hello, world!

>>> print ("bouncy, " * 10)
bouncy, bouncy, bouncy, bouncy, bouncy, bouncy, bouncy, bouncy, bouncy, bouncy,

>>> print (len("Hello, world!"))
13

question = "What did you have for lunch?"
print (question)
answer = raw_input()

The proper full code for the above topics discussed

#string operations
name="harinath ,";
friend1="anish ,";
friend2="yogavignesh ,";
friend3="daniel ,";
friend4="sharan and surya "

print “**group of friends**”,name+friend1+friend2+friend3+friend4
print (name*10);
print”Enter the group name”
group=raw_input();
print group;
print “The length of friend2”,len(friend2);

Advertisements

1 Comment

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: