Questions tagged [python]

Python is an interpreted, general-purpose high-level programming language whose design philosophy emphasizes code readability. Use the python tag for all Python related questions. If you believe your question may be even more specific, you can include a version specific tag such as python-3.x.

Filter by
Sorted by
Tagged with
2
votes
1answer
69 views

Pong game in Python with tkinter

This is a pong game I created some time ago, but it doesn't have methods to store scores yet and also might have some bugs. It is also very slow. The code: ...
3
votes
2answers
100 views

Beginner Tic-Tac-Toe in Python

...
12
votes
4answers
1k views

Extraction of value from a dict-tree, given a path of arbitrary length

Problem: We read a complex json-file which grants us a tree in terms of a python "dict of dicts". We're then requested to retrieve a specific path from the tree, represented by a list of elements. The ...
8
votes
1answer
63 views

File(s) encrypter implementation in python

I'm looking for any feedback in order to improve code styling, performance etc. Also I want to make sure that the way I've implemented AES here is actually secure ...
4
votes
1answer
47 views

Python timing optimisation

I'm new in this community and with Python 3! I'm trying to optimize this exercise: We have n strings stored in a txt file. Inside the strings a secret word is ...
3
votes
1answer
90 views

Login system created with Python

This is a program that I created using Python. Please help me optimize the code. ...
19
votes
6answers
4k views

Explicit song lyrics checker

To stay in practice with my Python I've decided to write an explicit song checker. It checks each word in the song against an array of 14 explicit words contained in the text file. I've decided not to ...
5
votes
2answers
278 views

Productivity/Timer app that uses twilio to send SMS-reminders

I wrote a timer app in python using both twilio and the timer module; sends an sms to my phone after a certain amount of time has passed. While it works without a doubt, I wanted to gather some ideas/...
1
vote
0answers
19 views

Blob data from Oracle to .zip file using python [closed]

I have been trying to get the blob data from oracle into a zip file using Python. I couldn't find the answer on any of the other links. Below is the code:- ...
3
votes
1answer
61 views

Small socket based packet Library

I'm currently writing a python script which needs some simple networking. After some playing around with sockets, this emerged, but as this is my first foray into sockets I'd really like a second ...
4
votes
1answer
43 views

Algo for generating a fake, but feasable, dataset

