[youtube id=”FxkTDeL386Y” width=”600″ height=”350″ autoplay=”no” api_params=”” class=””]
What are Strings in Python Programming?
Python is great at working with numbers, but what about when we want to communicate with people? To write programs that people can use, we need another variable type known as STRINGS.
Strings are what we call TEXT, or keyboard characters, in a programming language; they are groups (or ‘strings’) of letters, numbers, and symbols.
Your name is a string, as is your favourite colour.
A common way to use strings is in printing.
Let’s create a program that asks the user for their name, store their name in a variable called name, and then print their name on the screen 100 times!
There’s something new in the print() statement in the program’s last line: it contains a [popover title=”What is a Keyword?” title_bg_color=”” content=”A keyword is a special, reserved word that means something in a particular programming language. ” content_bg_color=”” bordercolor=”” textcolor=”” trigger=”hover” placement=”top” class=”” id=””]keyword[/popover] argument. The keyword here is the ‘end’, and it tells the program to END each print() statement with a space (there’s a space between our quotes: “ “) instead of the regular end-of-line character.
With this end keyword argument we are telling Python we don’t want every printout of our name to be on a new line.
Related Article: Girls Who Code