Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange
Join us in building a kind, collaborative learning community via our updated Code of Conduct.

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.

5
votes
3answers
285 views

Median Calculation of List of Integers without using heap

References Using those references: rolling median implementations benchmark FAST RUNNING MEDIAN USING AN INDEXABLE SKIPLIST Calculate the median of a billion numbers Find running median from a ...
-2
votes
0answers
18 views

Insert dataframe to SQL database [on hold]

I am trying to insert the Dataframe which looks like this ...
1
vote
3answers
50 views

Find the year when the user will turn 100

I moved to Python today after doing a little of c++. The following code works as intended, but I want to know if I should add the if __name__ == "__main__" ...
0
votes
1answer
25 views

Binary search tree traversal and depth first search in Python

I am learning about the tree traversal, and I would like to ask for feedback. Using recursion, write a function that takes in a binary search tree and number of outputs a list of values ordered by ...
-2
votes
0answers
22 views
-2
votes
1answer
78 views

Project Euler Problem 1 with Python 3 ideal solution

I have been playing around in hacker rank with Python these days, and now pulling my hair out on this question to solve the Euler's problem in the least time required. If we list all the natural ...
2
votes
2answers
52 views

Parsing date strings, inferring the year such that the date is not in the future

I got this program that I am working on and in it, I got a section that has a try statement and two error except statements. ...
3
votes
2answers
42 views

Using Python to create a JSON file of recipes from MySQL

I needed to create a JSON file from a couple of MySQL tables to migrate some recipes from wordpress. This was my first time writing a script in python and would like to get some feedback on what I ...
2
votes
2answers
189 views

Credit card validity check [on hold]

I want to go more in depth, but this is the 'boilerplate'. Is there any way I can optimize this or use more idiomatic Python code? ...
2
votes
0answers
45 views

Numerical evaluation of line integral

I have written a function that evaluates a contour integral in Python (Poincaré - Hopf index for 2D vector fields). It works, however is really slow if the arg res=N...
5
votes
2answers
86 views

Finite state automata

This is a non-deterministic finite state automata (NFA) meant to be used with a Regex engine. To show some example usage, suppose you wanted to construct an NFA for the regex ...
5
votes
2answers
64 views

2048 style game

I have made a replica of the game 2048. It works exactly how the game should work. However I was just looking to know where I could've possibly cleaned up my code or make it more efficient. ...
4
votes
2answers
54 views

TicTacToe game in Python 3

I wrote this program in Python 3.I would like to know if there is some more functionality that could be added/removed/is missing.Any comments would be helpful! ...
0
votes
1answer
45 views

Blackjack strategy simulation

I'm very new to python (been coding for about two days) and have created a programme that simulates blackjack games so that I can work out optimal strategy over many iterations. The problem is that ...
-5
votes
0answers
17 views

Force Brute with Python 3 [on hold]

I need a script in python 3 to have all combinations of 10 characters from these characters: 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ. (fr)J'ai besoin d'un script en python 3 pour avoir toutes les ...
8
votes
2answers
77 views

Python 3 two-sum performance

I just submitted a Python solution to the 'Two Sum' problem on LeetCode. The Problem Given an array of integers, return indices of the two numbers such that they add up to a specific target. ...
4
votes
1answer
35 views

Python program that gets basic information on a Github user

I've created a basic Python CLI script, which takes a Github username, and returns some basic information associated with said username. I use the requests for HTTP requests (I'm new to this area) and ...
2
votes
1answer
44 views

Python code to get Accrued interest

I've wrote this code and it does what is expected. However, I'm thinking if there are better ways to write this, specially if is useful to wrap it in a class, or other ways to make it less loosen. I'...
-3
votes
0answers
26 views

Bugs in TicTacToe game Python 3 [closed]

I wrote this program in Python 3.I would like to know if there is some more functionality that could be added/removed/is missing.Any comments would be helpful! ...
6
votes
0answers
28 views

Library for RCON clients

I wrote a library implementing the RCON protocol to automate interaction with Minecraft servers. I know that there are already a couple of implementations out there, but neither I found was convincing ...
3
votes
1answer
31 views

Searching Online English Dictionaries - follow-up

This is a follow-up to Searching online English dictionaries: ...
3
votes
2answers
78 views

Reading set of large log files line by line and count how many hostnames appear on each line

I have around 300 log files in a directory and each log file contains around 3300000 lines. I need to read through each file line by line and count how many hostnames that appear on each line. I wrote ...
6
votes
2answers
268 views

UDP Reverse Shell

I'm currently learning python / network programming altogether and I coded this simple python reverse shell; I would like to hear any remarks from you regarding code structure, any common beginner ...
3
votes
1answer
37 views

Memory Game using Tkinter/Pygame

I'm very new to python and programming in general. For a school assignment, I made this Memory Game and would love to receive feedback from you guys. ...
2
votes
1answer
27 views

Password field based on peewee ORM framework

I implemented a password field based on the peewee framework to handle passwords of accounts in web applications for Python 3.4. My goals were Secure hashing. No plain password leakage. Easy ...
5
votes
1answer
76 views

Shunting-yard algorithm

I implemented the Shunting-yard algorithm in Python, I have experience in C# but I'm looking for comments making this more pythonic. I'm also be interested if these methods would be better as ...
4
votes
2answers
71 views

