Missing module docstring (missing-module-docstring) - python-3.x

I am running below the addition of two numbers in jupyter
'''
This program `summationoftwonumbers` and displays their results
'''
A = 1
B = 5
print('Sum of Numbers:',A+B)
It is running fine giving an output as "Sum of Numbers: 6"
But when running a file by using PyLint, summationoftwonumber.ipynb gives the below errors.
summationoftwonumbers.ipynb:1:0: C0114: Missing module docstring (missing-module-docstring)
summationoftwonumbers.ipynb:1:0: W0104: Statement seems to have no effect (pointless-statement)
I do not understand why this is happening.

It's that you used quotes to write a comment, which in some cases creates a docstring. Python is warning you that the statement has no effect in your program. To get rid of the warning you could rewrite the line:
''' This program summationoftwonumbers and displays their results '''
as a normal comment:
# This program summationoftwonumbers and displays their results

Related

Selenium unusual output in python

I am getting comments from website I tried it already and it worked well but now it gives me unusual output.
Part of my code:
comments = driver.find_elements_by_class_name("comment-text")
time.sleep(1)
print(comments[1])
The output:
<selenium.webdriver.remote.webelement.WebElement (session="bb6ae0409dd8ec8c191f9bd84f79bea7", element="5f5d4a2f-7a93-41fe-9ca5-aa4e7c525792")>
You want
print(comments[1].text)
You were printing the element itself which is just some GUID (I think). I'm assuming you want the text contained in the element which means you need .text.

simple function statement is not giving any output

Tried to write a simple function in python version 3.7 system is neither giving any error nor it is giving any output.
def say_hello():
print('Hello user')
say_hello()
Python uses indentation for a code block (body of a function, loop etc.) i.e it starts with indentation and ends with the first unindented line.
So your method invocation was inside the method definition because of that it didn't even printed any output below code will fix your problem.
def say_hello():
print('Hello User')
say_hello()

How to fix this syntax error and Eof? [duplicate]

I have the following python code:
print 'This is a simple game.'
input('Press enter to continue . . .')
print 'Choose an option:'
...
But when I press Enter button, I get the following error:
Traceback (most recent call last):
File "E:/4.Python/temp.py", line 2, in <module>
input('Press enter to continue . . .')
File "<string>", line 0
^
SyntaxError: unexpected EOF while parsing
P.S. I am using python IDLE version 2.6 on Windows 7.
Related problem in IPython: Why does the IPython REPL tell me "SyntaxError: unexpected EOF while parsing" as I input the code?
For Python 2, you want raw_input, not input. The former will read a line. The latter will read a line and try to execute it, not advisable if you don't want your code being corrupted by the person entering data.
For example, they could do something like call arbitrary functions, as per the following example:
def sety99():
global y
y = 99
y = 0
input ("Enter something: ")
print y
If you run that code under Python 2 and enter sety99(), the output will 99, despite the fact that at no point does your code (in its normal execution flow) purposefully set y to anything other than zero (it does in the function but that function is never explicitly called by your code). The reason for this is that the input(prompt) call is equivalent to eval(raw_input(prompt)).
See here for the gory details.
Keep in mind that Python 3 fixes this. The input function there behaves as you would expect.
In Python 2, input() strings are evaluated, and if they are empty, an exception is raised. You probably want raw_input() (or move on to Python 3).
In Python 2.x, input() is equivalent to eval(raw_input()). And eval gives a syntax error when you pass it an empty string.
You want to use raw_input() instead.
If you use input on Python 2.x, it is interpreted as a Python expression, which is not what you want. And since in your case, the string is empty, an error is raised.
What you need is raw_input. Use that and it will return a string.

Name error when calling defined function in Jupyter

I am following a tutorial over at https://blog.patricktriest.com/analyzing-cryptocurrencies-python/ and I've got a bit stuck. I am tyring to define, then immediately call, a function.
My code is as follows:
def merge_dfs_on_column(dataframes, labels, col):
'''merge a single column of each dataframe on to a new combined dataframe'''
series_dict={}
for index in range(len(dataframes)):
series_dict[labels[index]]=dataframes[index][col]
return pd.DataFrame(series_dict)
# Merge the BTC price dataseries into a single dataframe
btc_usd_datasets= merge_dfs_on_column(list(exchange_data.values()),list(exchange_data.keys()),'Weighted Price')
I can clearly see that I have defined the merge_dfs_on_column fucntion and I think the syntax is correct, however, when I call the function on the last line, I get the following error:
NameError Traceback (most recent call last)
<ipython-input-22-a113142205e3> in <module>()
1 # Merge the BTC price dataseries into a single dataframe
----> 2 btc_usd_datasets= merge_dfs_on_column(list(exchange_data.values()),list(exchange_data.keys()),'Weighted Price')
NameError: name 'merge_dfs_on_column' is not defined
I have Googled for answers and carefully checked the syntax, but I can't see why that function isn't recognised when called.
Your function definition isn't getting executed by the Python interpreter before you call the function.
Double check what is getting executed and when. In Jupyter it's possible to run code out of input-order, which seems to be what you are accidentally doing. (perhaps try 'Run All')
Well, if you're defining yourself,
Then you probably have copy and pasted it directly from somewhere on the web and it might have characters that you are probably not able to see.
Just define that function by typing it and use pass and comment out other code and see if it is working or not.
"run all" does not work.
Shutting down the kernel and restarting does not help either.
If I write:
def whatever(a):
return a*2
whatever("hallo")
in the next cell, this works.
I have also experienced this kind of problem frequently in jupyter notebook
But after replacing %% with %%time the error resolved. I didn't know why?
So,after some browsing i get that this is not jupyter notenook issue,it is ipython issueand here is the issue and also this problem is answered in this stackoverflow question

While loop inside PyQt form not working

I'm using Python 3.4 and PyQt 5. I have written a while look Inside PyQt form. If the loop contains a single statement, it's working. But if the loop contains multiple statements, it's throwing an indentation error.
Below is working:
while count > 0: print("count value",count)
Below is throwing an indentation error:
while count>0:
print("count value", count)
count = count -1
Please help me to solve the problem. The same code is working if I run it outside PyQt form code.

Resources