Skip to content

Commit 2eaab92

Browse files
committed
add new guest post by @kwhinnery
1 parent e9b7043 commit 2eaab92

File tree

6 files changed

+35
-22
lines changed

6 files changed

+35
-22
lines changed

content/posts/191018-python-basic-data-types-strings.markdown

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,20 @@
11
title: Basic Data Types in Python 3: Strings
22
slug: python-basic-data-types-strings
3-
meta: Learn to create and manipulate strings in this series of blog posts on basic data types in Python programming
3+
meta: Learn to create and manipulate strings in this series of blog posts on basic data types in Python programming.
44
category: post
55
date: 2019-10-18
66
modified: 2019-10-18
77
newsletter: False
8-
headerimage: /img/191018-python-basic-data-types-strings/header.jpeg
8+
headerimage: /img/191018-python-basic-data-types-strings/header.jpg
99
headeralt: Learn basic Python data types in TwilioQuest 3 - Strings
10+
author: Kevin Whinnery
11+
authorlink: https://www.twilio.com/quest
1012

11-
If you're [new to the language](https://wiki.python.org/moin/BeginnersGuide/Overview),
12-
there's a lot to learn on your Python journey. Once you're comfortable writing
13-
and executing code, your first stop becomes learning how to represent data in
13+
14+
There is a lot to learn on your Python journey when you are
15+
[new to the programming language](/learning-programming.html). Once you are
16+
comfortable writing and executing code, your first stop becomes understanding
17+
how to represent data in
1418
your code. No matter the language, there are a few basic data types you'll use
1519
all the time - strings, numbers, booleans, lists, and dictionaries.
1620

@@ -23,8 +27,8 @@ You'll learn about basic data types and much more about Python programming.
2327

2428
Ready to learn how to use strings in Python 3? Let's get started!
2529

26-
## Strings in Python 3
2730

31+
## Strings in Python 3
2832
One of the most common data types in any programming language is a `string`. A
2933
__string__ represents a series of characters, which you would use to represent
3034
usernames, blog posts, tweets, or any text content in your code. You can create
@@ -34,8 +38,8 @@ a string and assign it to a variable like this.
3438
my_name = "Jonathan Joestar"
3539
```
3640

37-
### Strings are "immutable"
3841

42+
### Strings are "immutable"
3943
In Python, strings are considered [immutable](https://www.merriam-webster.com/dictionary/immutable) -
4044
once you create them, they can't be changed. You can, however, use a variety of
4145
methods to create new strings from existing strings. This type of work in
@@ -45,8 +49,8 @@ far from the truth!
4549

4650
Here are some common tasks you might undertake when using strings in your code.
4751

48-
### Common task - combining strings together
4952

53+
### Common task - combining strings together
5054
Combining strings together - __concatenating__ them - is a very common task. In
5155
Python 3, you can use the `+` operator for this purpose. You can use the `+`
5256
operator multiple times to concatenate multiple strings.
@@ -58,8 +62,8 @@ last_name = "Joestar"
5862
full_name = first_name + " " + last_name
5963
```
6064

61-
### Common task - inserting data into strings
6265

