Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Summary

Summary "Achieving Unprecedented Results in..."

Rating
-
Sold
-
Pages
12
Uploaded on
09-08-2023
Written in
2023/2024

Python Programming Guide: A comprehensive guide to mastering Python programming. Advanced Python Techniques: Unlocking the power of Python with advanced coding methods. Python Best Practices: A thorough exploration of industry-proven techniques and coding standards in Python. Python for Data Analysis: Leveraging Python's capabilities for effective data analysis and manipulation. Python Web Development Handbook: A comprehensive resource for building robust web applications with Python.

Show more Read less
Institution
Course

Content preview

Strings in Python | Python Tutorial - Day
#11
CodeWithHarry

Learning about Strings
Welcome back to 100 Days of Code! Today, we will be diving
deeper into the topic of Strings. As we know, Strings are a
special Data Type which can be written by enclosing any text
in double quotes. In this blog post, we will explore other
methods of creating Strings.

Without wasting any time, let's move to the computer screen
and get started!

Opening Replit
Firstly, I will open my Repls by going to the "Zero to Hero"
Python course. But before that, I want to address something.
Many people have been mentioning me on Instagram in the
100 Days of Code challenge. I want to let you know that I will
re-mention all those who mention me in the challenge.

Understanding Strings in Python
If you want to join me on Instagram, feel free to follow me and
tag me in your stories with "Day #5 done!" or "Day #6 done!"
to boost my energy. Today, we're going to dive deep into the
topic of strings in Python.

As you may already know, a string is a data type in Python. To
create a string, all you have to do is enclose anything in
double-quotes (""). For example:

 name = "Harry"

 friend = "Rohan"

 anotherFriend = 'Lovish'

As you can see, you can also enclose a string in single-quotes
(''). Both double-quotes and single-quotes can be used to
create strings.

, Strings Slicing and Operations on Strings in
Python | Python Tutorial - Day #12
CodeWithHarry

How to Do String Slicing in Python
Today's topic is string slicing in Python. As we learned before,
strings are a useful data type in any project. Slicing a string
means getting a substring from the original string.

Example:
Let's say we have a string named "harry" composed of 5
characters: h, a, r, r, and y. If we only want to access "rry", we
can use string slicing.

Code:
name = "harry"sliced_name =
name[2:]print(sliced_name) # Output: "rry"
If that example wasn't helpful, let's say we have a string with
multiple names separated by commas.

Code:
names = "Harry, Shubh, John, Jane, Alex"sliced_names
= names.split(", ")print(sliced_names) # Output:
["Harry", "Shubh", "John", "Jane", "Alex"]
We used the split() method to separate the names and
create a list of strings.

Let's say we have a string called "names" that contains the
word "Harry". If we want to slice out just the word "Harry" from
the string, we can use the following code:

print(names[:5])
This will print out "Harry".

If we want to slice out just the characters starting at the 5th
index, we can use the following code:

print(names[5:])

Written for

Course

Document information

Uploaded on
August 9, 2023
Number of pages
12
Written in
2023/2024
Type
SUMMARY

Subjects

$8.49
Get access to the full document:

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Get to know the seller
Seller avatar
abdullahkhan7

Get to know the seller

Seller avatar
abdullahkhan7 SINHGAD ACADEMY OF ENGINEERING
Follow You need to be logged in order to follow users or courses
Sold
1
Member since
2 year
Number of followers
1
Documents
9
Last sold
2 year ago

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions