Questions tagged [python]

Python is an interpreted, general-purpose high-level programming language whose design philosophy emphasizes code readability. Use the python tag for all Python related questions. If you believe your question may be even more specific, you can include a version specific tag such as python-3.x.

Filter by
Sorted by
Tagged with
2 votes
0 answers
13 views

Generate readable English words from given letters

I was redirected from StackOverflow to your community in hope to get some help and improve my script. The script receives letters as input and generates possible words, then extracts readable words ...
user avatar
  • 21
1 vote
1 answer
55 views

Python script to POST requests to a networking device

Request to review my code please and see if I am following the best practices. This is sending a POST operation via a Python script using the requests library to a networking cloud orchestration ...
user avatar
-1 votes
0 answers
15 views

Show values of lollipop-chart [closed]

I'm new to visualizing data and I'm trying to make a lollipop chart just like this one: data visualization - What is the name of this plot that has rows with two connected dots? - Cross Validated But ...
user avatar
2 votes
1 answer
35 views

Python CLI math game

I'm a self-taught programmer starting out with Python and my latest project is this game: It runs in the console, displays an equation, takes the user's answer, and increases your score if it's ...
user avatar
  • 23
1 vote
1 answer
38 views

Solution to arithmetic arranger from freecodecamp

I tried my hand at the freecodecamp python algorithm and I came up with a solution for the first question but need help refactoring it. Here is the arithmetic arranger question click here to access ...
user avatar
  • 13
5 votes
1 answer
194 views

Formatting a table using unicode symbols in python

The goal of the project is to take in input for a data, perhaps in the future as a csv, then print it out using UNICODE box-drawing characters. The main function ...
user avatar
  • 151
0 votes
0 answers
16 views

Table driven tests in Python using pytest

I'd like to have a standard test template to copy from when solving coding puzzles. Typically, I would need to write multiple test functions to check if my function is working as expected. However, it'...
user avatar
2 votes
2 answers
39 views

Sampling from k circles with different radii

Description: I would like to sample n_points points from k circles whose radii and centers are given as lists. Note: This is my ...
user avatar
5 votes
0 answers
48 views

A Python 3 script that generates art using matplotlib

I am always super interested in both science and art, science and art are two different ways to describe the objective reality, they are two sides of the same coin, in many areas they overlap, and ...
user avatar
-1 votes
0 answers
21 views

Python to display syllables in a word not counting the number of syllables [closed]

Would like to get the syllables in a given word in python. Not counting the number of syllables ...
user avatar
  • 1
2 votes
0 answers
20 views

Brand generator script using multiprocessing

I have two indices in Elasticsearch which are brands, and categories, and I have a very ...
user avatar
  • 183
0 votes
0 answers
13 views

Is there a recursive implementation of level order tree building (for leetcode tree examples)

Leetcode work with a "kind"** of level order tree representation. I wrote a code to build such a Tree (inspired by a post) from an array, do you think it would be possible to write it in a ...
user avatar
  • 273
2 votes
0 answers
21 views

Coin partitions

I am looking to obtain the partitions of coins that sum to a target amount So I tried search online, but every single website loves to use this problem to show the benefits of dynamic programming. ...
user avatar
2 votes
0 answers
27 views

simple OOP Blackjack

It has been a long time since I have gotten into OOP with python. I made this short little program. Are there any ways that I can make it more clear or concise (pythonic if you may)? ...
user avatar
1 vote
1 answer
70 views

Printing a JSON/HTTP response from a Cisco endpoint

Please check over my Python code for a HTTP GET operation using the requests library, and provide any potential pointers for improvement. ...
user avatar
1 vote
0 answers
28 views

How to parse existing functions to a Python class definition?

I have an implementation of a Quantum CNN on the MNIST dataset but right now, the code is just a bunch of standalone functions that call one another: ...
user avatar
  • 169
2 votes
0 answers
21 views

Minesweeper program using Tkinter

I have complete my minesweeper game using Tkinter and would like to know ways to improve. I also have a question for extra features: does anybody know a way to have a opening start, like google ...
user avatar
  • 137