Scrape data from website into dataframe(s) using Split function

Outline: This code uses the Split function to extract specific information from the following website: https://www.webscraper.io/test-sites/tables. The required ...
5
votes
1answer
53 views

Spearman correlations between Numpy array and every Pandas DataFrame row

I want to efficiently calculate Spearman correlations between a Numpy array and every Pandas DataFrame row: ...
6
votes
1answer
30 views

Signal output on Raspberry Pi that acts as input for FPGA

Problem I'm writing a verilog program that does the trapezoidal integration method (where a review is also welcome, wink wink). But turns out you need input for these kind of things, so in the overly ...
8
votes
2answers
1k views

Python Output Class

I have the following Python output class that I'm planning to use across a number of modules in a terminal application: ...
3
votes
1answer
31 views

Pivot and annotate Pandas DataFrame

Given the CSV data: ,fan1,fan2,foil1,foil2 0,0.0,0.0,0.0,0.125 1,0.0625,0.0,0.0625,0.125 2,0.0625,0.0,0.0,0.3125 Which I want to turn into a kind of annotated ...
6
votes
2answers
520 views

Simple Censor Program

I made a function to censor a certain word from a piece of text. Is there anything I should fix or do more efficiently? What are some other approaches I could have taken to detecting words and ...
5
votes
0answers
36 views

Comparing same-size files and reporting on the differences byte-by-byte

I created a small Python utility to analyze multiple same-size files and report on the difference byte-by-byte (i.e. Hamming distance, not Levenshtein distance.) I am planning to extend the ...
7
votes
2answers
87 views

A game of automated tag

This game has 4 people moving randomly, one unit in one of the four directions (up, down, left, right), with a fifth person as a designated tagger. If this fifth person tags someone, the person is out....
4
votes
2answers
140 views

Iterate over a list of list names as file names

Interrogating a web API using query-url's, for each query I can get either zero hits, one hit, or multiple hits. Each of those categories needs to go into a separate CSV file for manual review or ...
3
votes
1answer
31 views

Library to wrap notify-send

I wrote a library and two related scripts to wrap notify-send from libnotify. I need this script, since I am remotely ...
4
votes
0answers
46 views

pool of python coroutines

Task control how much coroutines are running simultaneously with ability to stop the process from inside. Use case when scraping websites you want to control how much memory program consumes and ...
8
votes
3answers
404 views

Simple Shop Program

I'm new to programming and this is one of my first programs. I had no idea what I was doing so most of this program was made from bad bug-fixing that barely managed to fix the bugs. I'm sure that ...
6
votes
2answers
74 views

Split big file into separate files depending on column's distinct values

I have a big file, which contains column names in the first row. The data is about 20GB and consists of 10s of millions of rows. Every other row contains data which I would like to append to other ...
3
votes
1answer
55 views

Simple dirbuster with threading

I've made a simple dirbuster. (I wanted to play with threading.) The program makes requests to fuzz for files and/or directories on a site. Featuring fuzzing for response codes fuzzing for files ...
16
votes
7answers
2k views

Program to check if a date is valid or not

I am a novice programmer and am currently learning Python programming by myself through a book. I stumbled upon a question in a chapter and it took me 2 days to figure out a solution for it. Although, ...
4
votes
0answers
171 views

Asyncio HTTP Request Queue

I wrote a simple sitemap.xml checker using asyncio and aiohttp. I followed the documentation demonstrating the producer/consumer pattern. However, I noticed that as the URLs scale larger, it seems to ...
5
votes
1answer
35 views

Non normalized set difference algorithm

I'm trying to set up an algorithm in python for getting all sets from a set (DataSet1) less any instances of data in a second set (DataSet2). Objective: ...
3
votes
2answers
106 views

Python function to find the next smaller number with same set of digits

Problem: Write a function that takes a positive integer and returns the next smaller positive integer containing the same digits. My solution: ...
1
vote
1answer
35 views

Finding the position in a triangle for the given challenge

The LAMBCHOP doomsday device takes up much of the interior of Commander Lambda's space station, and as a result the prison blocks have an unusual layout. They are stacked in a triangular shape, and ...
4
votes
1answer
40 views

Systematically analyzing dice roll outcomes

I created a generator function to iterate through all possible dice rolls, and then applied it the ability score generating methods in Pathfinder RPG. (Obviously, there are more efficient ways to ...
5
votes
0answers
59 views

Implementing numerical integration in Python

I have this Python code that implements a rectangular numerical integration. It evaluates the (K-1)-dimensional integral for arbitrary integer \$K \geq 1\$ $$\int_{u_K = 0}^{\gamma}\int_{u_{K-1} = 0}^...
4
votes
2answers
57 views

Use Python to determine the repeating pattern in a string (no leftovers)

As a part of a challenge, I was asked to write a function to determine if there was repetition in a string (if no repetition, output is 1), and if a substring is repeated throughout the string (for ...
6
votes
1answer
140 views

Reading and returning the HTML content from a specified URL

I wanted to create a simple function that can read and return the HTML content from a specified URL. This is what reading here and there lead me to: ...
2
votes
1answer
50 views

Store nested json repsonses in relational database

The goal is to collect market data from a free rest api. The response is in json and size per response is above 1MB. I want to get at least updated data once per minute which means about 24h * 60min * ...