Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

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.

3
votes
0answers
11 views

Assigning projects in order of priority

Let's assume we have the following situation: Multiple project topics exist, each corresponding to a natural number n, students can sign in and choose two ...
10
votes
4answers
1k views

First non-repeating letter

The problem: find and return the first nonrepeating character in a string, if the string does not have a nonrepeating character return an empty string. For purposes of finding the nonrepeating ...
-2
votes
0answers
22 views

CSV and Random class missbehaving [on hold]

So I was trying to generate a quick test file. I wanted to have 5 columns and 15 rows of random numbers. Naively I went like this: ...
-4
votes
0answers
17 views

Are two variable length parameters of different types possible? [on hold]

Here is some working code that would take two lists as arguments ...
4
votes
2answers
44 views

Simple Python 3 TicTacToe Game

Relatively new here so please let me know if I'm doing something wrong. I'm mostly wondering if there's any additional way I can make this code more efficient. Specifically the moveset and win ...
-1
votes
0answers
14 views

Python and SQL - Query takes too long to execute [on hold]

I've recently began to work with Database queries when I was asked to develop a program that would have read data from the last 1 month in a Firebird DB with almost 100M rows. After stumbling a ...
0
votes
0answers
8 views

End characters from string being cut off when decrypting (Python) [on hold]

Making a program that encrypts a txt file of the users choice and then saving the encrypted version as a separate file. It should also be able to decrypt the a file if the correct 8 character key is ...
2
votes
1answer
37 views

PyCat: a netcat implementation in Python3.x v2

This is a follow up question from this question Intro netcat is an all-round tool used with many applicable features My last try felt a bit rushed, and should've improved before posting here. But ...
3
votes
1answer
23 views

Use Python along with the HubSpot HubDB API and the Blog Post API to create, update, and publish a batch of blog posts

My program automates the process of creating and publishing 152 blog posts quarterly. The blogging platform HubSpot has a series of APIs that allow developers to access account data from a CLI in ...
-4
votes
0answers
10 views

Compare elements in 2D two non-identical arrays [on hold]

I want to compare each elements of List2 with first two elements of List1 and if matched return the 3rd elements from ...
0
votes
1answer
44 views

How to better process csv file with pandas and further dealing with set

I have below working code with pandas and python, i'm looking if there is an improvement or simplification which can be done. ...
2
votes
1answer
41 views

Spotify API data to vk.com user's status

Just a simple script that puts a user's currently playing track(on Spotify) to his account's status on vk.com. And printing info about the track in the console. ...
2
votes
1answer
54 views

Find all combinations of 4 elements whose sum equals a target in Python

I wrote a solution to find all combinations of 4 elements from a list whose sum of elements equals some target Given an array nums of n integers and an integer target, are there elements a, b, c, ...
-2
votes
0answers
18 views

Python BMI Calulater Error [on hold]

I tried everything to make it work but the mode and weight category didnt work i want to ask if anyone can help fix the code and make it work. its just the basics but i hope someone can help me. <...
4
votes
2answers
57 views

Python grouped iterator

I wanted to write an iterator that would split items up into groups, so i can bulk insert into mysql without crashing or overwhelming the server. This is the implementation I came up with. I am ...
11
votes
5answers
2k views

Printing every 10th result in an alternating ± series

Problem: In the following expression 1-2+3-4+5-6 ... -98+99-100, print result every 10th (10, 20, 30, ...) calculation. My code: ...
1
vote
0answers
17 views

Twitter scraper using tweepy

I wrote a Twitter scraper using the tweepy so I can scrape user information and tweets. Given that the free API doesn't let me get the number of messages per tweet, I had to rely on BeautifulSoup to ...
1
vote
1answer
60 views

Credit card validator in Python 3.7.1

I am doing some projects so I can teach myself programming. The one that I finished states: "Credit Card Validator - Takes in a credit card number from a common credit card vendor and validates it to ...
-4
votes
1answer
31 views

Parsing million words of list in python regular expression is slow [on hold]

I have been working on a project in python which takes content from web links and find some important words from content of that page. I used regular expression to do so. But it takes huge time to get ...
1
vote
0answers
70 views

Scraping and printing titles from Craigslist

I've written a very tiny script using class to scrape some titles of products from craigslist. My intention is to make use of __str__() method so that my script can ...
2
votes
0answers
29 views

Implementing key map with expire and size limit

Recently I have been asked to implement a key map with expire time for each key and possibility to limit the number of keys, in Python. I've used a dictionary + heap to store the entries, e.g.: ...
3
votes
1answer
51 views

Dice sums comparison probability

I was playing a fun little board game called U.S. Patent No. 1 about time traveling to register your time machine as the first U.S. patent. I started to wonder what the dice probabilities were for ...
-5
votes
0answers
8 views

Python-Jumble- Assist [closed]

Im writing a function that takes only the letters I input and pulls the jumbled word from a word.txt file. ex. if I type the letters "snlik" the function would pull the word "links" from the word.txt ...
0
votes
1answer
15 views

Assigning zero to random cells in a pandas.DataFrame

I am trying to assign 0 to random cells in a one dimensional pandas.DataFrame. The below code is the best way I could think of ...
7
votes
2answers
80 views

PyCat A small implementation of netcat in Python3.x

Intro netcat is an all-round tool used with many applicable features I was playing around with sockets and openssl, and decided I should build my own. It works as expected, but my code feels a bit ...
3
votes
2answers
40 views

