Most answered questions in Python

0 votes
1 answer

How do I create a star using the turtle module of python?

Hey @Jinu, Try something like this: import turtle star = ...READ MORE

Jun 22, 2019 in Python by Neha
1,384 views
0 votes
1 answer

Draw a square using the turtle module - Python

Hey @Baily, use something like this: import turtle sq ...READ MORE

Jun 22, 2019 in Python by Himanshu
1,340 views
0 votes
1 answer

Snake head placed on the center - Python using turtle

You can use turtle's goto() function. This ...READ MORE

Jun 21, 2019 in Python by Greg
620 views
0 votes
1 answer

What does the penup() do in Python(turtle module)

penup() basically makes sure that the moving ...READ MORE

Jun 21, 2019 in Python by Iris
5,949 views
0 votes
1 answer

Reverse a string in Python

You should try to use the following ...READ MORE

Feb 8, 2022 in Python by Rahul
• 9,670 points
507 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
529 views
0 votes
1 answer

How do I run a set of code for all the requests in Flask?

Hi, You can use dedicated hooks(decorators) called before ...READ MORE

Jun 21, 2019 in Python by Shabnam
• 930 points
613 views
+1 vote
1 answer

Python code to determine its day or night

Try something like this: sample data: (timezone= utc/zulutime) ...READ MORE

Jun 21, 2019 in Python by Imran
5,737 views
0 votes
1 answer

What is the use of join()?

Join()  function is used in threading to ...READ MORE

Jun 20, 2019 in Python by Wajiha
• 1,950 points
448 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
524 views
0 votes
1 answer

Open a file if it exists or create and open it does not exists - Python

You can use this: f = open("ex.txt","w+") Here the ...READ MORE

Jun 20, 2019 in Python by Jason
6,973 views
0 votes
1 answer

What is the difference between pop() and remove()?

Array elements can be removed using pop() ...READ MORE

Jun 20, 2019 in Python by Nisa
• 1,090 points
27,878 views
0 votes
1 answer

How do I read a file on only read only mode in python?

Hey @David! TRy something like this: campaign_data = ...READ MORE

Jun 20, 2019 in Python by Jason
597 views
0 votes
1 answer

How do I execute multiple SQL statements at once? - Python

You can use sqlite3 module. Have a ...READ MORE

Jun 20, 2019 in Python by Travis
29,917 views
0 votes
1 answer

More Pythonic way of counting things in a heavily nested defaultdict

You can try the following, this might ...READ MORE

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

How to expose std::pair to python using boost::python?

The most simple example of exposing std::pair is: class_<std::pair<int, int> ...READ MORE

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

Change the window background color using turtle - python

Try this: import turtle #set up the screen wn = ...READ MORE

Jun 19, 2019 in Python by Faiza
16,100 views
0 votes
1 answer

Change the snake head color using python turtle

You can et the snakehead color by ...READ MORE

Jun 19, 2019 in Python by Faiza
1,719 views
0 votes
1 answer

Snake head now showing when trying to build the snake game using python module turtle

Hey @Nagya, so you added the following ...READ MORE

Jun 19, 2019 in Python by Faiza
1,093 views
0 votes
1 answer

Python error "AttributeError: '_Screen' object has no attribute 'mainloop'" python module turtle

Hey @Nagya, replace  wn.mainlopp() with turtle.mainloop() ...READ MORE

Jun 19, 2019 in Python by Faiza
6,591 views
0 votes
1 answer

Why are Python lambdas useful?

The main purpose of anonymous functions come ...READ MORE

Jun 19, 2019 in Python by Wajiha
• 1,950 points
664 views
0 votes
1 answer

What happens when you use lambda inside lambda?

Yes you can use lambda inside lambda. ...READ MORE

Jun 19, 2019 in Python by Wajiha
• 1,950 points
1,941 views
0 votes
1 answer

Python error "ValueError: size needs to be (int width, int height)" while using pygame.Surface

pygame.Surface takes in integer values for building ...READ MORE

Jun 19, 2019 in Python by Varsha
5,284 views
+1 vote
1 answer

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

icon = pygame.image.load('spaceship.png') pygame.error: Couldn't open spaceship.png I am ...READ MORE

