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
5
votes
1answer
74 views

Fetch StackOverflow questions and save them to a markdown table

I'm trying to write a script that would (a) fetch StackOverflow questions and (b) update a markdown table with new entries. With github actions I automated this script to run daily. Idea borrowed from ...
3
votes
0answers
9 views

Extract the data from Dicom files in an time efficient way

I am trying to extract and save images from a Dicom dataset. It is taking approximate 4-5 hours to process 1000 files. (Also, I am reading and saving files in an external hard drive so there is a time ...
8
votes
0answers
40 views

Dungeon Ball, a Pygame

I just completed the first release for my first game on Python, called Dungeon Ball. I'm looking for people to test out the app and give me some feedback and constructive criticism. I'd like to use ...
4
votes
1answer
74 views

Vectorized crosstabulation in Python for two arrays with two categories each

I have two Python lists, label and presence. I want to do cross-tabulation and get the count for each block out of four, such as ...
6
votes
2answers
54 views

Python - use a list of names to find exact match in pandas column containing emails

I have an Excel file containing a free-form text column (that sometimes is structured like an email), where I need to find all first and last names and add an extra columns saying TRUE/FALSE to these ...
4
votes
1answer
51 views

AVL Tree implementation Based on VisualGo

I have tried implementing an AVL Tree on my own, based on visualising it. But i'm unsure how many testcases it work with, and how efficient it is. Are there any ways to make it efficient, and compact? ...
3
votes
0answers
21 views

Reddit Hangman Bot Python3

Back with another Reddit bot. This one provides games of Hangman to an arbitrary number of players simultaneously. Users interface with the bot by mentioning it for a new game. Once that game is ...
4
votes
1answer
40 views

Python implementation of Back Propagation Algorithm without bias

This program implements the back propagation algorithm of neural network with an example. Can we make it more efficient? ...
1
vote
1answer
32 views

Designing a hashset with LinkedLists as buckets

I am solving a problem on Leetcode that requires me to design a hash set. I intend to solve it using linked lists where each linked list would represent a bucket. I am intending to implement this: ...
4
votes
2answers
93 views

Tic Tac Toe, No OOP

I was looking at a code review of a Tic Tac Toe game in Python when I recalled a talk about not using classes, and I wanted to see if I could write a readable, working implementation of the game ...
8
votes
4answers
255 views

Python text-based Tic Tac Toe

I created a simple text-based Tic Tac Toe game in Python using OOP. Currently the computer moves are completely random - I plan to add some sort of algorithm later (no idea how to do that yet though) ...
4
votes
1answer
33 views

Huffman encoding as Unix style command line utility

After watching Tom Scott explain Huffman coding in this YouTube video, I wanted to implement it myself. I want to use this project to further my understanding of Python. Additionally this tool should ...
4
votes
2answers
44 views

Generates random entries in a particular format

My code down below generates entries for my program, but it's veryyy slow. I'm looking to generate about 10 million, is there any way to speed it up? FirstNames, LastNames, and Objects (.txt) are all ...
9
votes
5answers
1k views

Pythonic way to flatten lists or arbitrary depth using assignment expressions

I'm working through the classic "99 problems in prolog" collection. But trying to do them Pythonically. Flatten a list is problem 07. I am flattening a list of lists of arbitrary depth. I ...
2
votes
0answers
23 views

Make a class hierarchy data classes using a meta class

I am redesigning a library, which at the moment uses a lot of boilerplate code in a double hierarchy of classes / metaclasses, to attempt to make it much cleaner and reuse as much as possible what ...
5
votes
1answer
82 views
+50

A library for interacting with Pinnacle Sports Bets API

My code provides the following functionality for interacting with Pinnacle Bets API: retrieving betting history retrieving fixtures (future events) retrieving odds for the given leagues (competitions)...
3
votes
2answers
99 views

Printing the last two digits of an exponential calculation

I am trying to create a program where a user inputs two numbers - a base and an exponent, while exponent is a binary number. Then prints out the last two digits of the result. My code is working well, ...
3
votes
1answer
377 views

Function overloading in Python

Motivation As an exercise, I wanted to try implementing function overloading in Python 3, i.e. to implement a way of defining multiple functions with the same name and then calling the appropriate ...
7
votes
0answers
85 views

Calculating a unique count within a rolling time window

I have a Pandas DataFrame that contains a row per member per day, expressing member interaction with a website. Members interact only on some days, each member is identified with an ID. Here is a ...
6
votes
1answer
2k views

K-means clustering implemented in Python 3

Here is the classic K-means clustering algorithm implemented in Python 3. My main concern is time/memory efficiency and if there are version specific idioms that I could use to address issues of the ...
5
votes
5answers
158 views

Age calculator in python

I am new to python and to the StackExchange sites. I made an age calculator but i want to improve it till it's a reliable thing. Can i shorten the code? What can be Done more? Does it need any ...
2
votes
2answers
355 views

Ternary search tree implementation in python 3

I have implemented a Ternary search tree. It works well. But if you think something needs to be improved, say it. This code was tested in Python 3.7.4. ...
3
votes
1answer
81 views

Basic Trigonometry written in python3

Below is the code I wrote to perform basic Trigonometry without using the math module(except for 1 place) for the purpose of teaching myself basic trig and to improve my python. I have never taken a ...
7
votes
1answer
5k views

Square free number

Square free no: It is an integer which is divisible by no other perfect square than 1. For example, 10 is square-free but 18 is not, as 18 is divisible by 9 = 3^2. The smallest positive ...
4
votes
1answer
63 views

Reddit Dictionary Bot Python 3

This bot uses the PRAW package and jisho.org API. While running, it looks at recent comments for summons. A user either requests a random Chinese character/Kanji and associated definitions or ...
3
votes
1answer
56 views

Python script that consumes an API and generates an Excel spreadsheet

Wondering if I can get a review of the following script. I used to be a Python dev back when 2.7 was the norm and haven't really touched Python3, so interested to see where some new features might ...
1
vote
0answers
41 views

How To: Organizing Functions Into a Class [closed]

I have created code using only functions. The code I have created gets a users pizza order asking them for the size wanted, then their toppings wanted on that pizza. Returning the size cost then ...
1
vote
0answers
722 views

Better performance in solution for the Dole Out Cadbury challenge

Dole Out Cadbury Problem Description You are a teacher in reputed school. During Celebration Day you were assigned a task to distribute Cadbury such that maximum children get the chocolate. You have ...
3
votes
1answer
51 views

An emotion recognition test I designed using Pygame

for my dissertation (in psychology) I created an emotion recognition test that displays an image of a face displaying a certain emotion for a set time, then allows participants to press a button ...
3
votes
1answer
26 views

scrape AWS ECS and store summary in S3

This is my scraper for AWS ECS (Elastic Container Service). My primary use for this is to grep through the resulting file to see which cluster a given service is ...
2
votes
0answers
22 views

A task to store user's favorited projects in postgres using python

I am not happy with two functions calling get_user() since while testing I mock get_user and to test with get_user_returns_null case, it returns Null for both ...
7
votes
1answer
205 views

XOR Encryption, Decryption, and Cracking in Python

I have recently been working through a number of the Cryptopals Cryptography Challenges to try and improve my knowledge and understanding of both cryptography and Python. As five of the first six ...
2
votes
0answers
47 views

Simple Flask REST API to a MongoDB

I'm writing a simple REST API to my MongoDB using PyMongo (Python 3.7). Each collection I have in the DB has a route (e.g http://the.api.url/collection_name ), and every document under that collection ...
1
vote
1answer
35 views

LeetCode 124: Binary Tree Maximum Path Sum 2

I'm posting my code for a LeetCode problem. If you'd like to review, please do so. Thank you for your time! Problem Given a non-empty binary tree, find the maximum path sum. For this problem, a path ...
6
votes
2answers
777 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 ...
6
votes
1answer
32 views

A Level Statistics Calculator/Helper For A Casio Fx-CG50 Calculator's MicroPython

I have made a program for my calculator's micropython, that can solve various a level statistics questions for me. However due to the limitations of the ...
2
votes
4answers
644 views

Python palindrome checker function

For practice purposes I implemented a function that checks for palindromes: ...
2
votes
1answer
74 views

LeetCode 146: LRU Cache II

I'm posting my code for a LeetCode problem. If you'd like to review, please do so. Problem Design and implement a data structure for Least Recently Used (LRU) cache. It should support the following ...
3
votes
1answer
65 views

Sending a CSV file for a client list from a database

What can I improve about this code in order to be production-ready? I'm not worried about security but about errors that could occur. What exceptions should I catch? I feel overwhelmed about ...
4
votes
0answers
40 views

Memoizing a tree's parent pointers in Python

I have a simple binary tree that has no parent pointers. ...
2
votes
2answers
80 views

Multiplying numpy arrays

I have written a function to multiply two numpy arrays. ...
1
vote
0answers
21 views

Maybe with a structural pattern matching interface

With a reference implementation for PEP 622 now available in a Jupyter playground, I decided to copy over my favourite feature of Rust in full to Python. Note: this won't be released until Python 3.10 ...
2
votes
0answers
30 views

A Sieve of Eratosthenes

I have written this Sieve of Eratosthenes. This is a bit of software that will find all of the prime numbers between 2 and n, where n is a user-defined value. The code does seem quite bloated and any ...
7
votes
1answer
402 views

LinDB: A dictionary type database

As an exercise, I've decided to write a lightweight, dictionary type database. Below are some of the features I've implemented: Overwrite Inserting: I allow the user to determine if they want to ...
5
votes
2answers
51 views

Print a right-justified list of a list

I'm working through Chapter 6 in "Automate the Boring Stuff, 2nd Edition." Here is the chapter project at the end. Write a function named printTable() that takes a list of lists of strings ...
3
votes
1answer
40 views

Python's OOP for Calculating Growth of Money

I am making an OOP to calculate growth of money according to theory of interest. I have made 3 classes: Contribution which contain data of a deposit and its growth, ...
1
vote
1answer
31 views

Efficiency problem: Validating initial inputs then a joint validation test

The code works as intended but I believe it is very inefficient. The calculation of weights is simple, but I imagine this would be silly, for example, a 100 asset portfolio. The first problem is that ...
3
votes
1answer
43 views

7-Day Agenda in Python

This is a personal project of mine. I made a simple seven day agenda program in Python that stores tasks as a string, saves it into a .dat file, and returns that task when you input a day of the week....
2
votes
1answer
45 views

Python sudoku solver using backtrack algorithm

My first attempt at a sudoku solver using the backtrack algorithm. ...
3
votes
1answer
65 views

Check if number is divisible by three and two

Looks next nested if a little structure redundancy? Any better way for next nested if? ...

1
2 3 4 5
83