We’re rewarding the question askers & reputations are being recalculated! Read more.
Search type Search syntax
Tags [tag]
Exact "words here"
Author user:1234
user:me (yours)
Score score:3 (3+)
score:0 (none)
Answers answers:3 (3+)
answers:0 (none)
isaccepted:yes
hasaccepted:no
inquestion:1234
Views views:250
Sections title:apples
body:"apples oranges"
URL url:"*.example.com"
Favorites infavorites:mine
infavorites:1234
Status closed:yes
duplicate:no
migrated:no
wiki:no
Types is:question
is:answer
Exclude -[tag]
-apples
For more details on advanced search visit our help page
Results tagged with Search options user 139491

Python 3 is the latest version of the Python programming language and was formally released on December 3rd, 2008. Use this tag along with the main python tag to denote programs that are meant to be run on a Python 3 interpreter only. Do not mix this tag with the python-2.x tag.

8
votes
Basically, you want your list of booleans to be sorted. Specifically, since True > False, you want your list to be sorted in decreasing order: def check_true_then_false(booleans): return boolean …
answered Sep 4 '18 by Eric Duminil
4
votes
Notes I'd expect arrangements to return the unique permutations of sequence, not just how many there are. If it returns a number, it should be an integer. You could use collections.Counter instead o …
answered Mar 20 '18 by Eric Duminil
2
votes
Theory def sieve_of_eratosthenes(limit): boolean_list = [True] * limit; There's no need for ;. It might be easier to add one element to the list and use 1-based indexing. for i in rang …
answered Jan 20 '18 by Eric Duminil
3
votes
Just a few notes: You should display the range from which the number has been chosen, and specify if the endpoint is included or not (i.e. can the number be 100?). 5 guesses aren't enough to find th …
answered May 2 '18 by Eric Duminil
27
votes
You don't need to compare prev and new during each iteration. The difference between the new and the previous sum is simply the current term : $$\frac{8}{(2i+1)^2}$$ If you want this term to be sm …
answered Mar 6 '18 by Eric Duminil
3
votes
Theory The goal of recursion is to only consider 1 base case, and modify your input until you reach this base case. That's why you shouldn't check if num <= 26 or len(string) == 1. Just wait one mor …
answered Dec 14 '17 by Eric Duminil
6
votes
Theory Calculate prime factors For a semi-naive approach, you could calculate the prime factors of n first: from collections import Counter from math import floor def factors(n, found=Counter(), s …
answered Jan 18 '18 by Eric Duminil
7
votes
Believing the Python-3.x tag, here's a way to rewrite your method: def letter_changes(text): vowels = set('aeiou') new_str = '' for c in text: cur_char = c.lower() if cur_ …
answered Mar 12 '18 by Eric Duminil
1
vote
You could run autopep8 for minor style corrections (e.g. whitespaces). Naming variables correctly is always extremely important, especially in a dynamic language, without indications about object typ …
answered Mar 23 '18 by Eric Duminil
4
votes
Upper bound for p_n There is a known upper bound for the n-th prime. It means that you don't need to guess how large it could be. upper_bound_for_p_n(10001) tells us in less than a micro-second that …
answered Feb 22 '18 by Eric Duminil
3
votes
You might want to experiment with NLTK, a leading platform for building Python programs to work with human language data: You could import it, tags the words (NOUN, ADJ, ...) and replace words in the …
answered Mar 29 by Eric Duminil
3
votes
As mentioned by @IEatBagels, it seems that you didn't understand the question. You're not allowed to split numbers into digits. You're only allowed to reorder whole numbers in order to get the maximum …
answered Jul 3 by Eric Duminil
89
votes
Stop hammering XKCD server You basically wrote a denial-of-service attack, since you try to connect as fast and as often as possible to the server. By sharing this code on CodeReview, it becomes a d …
answered Sep 2 by Eric Duminil
2
votes
As you mentioned, Pandas or at least NumPy would do just fine. They're fast and the syntax is clean and straightforward for this example. With NumPy You just need to define a mask as a boolean array …
answered Apr 20 '18 by Eric Duminil
9
votes
I've never heard of the identities mentioned by @vnp. Here are different ways to use them. Naive, recursive implementation def recursive_fibonacci(n): if n < 3: return [0, 1, 1][n] e …
answered Dec 20 '17 by Eric Duminil

15 30 50 per page