Apr 9, 2020 in Python by Ali
10,176 views
0 votes
1 answer

Where is builtins module located?

The module is built-in to the python ...READ MORE

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

Combine selector conditions

In a nutshell, you can do: A[:, range(3) ...READ MORE

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

Package installed but still says "ImportError: No module named pygame.locals"

So Harsha, you Import the module first ...READ MORE

Jun 18, 2019 in Python by Varsha
3,690 views
0 votes
1 answer

Python error "ImportError: No module named pygame.locals"

You need to download and install the ...READ MORE

Jun 18, 2019 in Python by Greg
6,313 views
0 votes
1 answer

How to synchronize python lists?

threading provides Lock objects if you need to protect an ...READ MORE

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

Get bbox in data coordinates in matplotlib

I'm not sure how you got the ...READ MORE

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

Python function to find a list of all keywords

You can use the keyword module for ...READ MORE

Jun 17, 2019 in Python by Ayman
8,864 views
0 votes
1 answer

Python function to check if a given string is a keyword

You can get the list of keywords ...READ MORE

Jun 17, 2019 in Python by Drishya
1,975 views
0 votes
1 answer

python code to find if an array is monotonic

Hey Harsha, try out this code: def monotonic(a): ...READ MORE

Jun 17, 2019 in Python by Yesha
2,214 views
0 votes
1 answer

Python Error saying "NameError: global name 'true' is not defined"

It's a very small mistake. Change true ...READ MORE

Jun 17, 2019 in Python by Vinayak

edited Oct 7, 2021 by Sarfaraz 15,642 views
0 votes
1 answer

What does the map() method do in Python?

The map() function in Python is a ...READ MORE

Jun 17, 2019 in Python by anonymous
611 views
0 votes
1 answer

Using lambda functions to solve Algebra

Python lambda functions can be used to ...READ MORE

Jun 17, 2019 in Python by anonymous
2,680 views
0 votes
1 answer

Reconstruct an array by replacing every element with a[[i-1]%K] - Python

Hey varsha, Have a look at this ...READ MORE

Jun 14, 2019 in Python by Miya
1,191 views
0 votes
1 answer

Length and dimensions of NumPy arrays

The length of NumPy arrays can be ...READ MORE

Jun 14, 2019 in Python by Wajiha
• 1,950 points
1,097 views
0 votes
1 answer

How to check if a website allows web scraping?

To check if a website allows web ...READ MORE

Jun 14, 2019 in Python by Wajiha
• 1,950 points
15,778 views
0 votes
1 answer

Python array multiply

When you multiply a sequence by X in Python, ...READ MORE

Jun 14, 2019 in Python by SDeb
• 13,300 points
3,163 views
0 votes
1 answer

How to fill a list?

Consider the usage of extend: >>> l = [] >>> ...READ MORE

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

Error while converting a list into a numpy array

The only possible reason I could think ...READ MORE

Jun 14, 2019 in Python by Rhea
2,448 views
0 votes
1 answer

Python Error ""ValueError: could not broadcast input array from shape (4) into shape (1000)""

There are better ways of achieving the ...READ MORE

Jun 14, 2019 in Python by Faiza
29,757 views
0 votes
1 answer

Information about functions or classes in Python

Information about functions, classes, modules, etc can ...READ MORE

Jun 13, 2019 in Python by Nisa
• 1,090 points
517 views
0 votes
1 answer

Low precision and high recall application - Logical regression

In situations where you wish to reduce ...READ MORE

Jun 13, 2019 in Python by Meg
2,652 views
0 votes
1 answer

High Precision value and low recall value - Logistic regression

You use high positive and low recall ...READ MORE

Jun 13, 2019 in Python by Greg
1,631 views
0 votes
1 answer

Python error "pandas.errors.ParserError: Error tokenizing data"

Pandas do not take .xlsx files. Rename ...READ MORE

Jun 13, 2019 in Python by Rhea
18,778 views
–1 vote
1 answer

Python error saying "NameError: name 'email' is not defined"

you need to define the variable email READ MORE

Nov 29, 2019 in Python by Casper
• 160 points
6,410 views
0 votes
1 answer
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
542 views