πŸ“š

All Subjects

Β >Β 

⌨️ 

AP Comp Sci P

Β >Β 

πŸ“±

Big Idea 3: Algorithms and Programming

Strings

1 min readβ€’november 16, 2020

minnachow

Minna Chow


AP Computer Science Principles ⌨️

BookmarkedΒ 2.9kΒ β€’Β 79Β resources
See Units

What are Strings?

Strings, as mentioned earlier, are an ordered list of characters. You can navigate through them using index values, just like how you can navigate through a list using index values.
Although you can't perform mathematical operations with strings, you can still manipulate them.
A substring is a part of an existing string. For example, "APcomputer" would be a substring of the string "APcomputerscienceprinciples." The process of creating a substring is known as slicing.
There are many different ways to slice a string: here's a basic example.
string_example = "APcomputerscienceprinciples" print (string_example[0:10])
This code returns the substring "APcomputer." In Python, index values begin at 0, and the character at the end index number (10) is not included.
You can also concatenate strings. String concatenation occurs when two or more strings are joined end to end to make a new string. This is usually represented by the + symbol.

Concatenation Example

part_one = "Hello" part_two = "_World!" print (part_one + part_two)
The code returns:
Hello_World!

Was this guide helpful?

Fiveable logo
Join Fiveable for free
Create a free account to bookmark content and compete in trivia
Hours Logo
Studying with Hours = the ultimate focus mode
Start a free study session
Browse Study Guides By Unit
πŸ•ΉBig Idea 1: Creative Development
βš™οΈBig Idea 2: Data
πŸ“±Big Idea 3: Algorithms and Programming
πŸ–₯Big Idea 4: Computer Systems and Networks
⌨️Big Idea 5: Impact of Computing
✏️Frequently Asked Questions
πŸ“Exam Prep
πŸ“± Stressed or struggling and need to talk to someone?
Talk to a trained counselor for free. It's 100% anonymous.
Text FIVEABLE to 741741 to get started.
Β© 2021 Fiveable, Inc.