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

Failing some test Case [closed]

two students are sitting beside him each having one string. Lets say student1 has string s and student2 has string t.Both strings are made up of just two signs − and + and they are wondering whether ...
1
vote
1answer
21 views

Filtering string by given keywords

Im currently working on a filtering keywords. I have two lists which I called positive and negative. Scenarios: if POSITIVE matches and NOT ...
0
votes
0answers
44 views

Python case insensitive dictionary

This is a Python case insensitive dictionary that is ordered and has integer indexes for the keys and values. I just wrote it today. It is ordered because I am using Python 3.9.6 and plain ...
-3
votes
0answers
13 views

Unable to get required output in Backdoor and Listener with Remote Code Execution functionality [closed]

I am trying to code a Backdoor and for it, a Listener that can be used to remotely execute commands on a Compromised Machine. But I am unable to get the code right in Python 3. There are 2 codes in ...
1
vote
1answer
46 views

Python Code Style If,elif, else

I have this Python code: ...
6
votes
1answer
353 views

Python code for eliminating options for random intergers as they get picked

My goal is to write code that picks several random numbers from a range without repeating any previously chosen numbers. I figured out a functional solution for my problem but it seems very bulky and ...
1
vote
0answers
58 views

Python case insensitive three level nested dictionary

This is a custom case insensitive nested dictionary class created by me, its main usage is to populate QTreeWidget and keep track of said QTreeWidget, the main incentive behind this class is to ...
0
votes
1answer
16 views

Cubic Permutations | Project Euler #62

The cube, 41063625 (3453), can be permuted to produce two other cubes: 56623104 (3843) and 66430125 (4053). In fact, 41063625 is the smallest cube which has exactly three permutations of its digits ...
4
votes
0answers
40 views

Thread Art Generation that Creates Embroidery Files

