-
Notifications
You must be signed in to change notification settings - Fork 11
added strings #25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
added strings #25
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -445,9 +445,43 @@ rover.__doc__ | |
| dir(rover) | ||
| # [__dir__, __doc__, ..., 'bark', 'barks', 'is_happy', 'name', 'owner', 'wagging'] | ||
| ``` | ||
| ``` | ||
| Python String | ||
| In Python, Strings are arrays of bytes representing Unicode characters. However, Python does not have a character data type, a single character is simply a string with a length of 1. Square brackets can be used to access elements of the string. | ||
|
|
||
| ``` | ||
| ``` | ||
| Creating a String | ||
| Strings in Python can be created using single quotes or double quotes or even triple quotes. | ||
| ``` | ||
| `` Python Program for Creation of String | ||
| Creating a String with single Quotes | ||
| `` | ||
| ```py | ||
| String1 = 'Welcome to the Geeks World' | ||
| print("String with the use of Single Quotes: ") | ||
| print(String1) | ||
| ``` | ||
| Creating a String with double Quotes | ||
| ``` | ||
| String1 = "I'm a Geek" | ||
| print("\nString with the use of Double Quotes: ") | ||
| print(String1) | ||
| ``` Creating a String with triple Quotes ``` | ||
| String1 = '''I'm a Geek and I live in a world of "Geeks"''' | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. maybe it's important to mention why you might use these different ways of writing strings, like to avoid escaping the other set of quotes like you've demonstrated here. |
||
| print("\nString with the use of Triple Quotes: ") | ||
| print(String1) | ||
|
|
||
| ``` Creating String with triple Quotes allows multiple lines``` | ||
| String1 = '''Geeks | ||
| For | ||
| Life''' | ||
|
Comment on lines
+476
to
+478
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. could you also mention that using three double quotes works as well? |
||
| print("\nCreating a multiline String: ") | ||
| print(String1) | ||
| ``` | ||
| ``` | ||
| [Go back](README.md) and learn about `async` and Red commands | ||
|
|
||
|
|
||
| ``` | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you provide an example of using square brackets to access elements of a string? Also, maybe change "elements" to something else, something that makes sense that the elements you're accessing are either single characters or substrings.. "P