Python Programming in Hindi

You can use python -m pip install selenium in Python36 folder(or whatever version you are using at the time) and then try in PyCharm by selecting the corresponding interpreter in settings or else use PyCharm to do the installation by itself.

You need to define the class before you use it.Here is how :
Class animal:
def out():
print(“Here is an animal”)
s = animal()
s.out()

Python does not support increment operators such as ++ or --.But here is a shorter way to achieve this.

For increamen use : x +=1

How to install Matplotlib?

To install the Matplotlib library, you need to open the Anaconda prompt.
Use the command : conda install matplotlib
Or if you want to install Matplotlib in the Anaconda environment then use this command
pip install matplotlib
Then import the package import matplotlib.pyplot as plt

the website you provide is not installing the anaconda now how can we download it

Hello Learner,
Thank you for reaching out to us.Please write to us at academy@greatlearning.in. We will look into this matter for you and will get back to you as soon as possible.

I am facing this issue ,Can someone help me with this ? Python error: string index out of range python

What does %s mean in Python? And what does the following bit of code do?
%s is used to format the string syntax and it was taken from C.

how to convert a pandas dataframe into a NumPy array.

I am getting an error when importing pytorch.I have already installed pytorch using anaconda.Here is the error:modulenotfounderror: no module named ‘torch’

import torch

ModuleNotFoundError: No module named ‘torch’

I am getting an error after all the elements are printed when i run my python script:”list index out of range in python”:here is the code

list1 = [‘Apple’, ‘Banana’, ‘Orange’]
i=0
while i <= len(list1):
print(list_fruits[i])
i += 1

IndentationError: expected an indented block is what the console returns when my code is exactly what is on a video lesson

name = input("What’s your name? ")

if name == “Kris”:

print(name + " is a lumberjack and he is ok!")

else:

print(name + " sleeps all night and " + name + “works all day!”)

The string index out of range comes when the index you are trying to access does not exist.

The value of i which you are using to access the list is going beyond the number of elements in the list which is causing the list index out of range error.You can correct the code by changing the condition of while loop like this:

list1 = [‘Apple’, ‘Banana’, ‘Orange’]
i=0
while i < len(list1):
print(list_fruits[i])
i += 1

You should properly install pytorch using anaconda.The proper way to install pytorch to anaconda is following

conda install -c pytorch pytorch

First activate your conda profile with “source activate {your_profile}” if not already done and then use the above command.

Python requires formatting of blocks with indentation which basically means that you have to leave spaces before writing a line of code.The code lines belonging to same block must have same exact indentation which means the there must be equal number of spaces before each line of a block.So for you code,the correct formatting is like this:

if name == “Kris”:

print(name + " is a lumberjack and he is ok!")

else:

print(name + " sleeps all night and " + name + “works all day!”)

Putting in an extra space or leaving one out where it is needed will surely generate an error message

The error message IndentationError: expected an indented block would seem to indicate that you have an indentation error which is also sometimes caused by a mix of tabs and spaces. The indentation can be any consistent white space . It is recommended to use 4 spaces for indentation in Python, tabulation or a different number of spaces may work, but it is also known to cause trouble at times. Tabs are a bad idea because they may create different amount if spacing in different editors .

%s is used to format the string syntax and it was taken from C.

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?