Most viewed questions in Python

0 votes
1 answer

Power Math in Python

When you use "^" operator, it is ...READ MORE

Nov 12, 2018 in Python by ana1504.k
• 7,910 points
528 views
0 votes
1 answer

Re-assigning a name to itself

This code occurs in multiprocessing.dummy, a "fake" ...READ MORE

Oct 17, 2018 in Python by ana1504.k
• 7,910 points
528 views
0 votes
1 answer

How does insertion work in Python?

Or, this one: def ins_sort(k): ...READ MORE

Oct 8, 2018 in Python by charlie_brown
• 7,720 points
528 views
0 votes
0 answers

Python | Combine two bots into one

Hi everyone, Basically i made a bot in ...READ MORE

Jun 30, 2020 in Python by PrKit
• 120 points
527 views
0 votes
1 answer

Replacements for switch statement in Python?

You could use a dictionary: def f(x): ...READ MORE

May 29, 2018 in Python by aryya
• 7,450 points
527 views
0 votes
1 answer

Why is it string.join(list) instead of list.join(string)?

It's because any iterable can be joined ...READ MORE

Dec 2, 2020 in Python by Gitika
• 65,910 points
524 views
0 votes
0 answers

What does a ternary conditional operator do in python?

Can you give an example using a ...READ MORE

Jun 17, 2019 in Python by Waseem
• 4,540 points
524 views
0 votes
1 answer

Is there a string 'contains' in python?

In this case, you can use the ...READ MORE

Sep 25, 2018 in Python by SDeb
• 13,300 points
524 views
0 votes
1 answer

Comparing two files contents in python

Considering your file "Unique.txt" does just containt the IP ...READ MORE

Sep 11, 2018 in Python by Priyaj
• 58,090 points
523 views
0 votes
1 answer

Where can I get the list of Python keywords?

Just import a module “keyword”. Here you ...READ MORE

Apr 20, 2018 in Python by aayushi
• 750 points
523 views
0 votes
0 answers

How i can open a storage based pdf file in chrome full screen mood using python?

i have a pdf file stored in ...READ MORE

Mar 12, 2020 in Python by junaid
• 120 points

retagged Mar 12, 2020 by junaid 522 views
0 votes
1 answer

numpy all differing from builtin all

Numpy.all does not understands generator expressions. From the ...READ MORE

Jun 13, 2019 in Python by SDeb
• 13,300 points
521 views
0 votes
0 answers

How do you implement insertion sort in python?

Can you give the sample code as ...READ MORE

Jun 19, 2019 in Python by Waseem
• 4,540 points
520 views
0 votes
1 answer

How to access list in Python?

A list is created by adding comma ...READ MORE

Mar 4, 2019 in Python by Priyaj
• 58,090 points
520 views
0 votes
1 answer

NumPy Array Indexing

If you want to create a subarray ...READ MORE

Jul 26, 2019 in Python by SDeb
• 13,300 points
519 views
0 votes
1 answer

Best way to open a socket in Python

Opening sockets in python is pretty simple. ...READ MORE

Feb 21, 2019 in Python by SDeb
• 13,300 points
519 views
0 votes
1 answer

How can I print Lists in python

print is a function in Python 3.x, so ...READ MORE

Oct 24, 2018 in Python by Priyaj
• 58,090 points
519 views
0 votes
1 answer

Callable objects approach vs nested scope approach to create higher order functions - python

Using callable objects has a disadvantage over ...READ MORE

Jul 25, 2019 in Python by Vivan
518 views
0 votes
1 answer

How to add elements to a list in Python?

To initialize an empty list do this: new_list ...READ MORE

Jul 23, 2019 in Python by Neel
• 3,020 points
518 views
0 votes
1 answer

Change log-level via mocking

A way to do this without mocking ...READ MORE

Jun 4, 2019 in Python by SDeb
• 13,300 points
518 views
0 votes
1 answer

Print Delimited list

You can try the following and see ...READ MORE

Feb 28, 2019 in Python by SDeb
• 13,300 points
518 views
0 votes
1 answer

Python - abs vs fabs

math.fabs() converts its argument to float if it ...READ MORE

Sep 19, 2018 in Python by Priyaj
• 58,090 points
518 views
0 votes
1 answer

How can I do not equal in Django queryset filtering?

Hello @kartik, You can use Q objects for this. They ...READ MORE

Nov 17, 2020 in Python by Niroj
• 82,880 points
517 views
0 votes
1 answer

How can I set Django Cookies?

Hello @kartik, This is a helper to set ...READ MORE

Aug 12, 2020 in Python by Niroj
• 82,880 points
517 views
0 votes
1 answer

How to solve indentation in the below code?

Python does not use brackets, it uses ...READ MORE

Feb 9, 2019 in Python by Omkar
• 69,210 points
516 views
0 votes
1 answer

How do I append one string to another in Python?

If you only have one reference to ...READ MORE

Oct 22, 2018 in Python by SDeb
• 13,300 points
516 views
0 votes
3 answers

