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
2
votes
2answers
80 views

Text based fighting simulator in Python

This is my first large project, a text based fighting simulator. It is very clunky, do you have any ideas on how to make the code better? and how to make the code not get printed at once ...
4
votes
1answer
31 views

Find Todos by Line Number (or any other reference) in Python

I write a lot of TODO's but I never keep track of where they are. This program will search through files (and recursively through folders if needed) and find any TODO comments and their line number. ...
3
votes
1answer
18 views

Kruskals MST Algorithm

This code computes the Minimum Spanning Tree of a given graph using Kruskals Algorithm. It works successfully and I have provided test cases within the code. I would like feedback on code efficiency ...
-2
votes
0answers
18 views

How to vectorize the following set of code in python? [on hold]

I am using NearestNeighbors for a text-based recommendation system. The purpose of the model is to return some set of codes For example: ...
5
votes
4answers
66 views

Project Euler #14: Longest Collatz Sequence starting point

Problem statement: The following iterative sequence is defined for the set of positive integers: n → n/2 (n is even) n → 3n + 1 (n is odd) Using the rule above and starting with 13, we ...
14
votes
6answers
3k views

Project Euler, problem # 9, Pythagorean triplet

Project Euler #9, Pythagorean triplet is A Pythagorean triplet is a set of three natural numbers \$a < b < c\$ for which \$a^2 + b^2 = c^2\$. For example, \$3^2 + 4^2 = 9 + 16 = 25 = 5^...
2
votes
1answer
31 views

Print file out 1 character at a time in the terminal - Python

This program opens a file and prints the text out to the terminal 1 character at a time and at a predetermined speed using time.sleep() Simple and maybe, if you ...
6
votes
1answer
104 views

Calculate working hours using Python

This is a simple boilerplate / template for a bigger program (I hope), either linked to a DB or including a GUI frontend using PYQT or TKinter. This is just a little tool I wrote to keep track of my ...
3
votes
1answer
20 views

SSH autokiller for connections from other systems

I was messing around with ssh and decided to write a python program that scans for any connections that aren't from the system, then terminates them. It works well ...
2
votes
1answer
19 views

Find cycles in Graph using Union Find Algorithm on Adjacency List

My code detects if a cycle is present in a graph using Union find algorithm with Weighted tree analysis and path compression. It works and I have included test cases. ...
8
votes
1answer
538 views

speculum - A simple, straightforward Arch Linux mirror list optimizer

After having had a look at reflector's code base I decided to write a new, more lightweight mirror list optimizer from scratch: speculum. The script queries the Arch Linux mirror list JSON endpoint ...
3
votes
1answer
27 views

Parse table names and attributes from SQL queries in a dataframe

I want to get table names and column names from queries in a dataframe. The dataframe is like this: ...
3
votes
1answer
20 views

Converting string of hex values to numpy array of specific shape

I am working on a project that needs to take a .bdf font file and turn it into a Numpy array. I am using the code below to turn the bitmap for the font into a numpy array. It currently works, I just ...
2
votes
1answer
27 views

Project Euler #17: Number Letter Counts

If the numbers 1 to 5 are written out in words: one, two, three, four, five, then there are 3 + 3 + 5 + 4 + 4 = 19 letters used in total. If all the numbers from 1 to 1000 (one thousand) ...
2
votes
2answers
50 views

Rename and move images to a destination directory based on a text file followup

This is my third (and hopefully final) time re-writing this program. It was recommended I use Pathlib and it simplified my code, it's easier to read and understand ...
-2
votes
0answers
23 views

Python: Declaring a class within a function to encapsulate instantiation [on hold]

I was wondering how acceptable or bad it is to declare a class within a function in python, that also takes care of a correct instantiation of this class. ...
2
votes
1answer
60 views

Python function to count syllables in a word

I wrote this function to count the syllables in a word using Python to complete an exercise. The exercise's text is: Return the number of syllables in the given word, according to this rule: ...
2
votes
1answer
49 views

Select optimal piecewise regression fit

I'm making a program which fits a piecewise linear regression with up to 4-5 breakpoints in the data, and then deciding how many breakpoints is best to prevent over and underfitting. However, my code ...
2
votes
1answer
36 views

Rename and move images to a destination directory based on a text file

As a followup to this question, I removed the Repository class and do the copy in the Folder class. Suppose I have the ...
6
votes
0answers
6k views

Example of multithreading in Python3 / PyQt5 using QThread

I wanted to make a simple example of multithreading with QThread in PyQt5 / Python3. The script generates a set of QLineEdits and buttons to start and stop a set of ...
3
votes
2answers
85 views

Calculate mean and standard error of a generator in Python

The goal of the following code is to calculate the mean and the standard error of vectors of randomly-generated numbers. I am looking for feedback both on the correctness of the calculation, and on ...
2
votes
1answer
22 views

Configuration parsing and verification utility for bioinformatics tools

I've been working on my first Python library which provides different utilities for a set of bioinformatics tools. I am looking for feedback on this module I made for parsing configurations needed for ...
2
votes
1answer
27 views

Find articulation points/ cut vertices in graph

I would like to get some feedback on my completed code that finds and displays the articulation vertices in an undirected graph. I included a test case within the code, it should (and does) print <...
9
votes
3answers
441 views

School House Points (Python + SQLite)

I am creating a database to store house points for our school running events. I would like to be able to tally all the points for the houses and it is working fine, however, I think it may be a bit ...
16
votes
2answers
390 views

