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
2answers
39 views

Script that helps people make better choices

This is a "Help me make a choice" script where the user can input two options and then, based on the (3) reasons why they are good options, and the reasons weight the script will tell you which option ...
0
votes
0answers
16 views

Trying to write better code of numerical euler method beginner

Total new in here! I made an Euler method code, in which you can plot different parameters, and see how this affects the method. It works, but I have the sensation that it's horribly coded, and I ...
6
votes
2answers
62 views

Duplicate File Finder in python

I just started learning python yesterday, I have prior experience of C++. So I think I am able to get most of it pretty fast. I wrote a duplicate file finder for testing and practicing. Can you guys ...
-1
votes
1answer
55 views

Champions League Simulation [on hold]

Here is my first attempt at creating a full Champions League Simulation, including drawing the groups and subsequent games and playing all matches. The code is very, very long and I am sure there must ...
-2
votes
0answers
17 views

Print user inputted information about a song [on hold]

This program take user inputted information about a song and adds it to a dictionary before printing the raw dictionary. This program works well the first time but it breaks down the second time and ...
3
votes
1answer
44 views

A persistent file system operations queue using sqlite and JSON text fields

I want to implement a persistent queue for file system operations (copy, delete, move) that needs to be process and thread safe. The module will be used by a daemon (called ...
4
votes
1answer
44 views

Interactive folder files organizer (Alpha-numeric and type) for macOS / Linux in Python

A simple interactive Python script for organizing messy folders on the computer, supports macOS and linux but not windows. The mini-program has the following features: Creation of Alpha-numeric (A-Z /...
2
votes
2answers
51 views

LeetCode #1120 Maximum Average Subtree (Python)

This code snippet shows 2 common patterns I see a lot in Python that I don't really like: Arbitrarily-named, narrowly-scoped recursive function Inappropriate data type (in this case, an array ...
-1
votes
0answers
45 views

Solving Kruskal algorithm using Python [on hold]

This is the problem from uva online judge. Visit https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=975 In an episode of the Dick Van Dyke ...
2
votes
1answer
58 views

Remapping property IDs when inserting CSV data to a database table

My code is functioning the way I'm expecting, with the if. However, it is not pythonic to me, and that bugs me. The multiple if in the code below are supposed to ...
5
votes
2answers
84 views

Project Euler # 62 Cubic permutations in Python

The cube, 41063625 (\$345^3\$), can be permuted to produce two other cubes: 56623104 (\$384^3\$) and 66430125 (\$405^3\$). In fact, 41063625 is the smallest cube which has exactly three permutations ...
-1
votes
1answer
53 views

How to find the common factors of 2 numbers [on hold]

Print the number of common factors of a and b. input > 10, 15 Output > 2 The common factors of 10, 15 are 1 and 5 My code ...
2
votes
1answer
44 views

Exporting data from PostgreSQL as CSV to S3 bucket

I have a general question regarding DRY. As you can see there are several parts such as io.StringIO(), csv.writer, ...
4
votes
1answer
39 views

Command line utility to convert image formats of photos

Below is some code for a basic command line utility to convert image formats of photos. I'm wondering how any part of it might be written with better style, i.e. how it could be neater, clearer and ...
2
votes
1answer
52 views

Functional n-queens

Following the book "Structure and interpretation of computer programs" I have tried to implement a functional solution to the problem of N-queens (implemented by the function ...
-4
votes
0answers
52 views

Converting a set into a string [closed]

The input is a set of alphabets. The output is a string of 32 in length. For any letter in the set if it is preceded by a '¬' we replace the n-th character in our output string with '0', such that n ...
1
vote
0answers
33 views

Tab 2 spaces convertor (for markdown)

This below program simply converts given glob files' tab to spaces. There is a special case to ignore content inside triple back ticks. Example usage is ...
2
votes
1answer
29 views

Comparing web-scraped data from several sports betting APIs

I have written a python script that requests information from several Sports Betting API's, processes and standardises the results into a dictionary, Matches items between dictionaries and then ...
9
votes
4answers
2k views

Sum Square Difference, which way is more Pythonic?

I'm using python 3 and I am creating an algorithm to find the sum square difference for the first 100 (or 1 to x) natural numbers. This happens to be project euler problem 6 if anyone is wondering. I'...
0
votes
1answer
44 views

String manipulation in Python

I have this very ugly piece of code which runs ethtool and then parses the output (Lilex is just a static class encapsulating subprocess and is not relevant to the ...
0
votes
2answers
124 views

Income tax calculator [closed]

I've just started coding and have written a program to calculate your tax to be paid. Is there anywhere where I can improve this? ...
-1
votes
1answer
40 views

Python 3 code for a binary search tree [closed]

I am working on a python3.6.5 question about BST: Binary search tree (BST) is a binary tree where the value of each node is larger or equal to the values in all the nodes in that node's left ...
-4
votes
1answer
57 views

Project Euler #5 Optimized

I have seen multiple questions on this problem but none seem to answer my specific question. To start, the basic question is asking to find the smallest number that is divisible by numbers 1 to 20. ...
5
votes
2answers
87 views

Bracket balance checker in Python

Implement a feature for a text editor to find errors in the usage of brackets in the code. Input: sorted(list(zip(a, b)) Output: False Input: ([{}, {}]) Output: True Here's my implementation in ...
14
votes
5answers
3k views

Markov-chain sentence generator in Python

I wrote a Markov-chain based sentence generator as my first non-trivial Python program. I mainly used C before, so I probably have ignored a lot of Python conventions and features, so any advice would ...
2
votes
0answers
32 views

JSON to CSV in python using json.loads and json_normalize

I am trying to convert a JSON file to CSV format using Python. I am using JSON.loads() function and then using json_normalize() to flatten the objects. The code is working fine for few input rows. I ...
4
votes
3answers
351 views

Project Euler # 15 Lattice paths in Python

Starting in the top left corner of a 2×2 grid, and only being able to move to the right and down, there are exactly 6 routes to the bottom right corner. How many such routes are there through a 20×20 ...
2
votes
1answer
50 views

Project Euler # 11 largest product in a grid in Python

In the 20×20 grid below, four numbers along a diagonal line have been marked in red. The product of these numbers is 26 × 63 × 78 × 14 = 1788696. What is the greatest product of four adjacent numbers ...
2
votes
0answers
22 views

Pattern for classes that provide logger objects

I need to log the activities of instances of a class. Code that uses the class should be able to disable the default class logger (which, by default, is initialized with a ...
2
votes
0answers
27 views

A Simple Connect 4 game in Python

I have made a simple command line version of connect 4. It is my first time using classes and importing one part of my project into another so any feedback on how I've done and any way it could be ...
3
votes
1answer
42 views

Continuous Range class

I was surprised to find that there doesn't seem to be a good "continuous range from start to end" data structure in python. I ...
4
votes
2answers
61 views

Least Recently Used Cache Daily Coding Practice

I have the following challenge problem for which I was able to get a solution working, but not in \$O(1)\$ time as the problem asks for. Could someone point me in the right direction to optimize this?...
7
votes
1answer
49 views

Arithmetic/Geometric series calculator

I've written a small program that calculates Arithmetic and Geometric Partial Sums. I'd like feedback on anything possible, since I intend on writing a cheatsheet that encapsulates all PreCalculus ...
6
votes
4answers
104 views

LeetCode ZigZag helper function code

The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility) ...
0
votes
1answer
36 views

OLED FeatherWing instruction page

I have a Feather M0 basic paired with a OLED FeatherWing. I am making an instructions page but the code is quite repetitive. How can I make my code shorter? ...
3
votes
2answers
881 views

Can this code, to convert string to integer, be made more compact?

Problem: String to integer(leetcode) Implement atoi which converts a string to an integer. The function first discards as many whitespace characters as ...
9
votes
2answers
111 views

Synthetic division calculator

I've written a python program do perform synthetic division on a polynomial. There are a few constraints (listed in the module docstring of the program) on the polynomial, mainly because I haven't had ...
1
vote
0answers
46 views

Find the median of two sorted arrays [closed]

There are two sorted arrays nums1 and nums2 of size m and n respectively. Find the median of the two sorted arrays. The overall ...
4
votes
0answers
18 views

Inherit docstrings from specified parent

I was recently working on some python where I was working with multiple inheritance and mixins and stuff like that, and I wanted to inherit docstrings for specific functions, from specific parents (...
2
votes
1answer
34 views

HTTP scraper efficiency with multiprocessing

I built this scraper for work that will take a csv list of firewalls from our network management system and scan a given list of HTTPS ports to see if the firewalls are accepting web requests on the ...
19
votes
6answers
4k views

Premier League simulation

I've created a simulator for the Premier League, which takes in all of the 20 teams and plays them against each other, recording the results and outputting a table at the end. The skill levels are ...
8
votes
1answer
114 views

Measure time and space requirements of different Python containers

I was actually kind of bored and since I'm studying some Python data structures I decided to make some size(MB) and time(secs) comparisons between different containers when conducting the operation of ...
2
votes
1answer
33 views

compare different pandas dataframes to find matching rows

I have two dataframes: One contains of name and year. **name** **year** ram 1873 rob 1900 Second contains names and texts. ...
3
votes
1answer
41 views

Finding possible moves in a chess game [closed]

Recently I've been developing a chess game in Python - using pygame - just as a project for myself. I have a class for each piece type, and in each class, I have a method called ...
1
vote
3answers
43 views

Python startswith and then look a word in a conditional block

I have below working code which works fine, but just looking way around if there is an another elegant way of doing this, because here i'm using else condition to print the last line or dataBlock to ...
2
votes
1answer
81 views

Simplified three-body simulation

The code below simulates a given Newtonian 3 body system. Each row per slice is supposed to represent a Cartesian component for the initial trajectory vector and for the distance vectors to the other ...
1
vote
1answer
51 views

Bubble Sort: Time and Space Complexities

Algorithm Bubble sort, also known as sinking sort, is a sorting algorithm that repeatedly steps through a list, compares adjacent pairs and swaps them if they are not in the right order. The pass ...
3
votes
2answers
91 views

Tkinter program to teach Arabic

I am writing a lesson-based program to help teach friends and family the basics of Arabic. The program consists of different sections (letters, numbers, personnel pronouns, etc.) and each of those ...
2
votes
1answer
52 views

Python and FileIO

I've written a bunch of functions that deal with handling files on a Linux system. I'm looking for critique on the whole class, in particular: Exception handling Efficiency Style I'd also like to ...
5
votes
1answer
65 views

All-Python implementation of n-dimensional convolution

To better understand how discrete finite convolution works (read educational purposes) I wrote an all-python implementation of the convolution function. The idea was for it to give the same output as <...