66+
### Common task - inserting data into strings
6367
Another common task with strings is inserting data into a specific place
6468
within a string. In programming, we call this __string interpolation__. Python 3
6569
provides a handy tool for doing this called ["f" strings](https://www.python.org/dev/peps/pep-0498/).
@@ -81,8 +85,8 @@ message = f"My name is {first_name} {last_name}, and I am {age} years old."
8185
print(message)
8286
```
8387

84-
### Common task - using built-in string methods to manipulate strings
8588

89+
### Common task - using built-in string methods to manipulate strings
8690
String objects have a number of [methods](https://docs.python.org/3/library/stdtypes.html#string-methods)
8791
to perform common tasks, like changing the case of strings or trimming their
8892
content. Below, you'll find a few examples. In two of these examples, we are
@@ -122,8 +126,8 @@ for item in groceries:
122126
[Check our more strings can do](https://docs.python.org/3/library/stdtypes.html#string-methods)
123127
in the Python 3 docs!
124128

125-
## Type casting
126129

130+
## Type casting
127131
Frequently, you will want to convert data from one type into another. In
128132
programming, we call this process __type casting__. There are a number of
129133
__functions__ built in to Python which allow us to do these type conversions
@@ -145,12 +149,14 @@ converted = int(example_string)
145149
message = f"Two plus two equals { converted + 2 }"
146150
```
147151

148-
## Wrapping up
149152

153+
## Wrapping up
150154
Strings of text are one of the most common pieces of data you will work with
151155
in programming. Hopefully, you've learned a bit about how to work with strings
152156
in Python 3! Stay tuned for more blog posts in this series to learn more about
153157
basic data types like strings, numbers, booleans, lists, and dictionaries.
154158

155-
Also, be sure to [download and play TwilioQuest 3](https://www.twilio.com/quest/download)
156-
to learn even more about the Python programming language!
159+
Also, be sure to
160+
[download and play TwilioQuest 3](https://www.twilio.com/quest/download)
161+
to learn even more about Python!
162+
-150 KB
Binary file not shown.
97.2 KB
Loading

theme/templates/article.html

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,14 @@
2828
<h1 style="font-size: 36px;">{{ article.title }}</h1>
2929
<div style="font-size:12px;color:#666;margin:0 0 10px">
3030
{% if article.modified != article.date %}
31-
Post updated by <a href="/about-author.html">Matt Makai</a> on
32-
{{ article.modified.strftime('%B %d, %Y') }}. Originally posted
31+
Post updated by
32+
{% if article.author %}<a href="{{ article.authorlink }}">{{ article.author }}</a>{% else %}<a href="/about-author.html">Matt Makai</a>{% endif %}
33+
on {{ article.modified.strftime('%B %d, %Y') }}. Originally posted
3334
on {{ article.date.strftime('%B %d, %Y') }}.
3435
{% else %}
35-
Posted by <a href="/about-author.html">Matt Makai</a> on
36-
{{ article.date.strftime('%B %d, %Y') }}.
36+
Posted by
37+
{% if article.author %}<a href="{{ article.authorlink }}">{{ article.author }}</a>{% else %}<a href="/about-author.html">Matt Makai</a>{% endif %}
38+
on {{ article.date.strftime('%B %d, %Y') }}.
3739
{% endif %}
3840
</div>
3941
</div>

theme/templates/blog.html

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,14 @@ <h1 style="display:none">Blog Tutorials</h1>
2424
<h2 style="padding-top:0;margin-top:0"><a href="/blog/{{ a.slug }}.html">{{ a.title }}</a></h2>
2525
<div style="font-size:12px;color:#666;margin:0 0 10px">
2626
{% if a.modified != a.date %}
27-
Post updated by <a href="/about-author.html">Matt Makai</a> on
28-
{{ a.modified.strftime('%B %d, %Y') }}. Originally posted
27+
Post updated by
28+
{% if a.author %}<a href="{{ a.authorlink }}">{{ a.author }}</a>{% else %}<a href="/about-author.html">Matt Makai</a>{% endif %}
29+
on {{ a.modified.strftime('%B %d, %Y') }}. Originally posted
2930
on {{ a.date.strftime('%B %d, %Y') }}.
3031
{% else %}
31-
Posted by <a href="/about-author.html">Matt Makai</a> on
32-
{{ a.date.strftime('%B %d, %Y') }}.
32+
Posted by
33+
{% if a.author %}<a href="{{ a.authorlink }}">{{ a.author }}</a>{% else %}<a href="/about-author.html">Matt Makai</a>{% endif %}
34+
on {{ a.date.strftime('%B %d, %Y') }}.
3335
{% endif %}
3436
</div>
3537
{{ a.content|truncate(350) }} (<a href="/blog/{{ a.slug }}.html">read more</a>)
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<a href="/introduction.html" class="lgi">Introduction</a>
2+
<a href="/learning-programming.html" class="lgi">Learning Programming</a>
3+
<a href="/source-control.html" class="lgi">Source control</a>

0 commit comments

Comments
 (0)