Most voted questions in Python

+1 vote
1 answer

Python: Print variable and string in same line

For a better understanding you can refer ...READ MORE

Oct 30, 2018 in Python by Priyaj
• 58,090 points
1,235 views
+1 vote
1 answer

Implement Quicksort in Python

This will help you. def sort(array=[2,5,1,6,9,8,7,10,21,12]): ...READ MORE

Oct 30, 2018 in Python by Priyaj
• 58,090 points
809 views
+1 vote
1 answer

How is raw_input() and input() in python3.x?

raw_input() was renamed to input() so now input() returns the exact string ...READ MORE

Oct 30, 2018 in Python by Priyaj
• 58,090 points
684 views
+1 vote
2 answers

Difference: abstract class and interface in Python

If abstract class contains only abstract methods ...READ MORE

Jun 21, 2019 in Python by anonymous
7,261 views
+1 vote
3 answers

How can I use python to execute a curl command?

For sake of simplicity, maybe you should ...READ MORE

Oct 11, 2018 in Python by charlie_brown
• 7,720 points
93,207 views
+1 vote
1 answer

Index of predicted wrong data in Keras, how to find it?

Simply, use: model.predict() pred = model.predict(x_test) indices = [i for ...READ MORE

Sep 28, 2018 in Python by Priyaj
• 58,090 points
5,275 views
+1 vote
1 answer

Can installin pip for python install dependencies aswell?

As long as the dependency is listed ...READ MORE

Sep 26, 2018 in Python by Priyaj
• 58,090 points
554 views
+1 vote
1 answer

Run tally of events within a given period using datetime

If you have access to pandas, pd.Series.cumcount is one way. ...READ MORE

Sep 26, 2018 in Python by Priyaj
• 58,090 points
581 views
+1 vote
1 answer

How to handle Real-Time Matplotlib Plotting

To draw a continuous set of random ...READ MORE

Sep 26, 2018 in Python by Priyaj
• 58,090 points
15,717 views
+1 vote
1 answer

How to estimate number of clusters through EM in scikit-learn

For future reference, the fixed function looks ...READ MORE

Sep 26, 2018 in Python by Priyaj
• 58,090 points
962 views
+1 vote
1 answer

How to use GUI that comes with Python to test your code?

Hey @alex0809, When your testing a website ...READ MORE

Sep 24, 2018 in Python by Vardhan
• 13,190 points
675 views
+1 vote
1 answer

Quicksort in Python

The following code may solve your problem: def ...READ MORE

Sep 20, 2018 in Python by SDeb
• 13,300 points
517 views
+1 vote
2 answers

Does 'finally' always execute in Python?

The "finally" executes almost everytime. But there ...READ MORE

Aug 31, 2018 in Python by Omkar
• 69,210 points
5,399 views
+1 vote
1 answer

Understanding Python super() with __init__() methods

It's been noted that in Python 3.0+ ...READ MORE

Aug 28, 2018 in Python by Priyaj
• 58,090 points
3,845 views
+1 vote
2 answers

Remove all whitespace in a string in Python

You can also use regular expressions for ...READ MORE

Aug 31, 2018 in Python by Omkar
• 69,210 points
16,819 views
+1 vote
1 answer

What's the difference between eval, exec, and compile in Python?

exec is not an expression: a statement ...READ MORE

Aug 28, 2018 in Python by Priyaj
• 58,090 points
4,623 views
+1 vote
1 answer

Accessing the index in 'for' loops?

Using an additional state variable, such as ...READ MORE

Aug 28, 2018 in Python by Priyaj
• 58,090 points
369 views
+1 vote
1 answer

How do you express binary literals in Python?

Starting with Python 2.6 you can express ...READ MORE

Aug 28, 2018 in Python by Priyaj
• 58,090 points

edited Dec 21, 2023 by Khan Sarfaraz 3,731 views
+1 vote
3 answers

What are the ways of detecting outliners in Python

code from http://eurekastatistics.com/using-the-median-absolute-deviation-to-find-outliers  This uses the L1 distance ...READ MORE

Aug 24, 2018 in Python by eatcodesleeprepeat
• 4,710 points

reshown Aug 24, 2018 by Priyaj 964 views
+1 vote
1 answer

Why does x,y = zip(*zip(a,b)) work in Python?

I'm extremely new to Python so this ...READ MORE

Aug 23, 2018 in Python by Priyaj
• 58,090 points
1,345 views
+1 vote
2 answers

How to use the pass statement in Python

In Python programming, pass is a null statement. The ...READ MORE

Apr 5, 2019 in Python by anonymous
753 views
+1 vote
1 answer

How to print an error in Python?

For Python 2.6 and later and Python ...READ MORE

Aug 23, 2018 in Python by Priyaj
• 58,090 points
1,139 views
+1 vote
1 answer

Zip lists in Python

zip takes a bunch of lists likes a: ...READ MORE

Aug 22, 2018 in Python by Priyaj
• 58,090 points
518 views
+1 vote
1 answer

What is the difference between range and xrange functions in Python 2.X?

xrange only stores the range params and ...READ MORE

Aug 22, 2018 in Python by Priyaj
• 58,090 points
2,073 views
+1 vote
1 answer

Understanding Pickling in Python

While others have pointed to the Python ...READ MORE

Aug 22, 2018 in Python by Priyaj
• 58,090 points
597 views
+1 vote
1 answer

How to write the Fibonacci Sequence?

Efficient Pythonic generator of the Fibonacci sequence I ...READ MORE

Aug 21, 2018 in Python by Priyaj
• 58,090 points
1,002 views
+1 vote
1 answer

Reading a large file, line by line in Python

The correct, fully Pythonic way to read ...READ MORE

Aug 21, 2018 in Python by Priyaj
• 58,090 points
690 views
+1 vote
1 answer

What is the function for Factorial in Python

Easiest way: math.factorial(x) (available in 2.6 and ...READ MORE

Aug 21, 2018 in Python by Priyaj
• 58,090 points

edited Aug 21, 2018 by Omkar 1,109 views
+1 vote
2 answers

Python string formatting: % vs. .format

Using Python format() function is what the ...READ MORE

Apr 11, 2019 in Python by Dasa Ravi
976 views
+1 vote
1 answer

How do I trim whitespace?

Whitespace on both sides: s = " \t ...READ MORE

Aug 20, 2018 in Python by Priyaj
• 58,090 points
433 views
+1 vote
1 answer

How to check if a string is null in python

Try this: if cookie and not cookie.isspace(): # the ...READ MORE

Aug 20, 2018 in Python by Priyaj
• 58,090 points
22,652 views
+1 vote
1 answer

How to append an integer to a string?

You can not directly concatenate two different ...READ MORE

Aug 16, 2018 in Python by Omkar
• 69,210 points
1,229 views
+1 vote
2 answers

How to convert list to string

mylist = [1, 2, 3] ‘’.join(map(str, mylist)) ==> ...READ MORE

Aug 21, 2018 in Python by Omkar
• 69,210 points
672 views
+1 vote
2 answers

Static methods in Python?

Static methods are used when we need ...READ MORE

Aug 4, 2018 in Python by Ronaldobessmin
• 160 points

edited Aug 4, 2018 by Vardhan 703 views
+1 vote
2 answers

Multiple line comment in Python

Try this ''' This is a multiline comment. ...READ MORE

Jul 31, 2018 in Python by Priyaj
• 58,090 points
743 views
+1 vote
3 answers

How to run the Python program forever?

you can also do the old fashioned ...READ MORE

Jun 10, 2019 in Python by brianno
19,986 views
+1 vote
2 answers

What is the difference between classes and labels in machine learning?

Classes and Labels both are almost same things ...READ MORE

Apr 3, 2019 in Python by SA
• 1,090 points
6,960 views
+1 vote
1 answer

What is the correct order to learn concepts in Python for machine learning?

Machine Learning is a vast domain. It ...READ MORE

Jul 25, 2018 in Python by Abhi
• 3,720 points
782 views
+1 vote
1 answer

Appending data to a file [closed]

To append a file without overwriting, open ...READ MORE

Aug 7, 2018 in Python by Omkar
• 69,210 points

edited Aug 7, 2018 by Omkar 411 views
+1 vote
2 answers

Appending data to a file

First open the file that you want ...READ MORE

Jul 23, 2018 in Python by Omkar
• 69,210 points
688 views
+1 vote
1 answer

how to convert json to csv or to store in sql

You can convert JSON data to csv ...READ MORE

Jul 2, 2018 in Python by Nietzsche's daemon
• 4,260 points
1,935 views
+1 vote
3 answers

Difference between append vs. extend list methods in Python

Python append() method adds an element to ...READ MORE

Aug 21, 2019 in Python by germyrinn
• 240 points
95,658 views
+1 vote
2 answers

How to print first character of each word in upper case of a string in Python

class Solution:     def firstAlphabet(self, s):             self.s=s              k=''              k=k+s[0]              for i in range(len(s)):                     if ...READ MORE

Oct 28, 2020 in Python by Anurag
11,712 views
+1 vote
1 answer

How to replace id with attribute corresponding to id of another table?

Use the following query statement and let ...READ MORE

Aug 8, 2018 in Python by Priyaj
• 58,090 points
2,016 views
+1 vote
1 answer

How can I map input to output without using dynamic()

Here am talking about my example you ...READ MORE

Aug 8, 2018 in Python by Priyaj
• 58,090 points
770 views
+1 vote
1 answer

Why is openpyxl is required for loading excel format files?

Well, it sounds like openpyxl is not ...READ MORE

Aug 8, 2018 in Python by Priyaj
• 58,090 points
764 views
+1 vote
2 answers

Measuring the distance between pixels on OpenCv with Python

You can try this: Mat pts1(nPts, 1, CV_8UC2), ...READ MORE

Aug 24, 2018 in Python by Omkar
• 69,210 points
10,129 views
+1 vote
1 answer

How to create plots using python matplotlib in IPython notebook?

I think you should try: I used %matplotlib inline in ...READ MORE

Aug 8, 2018 in Python by Priyaj
• 58,090 points
1,189 views
+1 vote
12 answers

How to print array/ list without brackets in python?

print(*names, sep = ', ') This is what ...READ MORE

Dec 10, 2018 in Python by Sudo
142,247 views
+1 vote
7 answers

What do you mean by python scripting? What is a script and a module in python?

A module is a file containing a ...READ MORE

Jun 17, 2019 in Python by Zain Abbas
62,805 views