pub-3785248829033902 | Python: Strings #1 | - Big data with Python

| Python: Strings #1 |

Every time you put " (double-quotes) around a piece of text you have been making a string.

A string is how you make something that your program might give to a human. You print strings, save strings to files, send strings to web servers, and many other things. Strings are really handy, so in this exercise you will learn how to make strings that have variables embedded in them.

You embed variables inside a string by using specialized format sequences and then putting the variables at the end with a special syntax that tells Python, "Hey, this is a format string. Put these variables in there."


The best way to learn new things is to take a practical approach of the things you want to learn. Here is a fragment of code that demonstrates the use of the string statement in Python:

Æ’ python command

print('I want '+str(2) + ' tickets to Mars')

output

I want 2 tickets to Mars    



Previous
Next Post »