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
1
vote
0answers
9 views

Ubuntu GTK+ 3 desktop app, made with Python library PyGObject

I just created my first GTK+ 3 app with Python using PyGObject. It is very nice to be able to make GTK applications using Python, as I love that language. I'm not completely sure if the way I designed ...
-3
votes
0answers
21 views

HackerRank Apples(Python) [closed]

There are M Women sitting on the chair in a row. Every woman has a number assigned to it. Person A is distributing the apples to those women with following conditions. Each woman has at least one ...
6
votes
1answer
185 views

Optimizing Efficiency in a Stack

I'm solving a problem on HackerRank where I'm required to implement a simple stack. It's passing all the tests except for the last 4 where it fails due to surpassing the time constraint of 10s. ...
3
votes
0answers
51 views

Python - Single Responsibility and Method Naming - Best Practices

I need some opinions about method naming and single responsibility principle. First of all, let's talk about method naming. The class below was created to provide connection pool and whenever a pool ...
3
votes
1answer
25 views

Check if an inputted string is in the right format for a valid rgb color

It is a practice from the site edabit.com and you have to check if the input is valid. That is the original task: Given an RGB(A) CSS color, determine whether its format is valid or not. Create a ...
1
vote
0answers
29 views

A Tabbed calculator in python with tkinter

For learning purposes, I have written a small calculator app on Python, tkinter. I want to check if my design is on best practices for OOP, And seek advice on Nested functions For easy readability, I ...
4
votes
1answer
68 views

Highlighting partitions in distinct color

Given: G is an arbitrary graph partitions is a list of its edges divided into (in this case) 3 sets. Color generation: Its ...
1
vote
0answers
23 views

Simple food inventory manager in Python3

I've made a simple food inventory manager in Python3 Please tell me what can be improved GitHub ...
5
votes
2answers
106 views

Can it be shorter?: DNA Sequence Analyzer from CS50 written in Python

This is my first time requesting a code review. This is code I wrote in Python to create a DNA sequence analyzer. This is for the Harvard CS50 course. I was really hoping to get some constructive ...
0
votes
0answers
5 views

code into def function [migrated]

I'm brand new in Python and trying to solve one of my exercises: Below is a code describing growth of money, which started at $100, and which grows over time at a rate of 3% per year. The balance at ...
7
votes
2answers
548 views

This python code converts integers to strings and strings to ints without the inbuilt functions “int()” and “str()”

It is my solution from a challange from edabit.com named "Drunken Python". Thats the task: You need to create two functions to substitute str() and int(). A function called int_to_str() that ...
-2
votes
0answers
33 views

I’m a beginner building a terminal hangman app in which you can decide what the guessword for you opponent is [closed]

The following program directs you to a menu once you start it where you can either enter a new guessword or start the hangman game. By looking at it I think the code should work but once I press 2 to ...
3
votes
2answers
32 views

Merge Sort Implementation and Optimization

This is Merge Sort that i implemented, i feel i can make it better esp the combination function. So i split the code into functions because i don't like seeing a bunch of spaghetti code in a single ...
4
votes
0answers
24 views

Text only turn based battle simulator

This is my first proper-ish project I've made. This was my first time using classes as well. I know that I made really stupid decisions, this is extremely far from being anywhere close to optimal, and ...
5
votes
1answer
33 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
56 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
89 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
58 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 ...
7
votes
2answers
120 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 ...
4
votes
0answers
34 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 ...
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
97 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 ...
4
votes
1answer
34 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
1answer
41 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? ...
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 ...
8
votes
4answers
260 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) ...
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 ...
4
votes
2answers
45 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 ...
7
votes
1answer
114 views

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
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 ...
4
votes
1answer
64 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 ...
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 ...
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 ...
3
votes
1answer
27 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 ...
1
vote
1answer
36 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
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
0answers
50 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 ...
2
votes
4answers
644 views

Python palindrome checker function

For practice purposes I implemented a function that checks for palindromes: ...
4
votes
0answers
41 views

Memoizing a tree's parent pointers in Python

I have a simple binary tree that has no parent pointers. ...
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 ...
2
votes
0answers
22 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
32 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 ...
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 ...
7
votes
1answer
404 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 ...
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, ...
5
votes
2answers
52 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
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
49 views

Python sudoku solver using backtrack algorithm

My first attempt at a sudoku solver using the backtrack algorithm. ...
1
vote
0answers
755 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 ...

1
2 3 4 5
84