Questions tagged [python-3.x]

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.

Filter by
Sorted by
Tagged with
29 votes
4 answers
7k views

Sieve of Eratosthenes - Python

I've been doing a lot of Project Euler lately and just wanted to make sure my implementation was as good as it could be. Does anyone have any suggestions to speed this up? ...
Igglyboo's user avatar
  • 447
7 votes
3 answers
3k views

Efficiency of Project Euler problem 35

The number, 197, is called a circular prime because all rotations of the digits: 197, 971, and 719, are themselves prime. There are thirteen such primes below 100: 2, 3, 5, 7, 11, 13, 17, 31, 37, 71, ...
yask's user avatar
  • 245
15 votes
2 answers
7k views

Evaluating arithmetic expressions

I have written some simple code for evaluating expressions. However, I am not sure how well I am following conventions (this is my first time trying to). Specs for problem: All binary operators (+, -...
internet_user's user avatar
13 votes
3 answers
2k views

AniPop - The anime downloader

Note: The topics of performance and Selenium/BS4 have not yet been addressed, so this question can still receive a better answer! Chat Room: https://chat.stackexchange.com/rooms/100275/anipop-...
T145's user avatar
  • 3,087
7 votes
2 answers
6k views

Character Picture Grid exercise - automatetheboringstuff

Regarding the Character picture exercise located at the end the following page: https://automatetheboringstuff.com/chapter4/ Say you have a list of lists where each value in the inner lists is a ...
drapozo's user avatar
  • 115
5 votes
1 answer
190 views

Arabic language lesson program

The program I have been working on has been developed almost exclusively as "train-of-thought" style code. Things happen linearly (for the most part) thru the code. The goal of the program is to house ...
Jack Duane's user avatar
5 votes
2 answers
3k views

Generating frequency tables based on CSV dataset

I am working on a project which crunches plain text files (.lst). The name of the file names (fileName) are important because I'...
Bram Vanroy's user avatar
5 votes
1 answer
680 views

Instagram scraper Posts (Videos and Photos)

I wrote this code which has the ability to download images and videos from a specific Instagram profile. Using multiprocessing and threading I managed to speed up the extraction of data. My goal is ...
AlexDotis's user avatar
  • 417
4 votes
1 answer
156 views

Abstract graphing-and-timing functions

I like to use timeit to measure performance of small, and sometimes big, functions. However it can be uncertain as to what the 'actual' time to execute the function ...
Peilonrayz's user avatar
  • 42.7k
4 votes
0 answers
2k views

Breadth-first search: traditional and bidirectional in Python - follow-up

I have refactored the version of the previous (and initial) iteration according to the answer by alexwlchan. As a reminder, this snippet compares breadth-first search against its bidirectional variant....
coderodde's user avatar
  • 27k
3 votes
1 answer
4k views

Scraping Instagram with selenium, extract URLs, download posts

I made a very simple Instagram Bot that can download images and videos of the user, like Gallery with photos or videos. It saves the data in the folder. How it works: Creating directory for saving ...
AlexDotis's user avatar
  • 417
1 vote
3 answers
830 views

Custom exception handling function or logging library?

I want to document every exception handled in my code and some states of the code when it works properly. What I've done is two functions, one that creates an 'error report' (function: ...
Lucas Fernandez's user avatar
39 votes
4 answers
5k views

Beheading of knights, who survives?

We have a round table of n knights, where n is some positive integer. These have failed to satisfy the expectations of the mad ...
N3buchadnezzar's user avatar
17 votes
5 answers
35k views

Reversing a String in Python

I have a simple function that takes a string and reverses it: ...
Michael A's user avatar
  • 1,641
17 votes
3 answers
6k views

Number of Islands in a 2d grid

Recently, I've solved this "Number of Islands" problem on LeetCode, the solution was accepted by the LeetCode OJ. Problem Description Given a 2d grid map of '1's (land) and '0's (water), count the ...
alecxe's user avatar
  • 17.2k
16 votes
2 answers
3k views

ECDH implementation in python

I wrote an implementation of elliptic curve Diffie-Hellman key exchange in python. I would like to know if I could make it faster, cleaner or more secure: ...
Aemyl's user avatar
  • 690
15 votes
1 answer
4k views

Merge n sorted iterators

Over the weekend I was curious about efficiently merging multiple sorted iterators together, and for them to be in sorted order. This is quite like a challenge on HackerRank: You’re given the ...
Peilonrayz's user avatar
  • 42.7k
13 votes
2 answers
156 views

"Drone Racer" now shipping in your local area

This question is a follow-up of this one; where I present a software to plan and manage drone races. I might come with a new question about the SQL part in a few days as well. The code can still be ...
301_Moved_Permanently's user avatar
13 votes
2 answers
1k views

Segmented wheel Sieve of Eratosthenes in Python

Here is a new version of a segmented and wheel factorized Sieve of Eratosthenes. It currently uses mod 30 wheel factorization to eliminate multiples of 2, 3, and 5 in the sieve data structure to gain ...
Greg Ames's user avatar
  • 305
12 votes
2 answers
2k views

Memoizing decorator that can retry

I have some tasks that I'd like to memoize because they connect to a rather slow network and have to wait for the data. Unfortunately this network can be a little finnicky and we get occasional ...
Dan Oberlam's user avatar
  • 7,764
12 votes
3 answers
2k views

PyDOS shell simulation

I have a big project called 'PyDOS', written in Python 3.4, and it's going very well. Post your answers of anything that could make it look cleaner. ...
PyxlWuff's user avatar
  • 471
12 votes
6 answers
4k views

Python 3 - Fibonacci Implementation

I wrote a function returning the n-th Fibonacci number in Python 3: ...
user7802048's user avatar
12 votes
2 answers
4k views

CodeFights: Pipes game

Description Carlos always loved playing video games, especially the well-known computer game "Pipes". Today he finally decided to write his own version of the legendary game from scratch. In ...
Ludisposed's user avatar
  • 11.5k
11 votes
3 answers
2k views

RattleHiss (fizzbuzz in python)

This is an iterative review. The previous iteration can be found here. The next iteration can be found here I've now been programming in python for all of 4 hours. At 70 lines it's rather verbose ...
Kaz's user avatar
  • 8,810
10 votes
2 answers
21k views

Pretty-print Pascal's triangle

...
matheussilvapb's user avatar
10 votes
1 answer
162 views

Wordcloud from all answers of a user here on CR

Since I haven't really used Python's new async features yet, I took some older code of mine, which took all of my answers here on Code Review and generated a word cloud from them, and updated it to ...
Graipher's user avatar
  • 40.8k
9 votes
1 answer
6k views

Equation parser and solver

I wrote this equation parser and solver, I feel like it is well documented and tested: ...
Caridorc's user avatar
  • 27.4k
9 votes
1 answer
10k views

Creating truth table from a logical statement

This code creates a truth table from a statement in logic. The statement is input as a string, and it is identified as a tautology if it is true for all true and false combinations of the variables. ...
Vermillion's user avatar
9 votes
2 answers
1k views

Decoding grayscale PNG and performing Prewitt operator for edge detection

I'm a hobbyist programmer. What I try to do here is to read 8-bit grayscale PNG file. Then unfilter it. (That caused a headache). And after that perform Prewitt operator for "edge detection". I know ...
Evus's user avatar
  • 205
8 votes
1 answer
445 views

Measure time and space requirements of different Python containers

I was actually kind of bored and since I'm studying some Python data structures I decided to make some size(MB) and time(secs) comparisons between different containers when conducting the operation of ...
user avatar
7 votes
3 answers
336 views

SQL Query generator, round 2

This is the second round of reviews. The first round can be found in this question. This is a project I have been working on. This is one of my first experiences with Python and OOP as a whole. I ...
JAD's user avatar
  • 2,909
7 votes
2 answers
435 views

Finding min and max values of an iterable on the fly

This is a follow up for my question about optimizing solution for DNA Health HackerRank problem. Short re-cap: You are given 2 arrays (genes and ...
Denis Shvetsov's user avatar
6 votes
1 answer
3k views

Tic-Tac-Toe with changeable board size (Part 1)

Part 2: Tic-Tac-Toe with changeable board size (Part 2) I've created a Tic-Tac-Toe program with python which has a option to change a standard 3x3 board to NxN board. I've also created easy, hard and ...
Sriv's user avatar
  • 2,720
6 votes
1 answer
2k views

Scraping Instagram - Download posts, photos - videos

Python script that can downloads public and private profiles images and videos, like Gallery with photos or videos. It saves the data in the folder. How it works: Log in in instragram using selenium ...
AlexDotis's user avatar
  • 417
6 votes
1 answer
380 views

Entire Discord bot

I've made a Discord bot, and (to my knowledge) the code is pretty good. However, I've mostly taught myself Python and discord.py (the discord library for Python), so I was wondering if there's any ...
Joyte's user avatar
  • 135
6 votes
2 answers
22k views

Two-player dice game for NEA task computer science (Updated)

This is a game for two users who roll 2 dice 5 times. If the total of dice is even the player gains 10 points; if it is odd, they lose 5. If there is a draw after five rounds then both users will ...
colkat406's user avatar
  • 482
6 votes
1 answer
558 views

Web scraper that extracts urls from Amazon and eBay

Description: This is a simple script for scraping Amazon and eBay category, sub-category and product URLs and saving contents to files. In case of previously saved files, the files will be read and no ...
watch-this's user avatar
6 votes
2 answers
4k views

2 player dice game, where even total gains points and odd total loses points NEA task computer science

This is a game for two users who roll 2 dice 5 times. If the total of dice is even the player gains 10 points if it is odd, they lose 5. If there it is a draw after five rounds then the both users ...
colkat406's user avatar
  • 482
5 votes
2 answers
9k views

Print initial letter of an entered name

Just started learning python and I'm solving some beginner problems. I wrote a solution for a question without any edge cases like user not entering anything, entering numbers etc.: Question: Write ...
Ram Chandra Giri's user avatar
5 votes
1 answer
997 views

Python Port Scanner 2.0

A few months ago I put up a port scanner for review. Now, I've updated it with some new Python knowledge and integraing the feedback I got. Some things I specifically think might be wrong with it or ...
asteri's user avatar
  • 4,879
5 votes
1 answer
184 views

Arabic language lesson program Part 2

This is the second time I am asking for a review of this code (first time can be found here: Arabic language lesson program). The goal of the program hasn't changed - to house Arabic language lessons ...
Jack Duane's user avatar
4 votes
1 answer
92 views

Back to Basics - Tic Tac Toe

I've seen a few TTT related posts recently, and thought I might learn something or be reminded of certain techniques from attempting my own rendition. Here is that attempt! Hopefully any new coders ...
T145's user avatar
  • 3,087
4 votes
1 answer
655 views

Assigning sentiment to each tweet - Twitter trend

Below assignment is taken from here. Introduction In this project, you will develop a geographic visualization of twitter data across the USA. You will need to use dictionaries, lists, and ...
overexchange's user avatar
  • 3,321
4 votes
1 answer
83 views

Mail Crypt CLI encrypted email wrapper for Gmail

I've spent the past few days writing a python based client that allows you to locally encrypt your message and send it through Gmail. The encryption scheme is based off of hybrid RSA/AES encryption, ...
Joe Smith's user avatar
  • 170
4 votes
2 answers
1k views

Serializing (nested) data structures in a human-readable format

I am reinventing the wheel to write a function that serializes a (nested) data structure human readably. The default output is deliberately similar to that of ...
Ξένη Γήινος's user avatar
4 votes
1 answer
574 views

Improving time complexity of finding the longest palindrome in Python

The Longest Palindromic Substring challenge from InterviewBit: Given a string S, find the longest palindromic substring in S. where a "substring" must be contiguous, and in case of ties ...
Mona Jalal's user avatar
3 votes
2 answers
261 views

Sequence processing problems

Problem 1: Sum the even numbers for the first n fibonacci numbers Solution: ...
overexchange's user avatar
  • 3,321
3 votes
1 answer
769 views

Web scraping using selenium, multiprocessing, InstagramBot

An Instagram Bot which downloads the posts from profile I have to mention my previous posts: Instagram scraper Posts (Videos and Photos) Scraping Instagram with selenium, extract URLs, download ...
AlexDotis's user avatar
  • 417
3 votes
3 answers
288 views

Most effective search algorithm for guessing list of strings via function returning bool if substring is in list using Python

I trying to figure out the most effective way to accomplish this task: A function, check(), contains a list of strings. Calling the function with a string as ...
n0k's user avatar
  • 31
3 votes
1 answer
146 views

Python3 Stack implementation with List built-in - Round Two

Previous code is available at Python3 Stack implementation with List built-in, this is a second-round review after I made alterations. Once again, let's review my Stack implementation, with built-in ...
Thomas Ward's user avatar
  • 2,518

1
2 3 4 5
10