Learn Python Series (#2) - Handling Strings Part 1
What Will I Learn?
- You will learn about creating strings,
- about concatenating and repeating strings,
- about indexing and slicing sequence types, including strings,
- and about string formatting
Requirements
- A working modern computer running macOS, Windows or Ubuntu
- An installed Python 3(.6) distribution, such as (for example) the Anaconda Distribution
- The ambition to learn Python programming
Difficulty
Basic / Intermediate
Curriculum (of the Learn Python Series):
Learn Python Series (#2) - Handling Strings Part 1
Handling strings is an essential part of coding in Python, as is the case with most, if not all, programming languages. Python has a number of built-in methods to handle strings, to manipulate / change them into something else, and to print and/or return them for further processing.In this tutorial episode, we will cover creating strings, concatenating and repeating strings, the indexing and slicing of strings - which is by the way an essential ingredient to working with all sequence types -, string formatting, and in Handling Strings Part 2 I will cover a number of commonly used string functions. I hope you'll again find this Learn Python Series episode useful!
What are strings and how to create them?
Strings are a (text sequence) data type in Python, and a string consists of a number of characters which could be letters, but also numbers, spaces, punctuation such as commas and exclamation marks, or other characters. Strings are enclosed within single quotes ' or double quotes ", as long as the opening and closing quote are the same. To create a string, you just assign its value to a variable, like so:
str1 = 'I am a string enclosed in single quotes'
str2 = "And I'm a string as well"
Nota bene 1: please note how I'm in str2 contains a single quote which is part of the total string, and is not seen as the ending of the total string, because the opening quote and the closing quote are both double quotes and the quote in I'm is a single quote being a part of the total string itself. The take-away here is that quotes not only function as enclosing characters but can be a part of a string itself.Nota bene 2: please also note that in case you would like to use single quotes as enclosing characters for str2, that that's also possible by escaping the single quote I'm by putting the \ backslash character before the single quote you want to escape, like so:
str3 = 'And I\'m a string as well'
Escaping that single quote, in this case means "This single quote is not the end of the total string, please do not interpret this single quote as the end of the string but as a part of the string".
String concatenation
Using the + operator we can "glue together" multiple strings to form a larger string, which we can then print as one string. This works with concatenating string variables as well as with concatenating string values:
I'm doing panel discussions weekly now. This Saturday is Steem Visions. We've been gathering up some hugely popular and talented Steem Artists. We'll talk to them about their work, how they work, and what it's like being an artist on Steem.
Cohosts!
I count my blessings in the form of some amazingly talented cohosts!@mundar, the lady behind Slothicorn is going to be helping to bring these artists to life and ask them questions about their experience, process, vision, and message.I'm also joined by Minnow Support Project Sr. Moderator, JuJu Gum Conspiracy co-creator, and all around art talent @mundar!
Guests!
@elohprojects
@everlove
@yusaymon
@poeticsnake
@overkillcoin
@alexandravart
@denniskonstantin
@mrblinddraw
@paolobeneforti
@drawingly
@reinhard-schmid
Logistics
Show starts this Saturday, March 3rd at 11am EST (1600 UTC).
This is a highly visual experience and you're encourged to join the screen share and audio at https://mspwaves.com/listen.We'll be live chatting in the Peace, Abundance, and Liberty Discord Channel. We're just shy of 15,000 Steemians now in the server. You'll be in good company.If you're going to be on the show please get there early. I start DJing around 10:30am EST. That gives you time to audio check. You'll want a working mic, speakers, and have some work ready to display through links or files.
Other Saturday Events
March 10th with be Sounds of Steem with @mundar
March 17th is unknown at this time
March 24th is Meet your Moderator, a roundtable with MSP mods and witnesses cohosted with Mistress of Questions @mundar
March 31st is the end of month Witness Panel Discussion
Boston
I'm hosting another Steem meetup in Boston this weekend. Event starts at 2pm on Saturday. Everything is on Beacon st. in Brookline. Sushi and some board games. Should be a good time. @mundar.
If anyone is owning BCC coins, it might be a good idea to think assuming a lost as soon as possible.While the transfer of the coins is done on a decentralized blockchain, the whole value of their token depend on the good operation of their websites and ownership of their domain names which can be stopped and seized.