Is there a simple way to delete a list element by value?

There are three ways in which you ...READ MORE

Dec 28, 2020 in Python by Thomas Walenta
515 views
0 votes
1 answer

What is the basic difference between T-Test, Z-Test, Chi-Square and Annova test?

If we are using one numerical variable ...READ MORE

Oct 29, 2020 in Python by Gitika
• 65,910 points
515 views
0 votes
1 answer

I have a dictonary in python how to access the value field?

dic={"car":["limo","sedan"]} print (dic.keys())    <-----------------------Fetch the key "car" print (dic['car'][0])   <------------------------Fetch ...READ MORE

Dec 20, 2018 in Python by Shuvodip
515 views
0 votes
0 answers

Why do i get this error in tkinter - Python?

This is my code: from tkinter import * root ...READ MORE

Oct 10, 2021 in Python by LogizTV
• 120 points
514 views
+1 vote
1 answer

I wanted to change the entire row where index is 9 how can i do that

Import the file as a pandas dataframe ...READ MORE

Sep 16, 2019 in Python by Rishi
514 views
0 votes
0 answers

for label, value in s.iteritems(): s.set_value(label, value+2) s.head()

READ MORE

Jun 6, 2020 in Python by WELL
• 140 points

recategorized Jun 8, 2020 by Gitika 513 views
0 votes
1 answer

How to eliminate out outliers in a dataframe?

There are various ways we can replace ...READ MORE

Jul 24, 2019 in Python by Shri
513 views
0 votes
1 answer

How to get size of a list?

Hi, You can use built-in function "len" to ...READ MORE

Jun 21, 2019 in Python by Shabnam
• 930 points
513 views
0 votes
1 answer

Representing infinity

import math infinity = math.inf Now you can use ...READ MORE

Jun 27, 2018 in Python by Hamartia's Mask
• 1,580 points
513 views
0 votes
1 answer

Python comments

Use docstrings for multi-line commenting -  """ Line 1 Line ...READ MORE

May 7, 2018 in Python by Nietzsche's daemon
• 4,260 points
513 views
0 votes
1 answer

I am unable to import pyttsx2 in python. Python is throwing exception ModuleNotFoundError.

Hey, @Athrava Gulve, Hey, @Atharva, Which version of Python your ...READ MORE

Oct 7, 2020 in Python by Gitika
• 65,910 points
512 views
0 votes
1 answer

Python logical operator 'and'

If you use and on two or ...READ MORE

Jan 28, 2019 in Python by Omkar
• 69,210 points
512 views
0 votes
1 answer

How to use “raise” keyword in Python

You can use it to raise errors ...READ MORE

Jul 30, 2018 in Python by Priyaj
• 58,090 points
512 views
0 votes
1 answer

Namespace in Python

Namespace is a way to implement scope. In ...READ MORE

Nov 21, 2018 in Python by SDeb
• 13,300 points
511 views
0 votes
1 answer

Extracting extension from filename in Python

Yes. Use os.path.splitext >>> import os >>> filename, file_extension = ...READ MORE

Nov 27, 2020 in Python by Gitika
• 65,910 points
510 views
0 votes
1 answer

How to read photo using cv2 module in python?

Hi@akhtar, Yes, you can read your image in ...READ MORE

Apr 9, 2020 in Python by MD
• 95,440 points
510 views
0 votes
1 answer

Enter a 1-10, each on a new line in a file - python

Try something like this: i=1 for i in range(10): ...READ MORE

Jun 20, 2019 in Python by Greg
510 views
0 votes
1 answer

datetime.datetime.now() + 1

You can write the code as follows ...READ MORE

Mar 11, 2019 in Python by SDeb
• 13,300 points
510 views
0 votes
2 answers

How to use virtual environment in Python?

venv (for Python 3) and virtualenv (for Python 2) allow ...READ MORE

Aug 25, 2020 in Python by Pistle
• 300 points
509 views
0 votes
1 answer

What is a “method” in Python?

It's a function which is a member ...READ MORE

Oct 23, 2018 in Python by SDeb
• 13,300 points
509 views
0 votes
0 answers

name error: name 'symtr' is not globally defined

class Solution(object):     def symtr(self,root1, root2):         if(root1==None and root2==None):             return True         elif(root1==None ...READ MORE

May 14, 2020 in Python by anonymous
• 120 points
508 views
0 votes
0 answers

Numerical_vision_problem [distance_Pixels]

hello everybody, hoping that all with good ...READ MORE

May 2, 2020 in Python by anonymous
• 120 points
507 views
0 votes
1 answer

What is the purpose of self?

The reason you need to use self. ...READ MORE

Aug 3, 2018 in Python by Priyaj
• 58,090 points
507 views
0 votes
1 answer

How to randomly select an item from a list?

Use random.choice() import random foo = ['a', 'b', 'c', 'd', ...READ MORE

Dec 2, 2020 in Python by Gitika
• 65,910 points
506 views