So, I was working on a dashboard for a potential customer and I needed a fake dataset with employee information to demonstrate. Mainly, I needed to know when the employee arrived the company (first ...
6
votes
1answer
89 views

Optimizing a raycasting/voxelspace algorithm in Pygame

In the past three days, I've been developing a simple raycasting algorithm. I've made the renderer work as I'd like to. However, it is extremely slow (5 frames per second) because of two things (as ...
9
votes
3answers
2k views

Single Player Python Battleship Game

I made a battleship game for a programming class, where I only had about a week to get it done. Under this time crunch, and the fact that I don't know python very well, I made some of the code in very ...
5
votes
1answer
52 views

Average row id volume

After a test run with LoadRunner I wanted to know the average time for each transaction for each VU volume step, the LR let you create a graph for this but don't give you the point values... so it's ...
3
votes
1answer
63 views

unique username generator

I have written a class to generate a unique username from the full name. The full name is the name of a company usually containing 4 to 5 words. The username generated will be of format {preffix}{...
6
votes
1answer
318 views

Python Perceptron

This is my finished perceptron written in python. Is there anything that I can improve/suggestions? I'm a beginner with python so anything would be helpful! ...
1
vote
1answer
63 views

Reuse the value of previous type instead of None [closed]

I've created a function in python to print some information through it. I'm trying to supply list of alphabets to the function along with the type those alphabets fall under. When I execute the ...
3
votes
2answers
130 views

New to programming. How can I write this Rock, Paper, Scissors code better?

I am practicing w/ Python and wanted to code a simple Rock, Paper, Scissors game w/o any user input. I used a list to hold the values and randomly pulled them with a function. I used the the return ...
7
votes
1answer
158 views

Basic Python HTTP Server

It's an extremely simply HTTP server in Python using the socket library, and a few others to get the MIME type, etc... I've also avoided the ../../ vulnerability, ...
8
votes
2answers
306 views

NLP sentiment analysis in Norwegian

Please keep in mind that I am very new to data science and completely new to NLP! I am trying to create a model to classify customer reviews as either negative or positive. However, my main problem is ...
5
votes
1answer
128 views
8
votes
1answer
444 views

Optimize Performance of Region Checking in List Comprehension

I am modeling a linear process at a number of equally spaced time steps. I have a large list (~70k elements) which corresponds to a location at each time step, ...
4
votes
0answers
82 views

Liveness monitor : python and RabbitMQ together through Pika

I'm a beginner using Python, and I'm trying to implement a functionality of a monitor program already developed by an other programmer. This program is working on a Windows machine (made by Inno ...
3
votes
1answer
48 views

CliwPw - Yet Another Python3 Password Manager

I wrote a (very) simply Python3 password manager to familiarize myself with Sqlite3, and for fun. I am aware that there are already a variety of password managers out there, but I wanted something ...
1
vote
1answer
57 views

Reduce the execution time utilizing two apis

I am new to python. I have been given a task to verify the data from 2 apis which give similar data but in different format i.e. Json and XML. I have written the code but it is taking too much time to ...
12
votes
4answers
985 views

Parsing C-like code to extract info

I'm reading a file with the following data, ...
3
votes
1answer
58 views

Scraping IMDB and exporting to JSON or/and CSV

This code is scraping the data from IMDB and displays it in JSON or CSV format. I plan to extend it beyond the top rated movies. How can I improve the quality of my code? I am using Python 3.7.3. <...
4
votes
1answer
79 views

Automating a set a of weekly reports, including graphs and delivery of reports

I have been writing code to automate some weekly reports. I had help over on Stack Overflow. I have code that works for the most part, however there are a few things that I just can't seem to fix. In ...
2
votes
1answer
62 views

Object oriented hangman game

I'm a hobbist trying to become a professional software developer. I do have a lot interest in Data Science in general and my goal is to master Python before diging deeper into specific data science ...
0
votes
1answer
65 views

Hangman Game using python3

Summary I made a hangman game using python but I had trouble writing clean pythonic code Questions In the code snippet I provided (Full code in the link below) I used global for: loop and points ...
5
votes
3answers
107 views

Simple run-length encoding decoder

For practice, I decided to write a run-length decoder. For example: ...
1
vote
0answers
40 views

X in a Line Console Game - Python OOP

Please could you review my code below? The game is similar to "Connect 4", but I haven't implemented diagonal checking for wins. In particular I'm interested in my use of OOP. E.g. My choice of ...
2
votes
1answer
47 views

Import/Export data from/to json using python

I developed a code in python that: add name, age and Id information for each person, search a person by name, if it exists then display a message "Found" and fill "age" and "Id" with the ...
4
votes
1answer
41 views

Plotting shapely polygon in matplotlib

When working with geometric objects I like working with the shapely module (Shapely - PyPI). In here it is easy to create polygons and define union, intersection and differences. Like so: ...
3
votes
1answer
49 views

Map price values to bins where bins are of a larger price range

I have two different pandas data frames where in the first data frame (price), I have two columns. The first column named value has some values in it and the second column amount has the available ...
4
votes
3answers
2k views

Python Barcode Generator

I was asked to provide some example code for a job interview and didn't have anything to offer, so wrote the following function. A barcode generator may seem a bit basic, but there's some logic ...
6
votes
2answers
635 views

Python Barcode Generator v2

This is a complete rewrite of the code posted for review in this question. The question is identical. ...
-1
votes
0answers
26 views

text based adventure-game to defeat an attacking NPC [duplicate]

print("Welcome player! Defeat the enemy in Hell to win, die and you lose!") print("You can take an item you see in the room, you have to have an item in your bag") print("(which means you have ...
5
votes
3answers
238 views

Log monitoring with pythonic tail -f and process killing

The purpose of this cluster of functions is to tail the log file and kill/restart processes from shell (the latter is not yet implemented). ...
2
votes
2answers
74 views

hash image url and if valid store image url

I am trying to get all image urls which are valid and unique.To make sure i wont end up using the same image again i calculate hash of the image and store it in a text file and read the text file ...
1
vote
0answers
41 views

Basic pygame menu with buttons

I'm new to python and newer still to pygame. In my attempt to learn, I set to make a basic menu with buttons. Here's my code: (note, ui_plate, is a system that the buttons are based on, it keeps all ...
4
votes
0answers
51 views

Python Project Template

What's up smart people. A little backstory for context: I'm a completely self taught dev, and the only person ever looking at my code for the past 6 years is myself. I realize that's not the best idea ...
7
votes
3answers
15k views

Algorithm to get an arbitrary perpendicular vector

Is there a more efficient/direct way to find an arbitrary perpendicular vector of another vector? ...
6
votes
3answers
971 views

Receive a list of names and return a list of users - HackerRank test

So, few months ago I did a HackerRank test for a company. The problem was to create a function which receive a list of names and returns a list of unique usernames. For example: For the list of <...
5
votes
1answer
259 views

Solving Subset-Product in Python

I've written a python script that solves a restricted variant of Subset Product by using integer factorization. The purpose of the script is for my empirical observations of the similarities between ...
7
votes
2answers
492 views

find longest common substring in space O(n)

I am working on the class question find the longest common substring from 2 strings but I would like to return the longest common substring instead of just size of longest common substring.like ...
5
votes
0answers
400 views

2048 AI in Python 3

I am working on an 2048 AI and this is my code so far. In the game 2048 you have a 4x4 grid in that some random so named tiles spawn. Each tile has a number. The lowest number is 2. By using the left,...
3
votes
1answer
56 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 ...
5
votes
1answer
64 views

Python 3.6 Hangman game with .format graphics

This is my Python 3.6+ version of the Hangman game, with graphics generated with print and .format. I've never written code ...
8
votes
3answers
1k views

Generating a random string of 6 characters long in Python 3.6.2

I am learning Python, so pardon me if this is the very crude approach. I am trying to generate a random string using alphanumeric characters. Following is my code: ...