Python Programming in Hindi

I am trying to execute following code :

Given a getStr() function, write the necessary sequence of operations to transform the string (containing three literals) in such a way that every literal is tripled? respectively.

def getstr(s) :
result = 0
for i in s :
result = result + int(s[i] * 3)
#strlen = len(s)
return result

print(getstr(“abc”))

And it gives me a following error

How to convert string to JSON using Python?

How to display column names of Pandas Dataframe?

What is inplace in python and how does it affect my data it?Here is my code where I am using it.

df.dropna( inplace=True)

I have been getting this error: Unexpected indent in python? I have used indentation but till I am getting this error.

How to change directory in python?

What is the difference between sort() and sorted() methods in python?

You can use os module to do so,here is an example to change directory to a certain path.

os.chdir(path)

The path should be passed as a string,more preferably a raw string.

When you set inplace as True,the data in your case df is changed, we can say that it permanently changed your dataframe df.
On the other hand when you use inplace=False,the change does not occur in the original data df.Instead it performs the operation and returns a copy of the object, so you’d use:

df1=df.dropna(inplace=False)

Now your original data is unchanged.Sometimes you want the copy of your original dataframe and it can be useful then.

Here is how we can convert string to JSON using Python

import json

s = ‘{“success”: “true”, “status”: 200, “message”: “Hello”}’

d = json.loads(s)

print (d[“success”], d[“status”])

For a dataframe df, the below code to display the column names:

print(df.columns)

The sort() method modifies the list it is called on whereas, sorted() method creates a new list containing a sorted version of the list it is given and will not modify the list passed as a parameter.
If you want to sort a list but still have the original unsorted version, then you would use the sorted() method. If maintaining the original order of the list is unimportant, then you can call the sort() method on the list.

Hello sir i am Saiff

sir my basics is very weak i have complete course

I am class 12th student, how this course can be beneficial for me and what things should i learn apart from Python (i have learned C++ btw)

Hi Learner,
Thank you for reaching out to us. We, at Great Learning Academy, have launched over 100+ free courses with certifications on our website.
You can browse through all our courses here: https://www.greatlearning.in/academy

sir how to solve this problem

1 Like

plz solve this problem sir

1 Like

Dear Learner,

Please drop a mail to academy@greatlearning.in mentioning the course name along with the screenshot.

Hello guys ,I was wondering how I can do sorting in python without sort function?