2 votes
0 answers
16 views

A self-contained example showing how Gitlab CI's "parallel" works

Here's the code: ...
user avatar
  • 395
-3 votes
0 answers
24 views

How do you make a builder move a certain amount of times (specified in a list)? (Minecraft Education Edition) [closed]

This code is supposed to make square shaped structures with dimensions that relate to the Fibonacci sequence. eg: 0, 1, 1, 2, 3, 5, 8 ... and I made it into a list because I thought that was the ...
user avatar
1 vote
0 answers
34 views

Timer with input, sound and flashing ( Just timer :) )

I know that this program is not very outstanding, but I'm learning "Python" and decided to publish this code in order to get some advice and parting words and overall evaluation of the ...
user avatar
  • 41
2 votes
1 answer
60 views

Text splitter using Regular Expressions in Python

I have been provided a text splitter class that will take a text input and use re.sub to make replacements when matches are found and also splits sentences up and stores them in a list. I had an idea ...
user avatar
7 votes
1 answer
608 views

Wordle guesser, breaking out of loop by raising exception

After many years away from writing in Python, I am getting back into it. Specifically, I am trying to teach myself dataclasses. As an exercise I wrote a Wordle-solving program. I downloaded the ...
user avatar
1 vote
2 answers
56 views

Validator for 0/1 entries in a matrix

I build a function(A kind of puzzle) that counts from a matrix the number of valid count (Explanation below). The matrix is ​​made up of 0,1. Input- a matrix- list of lists row number column number ...
user avatar
  • 13
-1 votes
0 answers
8 views

Append a value for non-existing key in the hash-map [closed]

Ideally I'd like to call single append and by that, have next steps done: Create new key s if s doesn't exist in ...
user avatar
4 votes
2 answers
731 views

Battle terminal-based game

I'm new to learning OOP in python and played around with it, making this quick battle terminal based game-ish, but I'm wondering how I can optimize this to maybe less lines of code and just overall ...
user avatar
3 votes
1 answer
378 views

Can two knights pieces attack one another from current positions?

I am working on my Python skills and would like some feedback on this problem I have tried to solve. I would like to return a boolean if two knights at their current position can attack each other ...
user avatar
6 votes
1 answer
564 views

Abstract class with different derived signatures in Python

I don't feel too comfortable with the use of object oriented programming and the related advanced topics. That's why I went through this exercise of using Python's abstract class to implement an ...
user avatar
  • 225
2 votes
2 answers
118 views

Find all pairs of natural numbers whose sum is 12

I have been given the following task to complete. I am not sure if my solution is the most efficient. Are you able to take a look and suggest any changes? task: An application that finds all pairs of ...
user avatar
  • 21
-3 votes
0 answers
45 views

Python: How to design a game of monopoly [closed]

So I am trying to come up with a new game of monopoly. I am not sure how to start this. Any ideas? Import Tensorflow Import math Import sys
user avatar
4 votes
1 answer
422 views

Table Printer Project - Automate the Boring Stuff Chapter 6

The project outline: Write a function named printTable() that takes a list of lists of strings and displays it in a well-organized table with each column right-justified. Assume that all the inner ...
user avatar
  • 97
3 votes
1 answer
138 views

Automate the Boring Stuff CH 10 - filling in the gaps

This exercise comes from Automate the Boring Stuff CH 10 - second edition. The exercise is called "filling in the gaps," and the instructions are as follows: Write a program that finds all ...
user avatar
  • 117
0 votes
0 answers
34 views

MTD-F Implementation in Othello

I currently am using the MTD-f algorithm, along with a hybrid negamax/negascout with memory function, in an Othello implementation: ...
user avatar
  • 101
4 votes
2 answers
240 views

Porting PHP's array_push to Python

I am new to Python but not new to PHP. I've started porting PHP APIs to Python hoping to learn the Python language along the way, currently trying to grasp List, Dict, Set, Tuple. I tried writing PHP'...
user avatar
3 votes
1 answer
51 views

