Most answered questions in Python

+1 vote
2 answers

Replace every character of string by character whose ASCII value is K times more than it

Refer below code for your problem statement def ...READ MORE

May 17, 2020 in Python by Kumar Sambhawam

edited May 18, 2020 by Gitika 16,760 views
0 votes
2 answers

Change the default indexing of an array in pandas

df = pd.DataFrame({'month': [1, 4, 7, 10],                    'year': ...READ MORE

Nov 28, 2019 in Python by nagendra reddy
924 views
+1 vote
2 answers

Python error "ZeroDivisionError: float division by zero"

The error is thrown in this line matchPercentage ...READ MORE

May 21, 2020 in Python by Prabhakar
22,796 views
+2 votes
2 answers

Google search using Python

import webbrowser search=input('Search: ') webbrowser.open('https:// ...READ MORE

Dec 25, 2019 in Python by Makhmudov
2,422 views
0 votes
2 answers

Is it possible to save python dictionary into json files?

You can save the Python dictionary into ...READ MORE

Mar 17, 2020 in Python by Vishal
• 180 points
71,868 views
0 votes
2 answers

How to declare constants in python?

In python we don't require to declare ...READ MORE

Aug 18, 2019 in Python by anonymous
• 460 points
669 views
+1 vote
2 answers

How to automate image upload from my computer to site using python-selenium?

Hey, this code worked for me: image_path=os.path.abspath('.\\folder1\\subfolder2\file1.jpg') driver.find_element_by_id("Id of ...READ MORE

Aug 19, 2019 in Python by Rishi
5,687 views
0 votes
2 answers

Python error "ImportError: No module named 'tkinter'"

sudo apt-get install python3-tk Then, >> import tkinter # ...READ MORE

Nov 9, 2019 in Python by Icetutor
• 160 points
24,294 views
0 votes
2 answers

How to solve the error - ssl module not found?

Hey, @There, nstall the necessary packages for Python ...READ MORE

Oct 23, 2020 in Python by Gitika
• 65,910 points
2,166 views
0 votes
2 answers

Is it possible to launch python idle from a virtual environment?

Try running the following code. #!/usr/bin/env python """Simple script ...READ MORE

Jun 25, 2020 in Python by Sirajul
• 59,230 points
5,355 views
0 votes
2 answers

Python error " import requests ImportError: No module named requests"

Hello, Open Cmd or Powershell as Admin. type pip ...READ MORE

Nov 28, 2020 in Python by Rohan
• 200 points
16,920 views
0 votes
2 answers

What is random.sample() method in Python?

The use of random.sample() Randomly select multiple items from ...READ MORE

Mar 13, 2020 in Python by Vishal
• 180 points
4,561 views
0 votes
2 answers

%matplotlib inline SyntaxError: invalid syntax

I found a good solution to solve ...READ MORE

May 2, 2020 in Python by Edu
24,282 views
+1 vote
2 answers

sklearn.cross_validation import train_test_split not working

How ever now its in model selection ...READ MORE

Jul 17, 2020 in Python by karthikeyan
17,839 views
–1 vote
2 answers

In Python, How do I read 2 CSV files, compare column 1 from both, and then write to a new file where the Column 1s match?

Hi @Mike. First, read both the csv ...READ MORE

Jul 24, 2019 in Python by Omkar
• 69,210 points
32,515 views
+2 votes
2 answers

UnicodeDecodeError: "utf-8" codec can't decode byte in position : invalid start byte

You have to use the encoding as latin1 ...READ MORE

Jul 23, 2019 in Python by Kunal
242,575 views
0 votes
2 answers

What is the python logic to check if a number is armstrong number or not?

a = int (input('enter number')) num = a sum ...READ MORE

Jul 16, 2020 in Python by amrut
• 240 points
1,312 views
0 votes
2 answers

How to define a class in python?

Class use the special word  class for declaration. ...READ MORE

Jun 6, 2020 in Python by anonymous
• 580 points
852 views
0 votes
2 answers

How do you read from a file using file handling in python?

for write, read,append data in file check ...READ MORE

Jun 21, 2020 in Python by sahil
• 580 points
913 views
0 votes
2 answers

How to check whether a string contains alphabets or number in Python?

By using isAlpha () to check whether ...READ MORE

Jul 14, 2019 in Python by Sheik janibasha
4,983 views
0 votes
2 answers

Finding local IP addresses using Python's stdlib

import socket s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) s ...READ MORE

Mar 30, 2020 in Python by anonymous
2,619 views
0 votes
2 answers

How to lock a thread in Python?

Lock objects can release the lock at ...READ MORE

Jul 23, 2020 in Python by sahil
• 580 points
683 views
0 votes
2 answers

How do you convert a dictionary to a defaultdict?

from collections import defaultdict a = {1: 2, ...READ MORE

Aug 2, 2019 in Python by Mohammad
• 3,230 points
8,870 views
0 votes
2 answers

Get key by value in dictionary

I have slightly modified your program to ...READ MORE

Nov 25, 2021 in Python by Python Coder
583 views
0 votes
2 answers

How to check if a csv file is empty in pandas?

Try this: df = pd.DataFrame(columns=['Name', 'ID', 'Department']) if df.empty ...READ MORE

Jul 1, 2019 in Python by Bob
14,037 views
0 votes
2 answers

Python error "pygame.error: Couldn't open pygame.png"

add import os at top of your ...READ MORE

Sep 25, 2020 in Python by anonymous
1,416 views
0 votes
2 answers

Check if there exists two elements in the array whose sum is equal to the sum of the entire array

You can try something like this Harsh: def ...READ MORE

Jun 17, 2019 in Python by Ayman
3,315 views
+1 vote
2 answers

Python error "Python: can't assign to literal"

The way you're assigning variables is not ...READ MORE

Jun 17, 2019 in Python by Priya
15,048 views
0 votes
2 answers

Python Error "UnicodeEncodeError: 'ascii' codec can't encode character u'\u03b1' in position 20: ordinal not in range(128)"

import csv import sys reload(sys) sys.setdefaultencoding('utf8') data = [["a", "b", u'\xe9']] with ...READ MORE

Jun 28, 2019 in Python by anonymous
13,288 views
0 votes
2 answers

What is the difference between python lists and arrays?

Python arrays and lists have the same ...READ MORE

Jun 11, 2019 in Python by Nisa
• 1,090 points
1,091 views
0 votes
2 answers

Python error "TypeError: Can't convert 'int' object to str implicitly"

A TypeError can occur if the type ...READ MORE

Feb 5, 2020 in Python by lovelmark
• 160 points
1 flag 18,175 views
+1 vote
2 answers

Cannot install tensorflow on 32-bit Python

Unfortunately tensorflow is not supported on 32 ...READ MORE

Jan 13, 2020 in Python by jaakko
• 160 points

edited Apr 18, 2022 by Sarfaraz 11,638 views
0 votes
2 answers

Pick a random item from the list - Python

You can also use secrets.choice() import secrets list = ...READ MORE

May 28, 2019 in Python by Kim
1,070 views
0 votes
2 answers

Which programming language should I learn - Python or PHP?

It really depends on what you want ...READ MORE

Jun 11, 2019 in Python by Morten

reshown Jun 11, 2019 by Vardhan 611 views
+2 votes
2 answers

What is the difference between print and return in python?

Return statements end the execution of a ...READ MORE

Aug 26, 2019 in Python by anonymous
7,472 views
0 votes
2 answers

How can I write a program to add two numbers using functions in python?

there is sum() function as a built ...READ MORE

Oct 25, 2020 in Python by anonymous
23,282 views
+1 vote
2 answers

How to display column names of Pandas Dataframe?

print(list(your_df)) READ MORE

Jan 18, 2020 in Python by anonymous
21,856 views
0 votes
2 answers

Tkinter “module not callable” error.

This error statement TypeError: 'module' object is ...READ MORE

Jun 27, 2019 in Python by rahul
• 360 points
20,534 views
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

Jul 7, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 4,060 views
0 votes
2 answers

Django forms in ReactJs

Did you ever find a solution for ...READ MORE

Feb 6, 2020 in Python by martin
2,910 views
0 votes
2 answers

Invalid Token in Python

in python version 2.7,3.6.8 you can't write ...READ MORE

Jun 25, 2020 in Python by ker
6,815 views
0 votes
2 answers

how can i randomly select items from a list?

You can also use the random library's ...READ MORE

Apr 9, 2020 in Python by Patrick
4,899 views
0 votes
2 answers

How to create empty pandas dataframe?

To create a simple empty DataFrame, use ...READ MORE

Aug 10, 2020 in Python by Nehal
• 140 points

edited Aug 10, 2020 by Nehal 11,016 views
0 votes
2 answers

why do we use operator.abs

 python and abs() in Python The abs() take ...READ MORE

Apr 3, 2019 in Python by anonymous
735 views
+1 vote
2 answers

how can i do a binary search in python?

def Binary_search (array , element):       ...READ MORE

Jul 10, 2020 in Python by anonymous
• 240 points
755 views
0 votes
2 answers

Python Pandas error: AttributeError: 'DataFrame' object has no attribute 'rows'

Try this: data=pd.read_csv('/your file name', delim_whitespace=Tru ...READ MORE

Dec 10, 2020 in Python by anonymous
• 82,880 points
130,305 views
0 votes
2 answers

how to use sum() in python?

sum()=sum all item in a tuple  syntax: sum(iterble,start) iterable required. The ...READ MORE

Mar 26, 2019 in Python by rajesh
• 1,270 points
753 views
0 votes
2 answers

what is the procedure to the version of python in my computer?

Execute the following command on your terminal: python ...READ MORE

Mar 20, 2019 in Python by Alia
626 views
0 votes
2 answers

Explain OOPs concept in python with programatic examples

OOP reflects the real world behavior of ...READ MORE

Jun 24, 2020 in Python by rahul
• 360 points
1,525 views
0 votes
2 answers

Do we have pointers in python like other programming languages?

From one point of view, everything is a pointer in Python. Your ...READ MORE

Dec 16, 2020 in Python by Gitika
• 65,910 points

edited Jul 8, 2021 by Sarfaraz 61,671 views