I have made a thread art generator that creates thread patterns from images. Mine is a bit different as it outputs an embroidery file (It embroiders quite nicely, though the settings need a lot of ...
2
votes
2answers
44 views

Find the highest product of three numbers in a list (Python)

I wrote the below as a solution to: Problem Find the highest product of three numbers in a list Constraints Is the input a list of integers? Yes Can we get negative inputs? Yes Can there be ...
4
votes
2answers
44 views

Simple enemy movement simulation on Tkinter

Kind of a noob at Python here, and this is one of my first "big"(big for a beginner like me) project that I undertook with Tkinter and Pynput. Basically, this code will simulate an enemy's ...
3
votes
1answer
27 views

Attempting to solve minimum window substring problem using Python 3.8

Hello programming gurus/reviewers, I attempted to solve the Minimum Window Substring (Leetcode 76) problem using Python 3. My solution involved using Counters and backtracking. On submission, the ...
3
votes
3answers
394 views

Loop to print changes in irrigation state to turn on and off a pump when water is low

Python Noob building an automation irrigation system in Python for Raspberry Pi. Python has two functions in the most basic use case: on/off the LED (which will in future be a relay->pump) and ...
-1
votes
0answers
24 views

Prime pair sets | Project Euler #60 | Need code optimization

I am on problem 60 of Project Euler and my code is too slow to find the required 5 numbers. I can find 4 numbers easily under a second but finding 5 is taking very long. Can you help me identify what ...
2
votes
1answer
60 views

Yahoo finance option chain scraper

This is my 1st Python program I've actually written and I have little to no background in the language. I just figured I could learn and do something that interested me at the same time. I'm not a ...
1
vote
1answer
31 views

Ratio of primes in square diagonals | Problem 58 Project Euler

I solved problem 58 in Project Euler and I am happy with my solution. However, are there any areas where I can improve my code here as I am learning how to write good python code. Prompt: Starting ...
2
votes
0answers
16 views

Applying Minimum Image Convention in Python

I am computing pairwise Euclidean distances for 3-D vectors representing particle positions in a periodic system. The minimum image convention is applied for each periodic boundary such that a ...
0
votes
2answers
41 views

Build order from a dependency graph (Python)

Below is my attempt at the challenge found here. The challenge is "Find a build order given a list of projects and dependencies." Already given are the classes Node and Graph (which I can ...
1
vote
2answers
65 views

Permuted multiples in python

How can I improve efficiency/readability of the following code? It can be seen that the number, 125874, and its double, 251748, contain exactly the same digits, but in a different order. Find the ...
1
vote
1answer
26 views

Python MP3 player with pygame.mixer and tkinter for MacOS

I made a Tkinter MP3 Player with Pygame and am looking for tips to improve. Explanation offered in comments in code, but it generally works by getting all the files in a folder. (Have censored ...
2
votes
0answers
30 views

Loop through the nearest switch and deletion neighbours of a Boolean assignment

My goal is to look for nearest neighbours in a Boolean-assigned mapping (a Python dictionary). For this purpose I'm looping through the candidates, starting from those with the closest distance. The ...
0
votes
1answer
45 views

script to recover browser passwords

basically i am new to python lookin for any bad practices done down there in my script, any ways to shrink the code and increase efficiency ...
2
votes
1answer
110 views

Extract flight arrival data from web

I'm trying to scrape arrival data from Flight Radar 24 My script takes extremely long time to scrape the data. Is there any way I can speed up the scraping process? Here's my script: ...
3
votes
1answer
53 views

Pygame program made to look like NohBoard

This is something I made as an input display resembling NohBoard because I need to make a video for a video game, but it's on Linux which doesn't have any good input display programs. One thing I'm ...
2
votes
1answer
88 views
1
vote
0answers
13 views

Delete older EBS Volume snapshots except few with certain tags using Python, Lambda

I am learning Python and managed to accomplish the above. But my script doesn't seem optimal. Could someone help to take a review and suggest for betterment? ...
1
vote
2answers
130 views

Scraping webelements if found

Im currently working doing a webscrape which in my case if sydsvenskan but will be a template over time for other sites. I have currently done: ...
1
vote
1answer
31 views
4
votes
1answer
85 views
0
votes
1answer
25 views

Config for each environment (for a simple Python SDK)

I have a simple SDK in Python for internal use. It's basically 150~200 lines of code of simple API calls wrapped around nicely that is comfortable for us to use. It holds a few clients with methods (...
1
vote
1answer
32 views

Simple login test, translated from java to python

I'm reading on how to write proper testing suites here. So I'm trying to follow the selenium example in the docs which is in Java; I'm trying to translate it to Python since my app is written in ...
3
votes
2answers
75 views

Round number to nearest non zero digit

I have the following code to round a number down to the nearest non zero digit in a string, or if the digit is larger than 1 it would round to the second decimal place. I have yet to find a way to do ...
8
votes
2answers
534 views

Efficient renaming of dict keys from another dict's values - Python

I have a dictionary in Python (uglyDict) that has some really un-cool key names. I would like to rename them based on values from another dictionary (...
3
votes
1answer
38 views

Find number of ways to traverse matrix of 0's and 1's

I solved a Daily Coding Challenge, but i suspect my code could be optimised. The challenge is the following: You are given an N by M matrix of 0s and 1s. Starting from the top left corner, how many ...
10
votes
2answers
657 views

Create a words histogram of a given string in python

I wrote a code that given a string (txt), will print a histogram that contains the number of occurrences of each word in it and the word itself. A word is defined ...
1
vote
2answers
53 views

Checks if all nested objects don't have 'status' attribute as 'deleted'

I currently this code working, but its performance is very poor — 1.45 seconds seems a bit too much for a simple recursive if statement that only checks attribute values. ...
4
votes
1answer
361 views

Find next smallest number that's representable as a sum of distinct powers of 3

I'm solving this challenge: Given a positive integer number, you have to find the smallest good number greater than or equal to the given number. The positive integer is called good if it can be ...
1
vote
2answers
39 views

Account signup/login program in Python

This is my first program that I wrote on my own. Is there something I can improve upon? There are a few things that still need to be added, such as: Confirm password while registering Adding a way to ...
3
votes
1answer
73 views

Python sensor calibration tool

all This script's purpose is to check whatever the acceleration component s in order. The IMU data sampled represent 2 samples of the imu measurements. I'd love to hear your comments regarding ...
1
vote
1answer
44 views

Move all markdown files from one folder to another in Python

I want to move all markdown (.md) files from one folder to another. The folder structure I have: ...
0
votes
0answers
29 views

Graph Theory Amortized Analysis

I created some code to represent a graph. There are two functions to operate on the graph. The first which uses a list of nodes, determines if there is a key in a graph. The second which uses an ...
1
vote
1answer
50 views

An implementation of Uber's “Fare Estimator” [CodeSignal]

CodeSignal put out a challenge by Uber that involves writing a "fare estimator" that involves a function dependent on cost per minute, cost per mile, ride time and ride distance. The formula ...
2
votes
2answers
80 views

Finding pair of numbers that minimize a function

This is a problem of a past bioinformatic contest (requires an account). My solution works but is too slow for some test cases. Input format The first line of the input contains one integer \$T\$, \$(...
1
vote
0answers
27 views

Python script to compress and encrypt a list of files/directories (tar + gpg)

I've tried, as practise, to write a Python 3 script which takes a list of paths to files/directories and compresses them with tar, before encrypting the resultant ...
1
vote
3answers
140 views

Count prime numbers whose rotations are all prime

This code solves Project Euler problem 35: The number, 197, is called a circular prime because all rotations of the digits: 197, 971, and 719, are themselves prime. There are thirteen such primes ...
1
vote
2answers
83 views

Compute members of the infinite series generated by 2n+1 and 3n+1

Consider the infinite sequence u, where u is defined as follows: The number u(0) = 1 is the ...
1
vote
1answer
32 views

Inserting Data to three linked table with SQLAlchemy

I am inserting data from a dict type object into three different tables in the SQL database. I am using Sqlalchemy as my ORM. My code is working but I think it is not very readable, is it any way to ...
1
vote
0answers
24 views

Hangman program (python)

I created a fairly simple hangman program as a little side project. Could you please tell me of any improvements/suggestions/criticism/feedback that you have about my code? Thank you in advance. ...
8
votes
3answers
872 views

Filter out ambiguous bases from a DNA sequence

I have this function: ...
3
votes
0answers
55 views

Generate valid combinations of parentheses

Playing on leetcode coding problem: "Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses." I realized that my understanding of Python was ...

1
2 3 4 5
95