Call-flow graph from Python abstract syntax tree

Below is my code for building a call-flow graph from a Python abstract syntax tree. I'm not satisfied with it because the algorithm is very complicated. Perhaps much more complicated than it needs to ...
user avatar
9 votes
3 answers
1k views

A Simple Tic-Tac-Toe Game

I wrote a simple tic-tac-toe game in Python. I'm pretty much a novice, but I do have some experience with coding other things in Python. I just wanted to see if I was capable of writing a simple tic-...
user avatar
  • 143
2 votes
2 answers
90 views

Create new columns based on existing columns

The code: ...
user avatar
1 vote
1 answer
54 views

Register/Login for Rock/Paper/Scissors

Recently I have been learning Python after years of putting it off, and I am having a really fun time with it. However after I spent a few hours making something that I thought was pretty cool, I ...
user avatar
  • 11
0 votes
1 answer
27 views

What is the best way to retrieve all pages of a REST API route with Python aiohttp when the number of pages is unknown?

I've encountered a paginated API route where there is no way to know the number of available pages. The only way to retrieve every pages is to check on each page if a next page exists. To do so, the ...
user avatar
3 votes
1 answer
31 views

List to Dictionary Function Project - Automate the Boring Stuff Chapter 5

This is the List to Dictionary Function for Fantasy Game Inventory project in Chapter 5. The project is as follows: Write a function named addToInventory(inventory, addedItems), where the inventory ...
user avatar
  • 97
1 vote
0 answers
48 views

To do application using python's tkinter and sqlite3

I program python as a hobby and wanted to learn how to apply databases in a functional program, while at the same time make something useful. so I made a to do application with some basic ...
user avatar
3 votes
2 answers
64 views

Alphabet Rangoli

I have written alphabet rangoli code in python and would like to get it reviewed. The goal is to print concentric diamond shapes made of letters, with "a" at the center, "b" ...
user avatar
1 vote
1 answer
31 views

Trouble with rendering speed of the animation of a simulation?

The following code is a conversion from some old java I wrote to python. It shows the beginnings of a simulation of an ant colony. I am finding the animation speed very slow - and I'm wondering if I ...
user avatar
  • 155
3 votes
2 answers
59 views

Pascal's triangle solution in Python code

I have solved the pascal's triangle problem. I am not good at writing efficient programs, hence any suggestions/ comments shall be welcomed. ...
user avatar
1 vote
2 answers
63 views

Generating random integers in one of three ranges

I have a function returns a random integer number. This function only accepts these three numbers 1,2 and 3(there's another function in my code which is make sure of this otherwise that function will ...
user avatar
  • 13
0 votes
0 answers
39 views

Web-scraping favorites from a website and saving them to an Excel sheet

...
user avatar
1 vote
0 answers
30 views

Web scraper for pokemon prices using Selenium

I made this scraper to pull the prices of pokemon cards off tcgcollector, using a csv file from the same site. Because for some reason they don't export price. I'm looking for any kind of noobie ...
user avatar
3 votes
2 answers
37 views

Single-file stdlib-only python backup utility

I have written this backup utility to keep incremental backups by copying new and modified files, and hard linking unchanged or simply moved files. In an attempt to speed up the comparisons, I save a ...
user avatar
  • 233
1 vote
1 answer
63 views

Decision Tree for classification tasks in Python

I've decided to implement the ID3 Decision Tree algorithm in Python based on what I've learned from George F. Luger's textbook on AI (and other secondary readings). As far as I know, the code is ...
user avatar
4 votes
1 answer
69 views

Weird things to do to an image

Here is a program I wrote to take an image and do weird things to it. Is there any more weird things I can add? Right now I have: Chop the image Flip the image (up/down and left/right) Rotate the ...
user avatar
3 votes
1 answer
45 views

Newspaper Bill Calculator CLI with Python (3 of 3, Database)

Code is posted after explanation. Due to the size of the project, this is being posted in three separate posts. This also ensures each post is more focused. Post 1 of 3, Core: Newspaper Bill ...
user avatar

1
2 3 4 5
292