Strings Indexing, Slicing and Methods | Python Tutorial in Hindi 13

Strings Indexing, Slicing and Methods | Python Tutorial in Hindi 13

Rishabh Mishra

3 месяца назад

3,827 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

@NeerajKumar-zq8or
@NeerajKumar-zq8or - 29.10.2024 01:00

love all lectures

Ответить
@TinuBhai-vr3hh
@TinuBhai-vr3hh - 28.09.2024 15:22

Bro list tuple dict diff

Ответить
@Nehashukla-v3f
@Nehashukla-v3f - 24.09.2024 14:59

Congratulations 🎊 🎉 incoming Nike CEO

Ответить
@princetiwari8016
@princetiwari8016 - 23.09.2024 17:35

Very very thanks 🙏❤❤sir❤❤ for given continue lectures ❤❤

Ответить
@nveerajsunny6612
@nveerajsunny6612 - 23.09.2024 16:47

Rishab,
I would also like to inquire about the completion timeline for the Python tutorial playlist. Could you please provide an overview of the remaining topics that will be covered? This information would help me gauge the expected duration for completing the series. Thank you.

Ответить
@nveerajsunny6612
@nveerajsunny6612 - 23.09.2024 16:44

Hello Rishab😊😊😊,

I would like to express my gratitude for the excellent👌👌 Python tutorial videos you have created. I have been following your content closely, and I truly appreciate your teaching style, which is both engaging and approachable.

Below are my answers to the assignment you provided.

TOPIC - STRINGS IN PYTHON – BELOW ARE THE ANSWERS FOR THE QUESTIONS YOU ASKED US TO DO IT.

1. limit the decimal places to 2 digits using .format method and print the result, for the variable pi = 3.14159265359

pi = 3.14159265359
result = "{:.2f}".format(pi)
print(result)

2. extract the characters from 2 to 8 with a step of 2. given my string "Python Course", slice characters from index 2 to 8, skipping every other char

my_string = "Python Course"
result = my_string[2:8:2]
print(result)

3. slice to get only the middle character(s): For my_string ='Madhav', use slicing to extract the middle character(s)

my_string = 'Madhav'
length = len(my_string)

# For even length, slice two middle characters
if length % 2 == 0:
mid_left = length // 2 - 1
mid_right = length // 2 + 1
result = my_string[mid_left:mid_right]
else:
# For odd length, slice the single middle character
middle = length // 2
result = my_string[middle]

print(result)

4. remove the first 3 and last 3 characters: Given my_string = "Regression Analysis", remove the first 3 and last 3 characters.

my_string = "Regression Analysis"
result = my_string[3:-3]
print(result)

5. Get the substring that starts 4 characters from the end to the last character : for my_string ="Classification", slice the string starting from the 4th character from the end to the last character.

my_string = "Classification"
result = my_string[-4:]
print(result)

6. how to reverse a string using python string methods

my_string = "Hello, World!"
reversed_string = my_string[::-1]
print(reversed_string)

7. write a python function to check if a string is a palindrome using string methods?

def is_palindrome(my_string):
my_string = my_string.replace(" ", "").lower()
return my_string == my_string[::-1]
test_string = "A man a plan a canal Panama"
print(is_palindrome(test_string))

8. Difference between find() and index() in python ?

Return Value

find(substring):
Returns the lowest index of the substring if found.
Returns -1 if the substring is not found.

index(substring):
Returns the lowest index of the substring if found.
Raises a ValueError if the substring is not found.

Use find() if you prefer to check for a substring's presence without exceptions.
Use index() if you want to assert that the substring is present and handle errors explicitly.

Ответить
@bijanpattnaik5112
@bijanpattnaik5112 - 23.09.2024 16:30

Sir please loops kaa video bhi banaiye

Ответить
@shouryasharma6342
@shouryasharma6342 - 23.09.2024 04:31

Bhai tumse ek baat puchni h kya mere data analyst mein job lg skti hai b.a kia hu 4 year gap h

Ответить
@JustForYou023
@JustForYou023 - 22.09.2024 20:39

let's Go ... Daily Videoo coming
Now it feels like Maybe this series can be completed in next two weeks ...
Daily New Video Aana Chahie Bhaiya ...
By the Way .. I'm Following Series From Day 1 ...

Ответить
@chitranshchaturvedi2333
@chitranshchaturvedi2333 - 22.09.2024 19:00

Hello Rishabh bhaiya
Aap iss course mein Python ke basics ke baad Libraries bghera karwaoge for data analysis??
And kitne din lag jayenge lagbhag complete hone mein??

Ответить