MNIST Deep Neural Network in TensorFlow

I have been working on this code for a while and it gave me a lot of headaches before I got it to work. It basically tries to use the MNIST dataset to classify handwritten digits. I am not using the ...
0
votes
1answer
57 views

Python decorator to support static properties

Classes in Python do not have native support for static properties. A meta-class can rather easily add this support as shown below. Are there any problems programmers might experience if they use this ...
6
votes
2answers
8k views

List all possible permutations from a python dictionary of lists

The following code takes a dictionary of lists (indexed by keyword) and converts it into a list of list of dictionaries that contains all possible permutations of those lists. However, my solution ...
-1
votes
0answers
23 views

Counting co-occurence of a file encoded in UTF-8 [on hold]

I need to write a script that can count co-occurences in a UTF-8 encoded file. The length of the co-ocurence is between 2 to ...
6
votes
3answers
285 views

Bishop game - python

A bishop can capture any other bishop if it lies along the same diagonal line, so long as no other bishop is in its path. Given a list of coordinates of the bishops locations, and a board size, ...
5
votes
1answer
60 views

Text-based fighting game in Python 3.0

I have began to practice Python after a couple of years and for my first Project, i decided to make a fighting/rpg-like game with different characters. So far, I am only familiar with loops and ...
-1
votes
0answers
16 views

How do I wrap up all my dataframe filter in a def function [duplicate]

I have written codes that will filter streaming data once they are imported and unzipped. The code works, but looks quite messy and unprofessional. Someone will inherit them in the future. I want to ...
0
votes
1answer
48 views

Port the data from a TEXT file to Postgres table using Python

I have written the below code to read a huge text file of size 20+ MB and insert the values to a PostgreSQL table. The code is working fine, but I'm facing below issues in the code. 1) The code is ...
0
votes
2answers
56 views

A regex pattern that matches all forms of integers and decimal numbers in Python

The question is pretty self-explanatory. I wrote a regex pattern which should (in theory) match all possible integers and decimal numbers. The pattern is as follows: ...
5
votes
1answer
240 views

Python function to generate Spanish conjugations

I tried to make a Python function to generate present tense Spanish conjugations. ...
-4
votes
0answers
21 views

setting and running basic python code [closed]

my developer did this scrapper https://github.com/pythexcel/cryptoapp_backend_frontend/tree/master/backend/app which runs at an interval and he is not available now and I am stuck setting it up in ...
-2
votes
1answer
42 views

Python Count on if Loops [closed]

I would like to make this super beginner factoring calculator in Python3 without the use of lists or other data structures. How do I get the count to successfully number the iterations of the print ...
1
vote
1answer
23 views

Command Design Pattern Implementation: Moving Robot with Undo-movement (Python)

I'm learning about the command design pattern and would like you to critique it for division of responsibility, especially with regards to how the robot "undoes" commands it previously executed and ...
9
votes
3answers
4k views

Parsing the lsblk output

I am a Python beginner learning Python 3. I have written two small functions that parse the lsblk output and return Linux physical and logical disks. Here is the first function: ...
6
votes
2answers
841 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 ...
2
votes
0answers
33 views

Python Script to download images and videos from a user's profile on Instagram

The script downloads images and videos from a user's profile page on Instagram. It works fine, but I'd like to know if there are ways to improve it. All ideas and suggestions are welcome. ...
1
vote
0answers
17 views

test oriented design; Python test script to test a company's API, print test results, log exceptions

I'd like some constructive feedback on the code that I have written to test the API for smartsh33t.com I wrote it in Python. I wrote the program to take .json files and read them into the testrunner....
3
votes
1answer
47 views

the fox is black - a simple image scraper

I wrote a simple image scraper for the Desktop Wallpaper project by The Fox is Black. The site is a fantastic (yet, apparently dead) blog full of fabulous images. However, there's no way to download ...
1
vote
0answers
22 views

Parsing and plotting with numpy (or pandas)

I am trying to improve the following code to make it more broadly applicable and quick to use. ...
3
votes
2answers
91 views

Jump Game - Leetcode

Below is my solution for the LeetCode Jump Game Given an array of non-negative integers, you are initially positioned at the first index of the array. Each element in the array represents ...
4
votes
0answers
39 views

Scraping a hiring website using python's requests and BeautifulSoup

I'm designing a scraping application using python, requests and BeautifulSoup4. I decided to divide the logic into two classes: Spider : gets the base url ...
8
votes
1answer
76 views

Geektrust: Solve War problem in a OO way in Python

I solved this programming challenge whose objective is to come up with an OO solution to the problem. The problem statement is quite verbose and the tl;dr version would be: Given an enemy army(...
4
votes
2answers
45 views

String validation based on multiple criteria

I had me a code challenge and I was thinking: is there a way to make this more efficient and short? The challenge requires me to scan a string and ... In the first line, print ...
6
votes
2answers
166 views

pydoro - terminal tomato timer

I've recently created a tomato timer for terminal. It's hosted in github. My concerns are how Pythonic my code is? Is the way I'm handling state transitions good? Which areas of the text user ...
1
vote
1answer
46 views

Maximum Width binary tree

Here is my code for the LeetCode problem For a given binary tree, find the maximum width of the binary tree. The width of one level is defined as the length between the end-nodes even if there are <...
1
vote
2answers
87 views

Descriptive quantity (one, two, many) from number

I just write a simple method which returns a string based on the number in accepts as a parameter. I used if/elif/esle here but I think for this simple scenario I ...