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
0
votes
0answers
13 views

OOP python blackjack game

This is an OOP version of Lastest version of my Blackjack game. Also, it now uses PostgreSQL as database. ...
2
votes
2answers
22 views

Checking the strength of a password using regexes

I'm a beginner in Python and I made a password checker. I'm following these rules: I have to use regex password must be at least 8 characters must have at least one lower case character must have at ...
6
votes
4answers
136 views

Project Euler # 25 The 1000 digit Fibonacci index

The Fibonacci sequence is defined by the recurrence relation: Fn = Fn−1 + Fn−2, where F1 = 1 and F2 = 1. Hence the first 12 terms will be: F1 = 1 F2 = 1 F3 = 2 F4 = 3 F5 = 5 ...
2
votes
2answers
19 views

Project Euler # 24 Lexicographic permutations in Python

A permutation is an ordered arrangement of objects. For example, 3124 is one possible permutation of the digits 1, 2, 3 and 4. If all of the permutations are listed numerically or alphabetically, we ...
2
votes
1answer
34 views

Sim game and it's my first program

This is my first program and I had fun making it and learning new things! Please let me know what I can do to improve this code! The objective of the game is to survive as long as possible. You have ...
4
votes
1answer
26 views

Project Euler # 22 names scores in Python

Using names.txt (right click and 'Save Link/Target As...'), a 46K text file containing over five-thousand first names, begin by sorting it into alphabetical order. ...
-3
votes
0answers
14 views

Check list of password requirements using Regular Expressions [on hold]

Python program to check the validity of password input by users using re module. Following are the criteria for checking the password: At least 1 letter between [a-z] At least 1 number between [0-9] ...
3
votes
2answers
57 views

Importing data into PostgreSQL from remote text file using ftplib class

I need to read a remote file using FTP and process it and insert the processed data to a PostgreSQL database in another server. The below code is working fine, but i want some advice to modify few ...
0
votes
1answer
19 views

Project Euler # 21 amicable numbers Python

Let d(n) be defined as the sum of proper divisors of n (numbers less than n which divide evenly into n). If d(a) = b and d(b) = a, where a ≠ b, then a and b are an amicable pair and each of a and b ...
-3
votes
0answers
25 views

How to create an autocomplete method that search an existing trie in python [on hold]

I am new to python, I found different codes that implements trie, like this one example below, but I have hard time understanding how to search the trie.. ...
3
votes
1answer
29 views

Project Euler # 20 factorial digit sum in Python

n! means n × (n − 1) × ... × 3 × 2 × 1 For example, 10! = 10 × 9 × ... × 3 × 2 × 1 = 3628800, and the sum of the digits in the number 10! is 3 + 6 + 2 + 8 + 8 + 0 + 0 = 27. Find the sum of the ...
2
votes
1answer
32 views

Project Euler # 19 Counting Sundays in Python

You are given the following information, but you may prefer to do some research for yourself. 1 Jan 1900 was a Monday. Thirty days has September, April, June and November. All the rest have ...
1
vote
1answer
28 views

Integer field in Python with extra constraints (Testable class)

I am trying to write an integer field in Python with the following attributes: Minimum Exclusive minimum Maximum Exclusive maximum Multiple of Value Basically, given the constraints and the value, ...
-1
votes
1answer
30 views

HarckerRank 2D Arrays Hourglass challenge

About this 2D Arrays HackerRank problem. The task is to find the maximum sum of a region in a 2D array. Specifically, it is to find the maximum sum of an "hourglass" region, defined as a 3x3 square ...
-2
votes
0answers
22 views

Python Modifying a For Loop so that Loop Ends when condition is Met [on hold]

I have created a Python script that iterates through an HTML table.The script has an IF / ELSE section that looks for text with a decimal point. My goal is to determine if text on the HTML table ...
2
votes
1answer
33 views

Store coordinates in 2d grid

I`m writing a function for small pygame program. The ideas is that I have a 500 pixels square screen and I want to place 5 objects per row with the size of width and height in random order and I need ...
3
votes
1answer
52 views

Hurst Exponent calculator

I am aiming to compute the Hurst Exponent of a 1-D signal time series in Python. For now, I have one existing function hurst(sig) which returns the Hurst exponent ...
1
vote
1answer
22 views

leetcode 987. Vertical Order Traversal of a Binary Tree

anyone can provide some suggestion about my answer for the questions 987. Vertical Order Traversal of a Binary Tree Given a binary tree, return the vertical order traversal of its nodes values. ...
2
votes
2answers
90 views

Staircase challenge - Python

Your task is to print all unique ways to climb a staircase of length n where, from each step, you can take steps of size x where ...
2
votes
1answer
48 views

Find Todos by Line Number (or any other reference) in Python - Revised as functions

A new function based version of the code from this question as suggested by @Hlib Babii I write a lot of TODO's but I never keep track of where they are. This program will search through files (and ...
1
vote
4answers
112 views

Rock, paper, scissors game in Python 3

as a beginner in Python I made a rock, paper, scissors game and was wondering if my code was a bit weird and could be simplified??? ...
-2
votes
0answers
30 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: ...
3
votes
1answer
35 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 ...
3
votes
1answer
48 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 ...
4
votes
1answer
53 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. ...
2
votes
1answer
21 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. ...
3
votes
1answer
27 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 ...
3
votes
1answer
46 views

SQL queries in a dataframe

I want to get table names and column names from queries in a dataframe. The dataframe is like this: ...
2
votes
1answer
35 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) ...
3
votes
1answer
22 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
2answers
52 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
25 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. ...
3
votes
2answers
102 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 ...
6
votes
1answer
111 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 ...
5
votes
4answers
75 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 ...
2
votes
1answer
63 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
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 ...
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
23 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 ...
9
votes
3answers
483 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 ...
2
votes
1answer
28 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 <...
-1
votes
0answers
23 views

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

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
288 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, ...
3
votes
2answers
88 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 ...
-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 ...
0
votes
2answers
59 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: ...
0
votes
1answer
55 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 ...
5
votes
1answer
62 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 ...
2
votes
0answers
34 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. ...