Python 3 multi-threaded pinger

My goal: I want to ping every single IPv4 address and record whether or not they responded. The way I have it set up is every IP address corresponds to an index. For example ...
1
vote
1answer
82 views

Making use of a decorator within a python script

I've written a script in python which is able to collect links of posts and then fetch the title of each post by going one layer deep from the target page. I've applied @get_links decorator which ...
-3
votes
0answers
14 views

Extract Data from single sheet in single excel file and then create multiple excel sheets by performing data manipulation in Python Data Frame [closed]

I have created a data frame in python which consists of data contained in excel sheet as per details below. I have a single sheet in single excel file with 100000 rows and 2 columns ("Location Name","...
3
votes
0answers
16 views

Context manager to temporarily drop indexes and constraints on a table

I'm importing millions of rows into a PostgreSQL database using a foreign data wrapper. To speed this up I've written this context manager to DROP all the indexes ...
2
votes
0answers
46 views

Historical exchange rate between currencies using Ecbxrate

I tried writing a simple python script using the python module ecbxrate that outputs to a CSV file a table with the daily exchange rate between EUR and USD since ...
2
votes
2answers
88 views

Python login system for a dice game

This is a finished login system where 2 players have to enter their username and password to proceed onto the game. The usernames and passwords are stored in a text file in this format...
0
votes
0answers
23 views

solving n queens in polynomial time when n is a multiple of 6 [closed]

I was trying to solve queens when I realized that the queens' position was geometrical shapes then probe every n and I discovered that the multiples of 6 form two parallel lines then create a code ...
0
votes
0answers
10 views

Building a system of ODEs, efficiently updating parameters and evaluating vecors of ODEs

I am building quite large systems of ODEs programmatically. I intend to find the steady states of ODEs under different parameter values. A boiled down example of my code is shown below. Comments with <...
0
votes
1answer
38 views

User Input in class sanitized

I want to sanitize my user input in my class. All is working as expected but first of all, I would like to avoid to set a default value for my digit parameter. ...
1
vote
0answers
35 views

Sorting cards by suit and value using Shell Sort

The question description: put a deck of cards in order by suit (in the order spades, heart, clubs, diamonds) and by rank within each suit, with the restriction that the card must be laid out face down ...
3
votes
1answer
40 views

Counting vowels and consonants in a string

The output should display as follows... ...
4
votes
1answer
42 views

Project structure for a reactor model built in Python

I use Python for various computational reactor modeling activities. While there are many components to the models I develop, the basic structure of the project folder tends to be similar to the ...
0
votes
2answers
42 views

Count power of big numbers and then apply modulo on this numbers

I have this example code in which I have very big numbers as you see. Problem is that when I use this algorithm for some small numbers, it works well, but when I use it for big numbers like in this ...
3
votes
1answer
45 views

Command-line NHL skaters stats tool

Have been playing with the undocumented NHL API for some days. I'd love to see any input about this little script. About overall structure, style, performance enhancements, etc. Not sure how to ...
0
votes
2answers
48 views

Short Eratosthenes Sieve

I've written a short implementation of the Eratosthenes' sieve. ...
2
votes
0answers
23 views

Calculate average round cell value from each 2D array cell

I am try to practice the leetcode and hit the following question 'image smooth'. Basically the question is to calculate average the around cell value from a 2D array. I have following code. But if ...
8
votes
2answers
369 views

Sparse 3D binning/histogram function

This is a function written in Python I wrote to process galaxy catalogs for cosmology research, however it is more generally applicable than just my pipeline. The goal is to take a Python list of ...
3
votes
1answer
99 views

2 player dice game

This is a finished project where Two people roll a dice twice and if the total of the two dice are even it adds 10 points to the two dice rolls and if the total is negative it takes away 5 points from ...
1
vote
1answer
64 views

My Python 3.6 script to detect stamp card redeem fraud and prepare a csv report

I have a requirement to write a Python 3.6 script which should be able to detect following case within a time period and be able to create a text file report that lists the condition violated and ...
1
vote
1answer
29 views

Vector addition and pythagorean theorem code

Hello i would like to share my code that is meant to help me add 2 vectors together. It is very simple and i would like to kindly ask you whether you could review my code. Also i decided to keep ...
1
vote
1answer
71 views

Wrapper for REST API calls

This is a wrapper that can be used to do additional external REST call to some API. Since I have to provide support to legacy code so I added three static functions to support them. However, the ...
5
votes
1answer
67 views

Using Python decorators to do Hoare Logic

I'm relatively new to Python from a strong Java background. I am trying to create a base class to do Hoare Logic. Function decorators seem to be the way to go with this. I've produced the following ...
2
votes
1answer
46 views

twitter data mining script in python

I have written a simple script that searches twitter for keywords and saves them to a csv file if they contain those words. It can be found on my github here. How can I improve this code to generally ...
3
votes
1answer
45 views

Python Rubiks Cube Object

I have made a Rubiks Cube object which builds a Cube out of Cubelet objects and then allows you to move it. Things I still plan to do is add tower cubes and triangles and other shapes as well as a ...
2
votes
2answers
66 views

Given some integers, find triplets where the product of two numbers equals the third number

I am trying to solve a coding challenge: Given N integers A1, A2, …, AN, count the number of triplets (x, y, z) (with 1 ≤ x < y < z ≤ N) such that at least one of the following is true: ...