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

Decrement from an array of integers equally for all elements > 0

There are x distribution centers each with y number of products. Each day only an equal amount from all x distribution centers with remaining product can be shipped. Calculate how many days it would ...
3 votes
1 answer
85 views

Converts image from one type to another

This script first looks through a specified folder path for image files that have a given extension and removes any periods that might be in those file names. It also adds those sanitized file names ...
2 votes
1 answer
178 views

Making two classes work ambidextrously

I've written some script in python following OOP guidelines. I've created two classes in my script in such a way so that both of them are able to make requests and produce flawless results. It can ...
2 votes
0 answers
32 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 ...
4 votes
3 answers
6k views

Compare files by name in two folders A and B and delete duplicates from folder A

I wrote my very first Python program to answer a Super User question. I'm wondering how the application can be rewritten to make it as pythonic as possible. Unit test ...
6 votes
2 answers
418 views

Determine a diver's table and schedule based on depth and duration

I'm new to coding but I'm particularly new to python. I wrote a program that will determine a diver's table and schedule(because it relates to my job). It essentially assigns a value from multiple ...
1 vote
0 answers
31 views

Program for monitoring file in Combined Log Format

After encountering a suggestion that monitoring a log file for a webserver could allow for the implementation of automatically analyzing and handling of certain events (that might require altering ...
5 votes
3 answers
116 views

Python 3 Multi-connection downloader

I have written a fully functional simple command line multi-connection downloader, written in Python 3, using just threading, ...
2 votes
1 answer
3k views

Predicting random numbers based on past output

I've been working on a program to predict random numbers based on previous digits. However, I only get access to numbers from 0-53 inclusive, and one only comes every 30 seconds or so, therefore ...
0 votes
0 answers
36 views

Television and channel modelling [closed]

I wrote a simple project to train my beginning knowledge of OOP. My class represents a Televisor that has two types of channel list: the first one is global, that's applied to all objects of my class ...
5 votes
0 answers
132 views

@lazylist - Converts a Python Generator to a List without evaluating every element

I made a LazyList class that can wrap an iterable (list, generator etc.) and turn it into a MutableSequence (like ...
3 votes
0 answers
54 views

Decorator implementation around xarray.open_dataset

If you would like to download some grib data for yourself, the script below will pull girb data from the google api over a date range at an hourly interval. Extract some hrrr grib2 data ...
23 votes
3 answers
4k views

Financial website scraper

I wrote the code that would scrape Finviz for tickers and href that attach to the ticker. I tested with multi-page as well as one page. I'm new to Python ...
0 votes
0 answers
41 views

Web Scraping: finding a particular content and taking an action for multipule pages

Summary: the whole code is given at the bottom the problem (or say main concern) is described hereinbelow. The code scrappes the website goes through various pages and finds particular content to ...
4 votes
1 answer
103 views

Check how many days a country has been independent

I have been using a website called 'CSNewbies' to learn Python and one of the tasks was to create a way for a user to check how many days a country has been independent. The countries are limited to ...
3 votes
1 answer
104 views

Small shopping cart application - Solid Principles and Clean Code

I've recently had a technical interview where I had to identify code smells and refactor an existing code by applying the SOLID principles and implementing unit tests. It is a small shopping cart ...
-1 votes
1 answer
54 views

Forecast experimental results based on temperature [closed]

I would really welcome any hints on making this code more concise please. In this example we have some experiment results. For each planned experiment We have predicted results based on 4 temperatures ...
6 votes
1 answer
100 views

Implementation and Testing of Exponential Search for scenario where we search the same array/list many times

Exponential Search is an optimization over binary search. Conceptually, when searching for a number target in a list of numbers ...
1 vote
2 answers
70 views

Comma code project from "Automate the Boring Stuff with Python"

...
1 vote
1 answer
154 views

MATLAB / vs Python np.linalg.solve, heat diffusion

I am solving a simple 1D steady heat question using spectral method. I am a long time MATLAB and Mathematica user and trying to learn Python. I compare only linear solving times and Python is way ...
1 vote
3 answers
50 views

Removing medications older than 180 days ago from a list

I have the following code which removes a dict from a list of dicts in Python based on ...
2 votes
1 answer
58 views

Credit Card Validation Check (Using Luhn's Algorithm)

...
15 votes
3 answers
3k views

My 1 Week Python Journey — A Quiz Game that I made in Python

I started my Python Journey almost a week ago from now. I had been following a Youtube tutorial earlier, but switched to Harvard's CS50P instead. I decided on making a little Quiz Game with my ...
2 votes
1 answer
43 views

Get some cryptocurrency rates from coingecko api

I'm currently learning some aspects of PEP8 and Python programming in general. Could you please code-review this little piece of code for me? I would be glad to hear any, even the smallest comments, ...
5 votes
1 answer
98 views

How can I make my Pygame Tic Tac Toe game better?

I have this code ready and it works just fine. But what are the ways by which I can improve this code? I have no CS background and this is my first coding project. I could not paste my entire code so ...
2 votes
2 answers
193 views

Multi stage Dockerfile for eccode compilation

I wrote a Dockerfile to install ecCodes for use in a python environment using cfgrib and xarray. The tarball can be found on the ecCode releases page Dockerfile <...
0 votes
2 answers
45 views

Speeding up row insertion to Pandas DataFrames [closed]

I have the below code that seems to be taking a while to run over time. ...
6 votes
4 answers
892 views

Guessing the Number Game

I started my python journey 4 days ago. I am following a Youtube tutorial currently to understand the basics of Python. So bear in mind that I am REALLY new to this. I wanted to test myself a little ...
7 votes
2 answers
764 views

E-mail crawler for yellowpages

I've written a script in python to scrape e-mail addresses from different pizza shops located in los-angeles available in yellowpage traversing multiple pages. It is able to go one-layer deep and dig ...
2 votes
1 answer
45 views

Simple backup script with file removal after 7 days

Here is the script that I would like reviewed for the following: Best practices and design pattern usage Correctness in unanticipated cases Possible error checking Any streamline updates/ideas are ...
8 votes
4 answers
4k views

Fantasy game inventory — Ch. 5 Automate the Boring Stuff

Here is a practice exercise — Fantasy Game Inventory \$-\$ You are creating a fantasy video game. The data structure to model the player’s inventory will be a dictionary where the keys are string ...
3 votes
1 answer
47 views

Weighted Union-Find class

For a final project I used a weighted union-find and decided to implement it in Python. I wrote it to be as general as possible so it's very portable. I do plan on looking into path compression to ...
2 votes
1 answer
48 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. ...
2 votes
2 answers
85 views

3 dimensional python battleship game

I have an assignment in a python course. We were instructed to make a 3D Battleships game for 2 players on the same computer. I've written a code that works, according to the assignment instructions, ...
0 votes
2 answers
64 views

12 hour to 24 hour time conversion

doing hackerrank challenges and been learning python3 for a month now, made this code to convert and return 12 hour to 24 hour time format in one of the challenges ...
1 vote
0 answers
40 views

Python fractal tree generators

I wrote the scripts several days ago, they do exactly what I intended, but the performance is not very good, I am still stuck on for loops and don't know how to vectorize things, I wrote both scripts ...
7 votes
3 answers
23k views

Hailstone Sequences in Python

For the problem given: Douglas Hofstadter’s Pulitzer-prize-winning book, Gödel, Escher, Bach, poses the following mathematical puzzle. Pick a positive integer \$n\$ as the start. If \$n\$ is ...
1 vote
1 answer
55 views

Program for creating custom directory listings

The following code was written to create custom directory listings for the Abyss Web Server. It attempts to provide an improved example of the included documentation for doing so in Python. However, ...
2 votes
1 answer
52 views

Design Tic Tac Toe Interview Problem [Python 3]

Practicing objected oriented design. This time, it's designing the TicTacToe game. One difference between the real TicTacToe game is that I've made my TicTacToe game to have variable sized board. ...
3 votes
1 answer
274 views

Design Shopping Cart System Interview Problem [Python 3]

Just practicing some objected oriented design questions. Please let me know what can be improved to be more OOD and extensible. Thank you. Functional Requirements Cart can hold multiple products A ...
2 votes
0 answers
42 views

CodeReview: CycleGAN Implementation Using Keras FunctionalAPI

Okay So I Am Here Implementing the cyclegan architecture with using keras api from scratch. For Those who Wanna Know More About Cyclegan seehere The CycleGan Compose of Two Phase Architecture Like ...
12 votes
6 answers
2k views

One of my first Python projects - an adventure game

This is a simple text-based adventure game I made. I'm a beginner and I want to know if the code is optimal or if it can be improved. The story is not very complex, but I made it more for practicing ...
1 vote
1 answer
245 views

Hashing with python optimization, hashlib and multiprocessing

I am looking to get any type of improvement, I want to be able to hash a list of 'blocks' aka strings and check if hashes match per block, if you can help me with that, currently reading and writing ...
1 vote
1 answer
57 views

Adding string to a text file without duplicates

I have a function below, store_in_matchid_file, and it adds certain strings to a .txt file as long as that string doesn't already exist in the file. However that ...
4 votes
1 answer
597 views

Python factory class with dynamic imports

I'm trying to write a factory class that essentially provides a user-friendly frontend to creating objects of different kinds depending on keywords. So the user will just have to import this module, ...
15 votes
3 answers
11k views

Leetcode Two Sum code in Python

Here's my solution for the LeetCode's Two Sum problem. Problem: Given an array of integers, return indices of the two numbers such that they add up to a specific target. You may assume that each ...
5 votes
1 answer
191 views

Calculate the number of people occupied at each time interval

The following scripts calculate a list with the number of people occupied at each time interval. The intervals are defined by the timestamps of two consecutive events that come from the sorted list <...
2 votes
1 answer
60 views

Password hashing for safe storage with Argon

This code snippet implements password hashing for safe storage. It uses Argon2 as hashing algorithm. The method hash_password() is used to hash and salt a password. ...
1 vote
0 answers
56 views

Password hashing for safe storage with Bcrypt

This code snippet implements password hashing for safe storage. It uses Bcrypt for the hashing algorithm. The method hash_password() is used to hash and salt a ...
3 votes
1 answer
87 views

Noughts and Crosses Python3

I'm trying to get more coding experience and decided to start small with a basic noughts & crosses game. Any feedback is welcome and below are the items I think I should add a print out of an ...

1
2 3 4 5
102