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.

-1
votes
0answers
5 views

Extract Information from CSV file using Python

I have a dataset provided properties.csv (4000 rows and 6 columns).The csv file including many features some of these features are numerical and some of them are nominal (features contain text). ...
-2
votes
0answers
12 views

Python - exercise to test loops, conditionals, and try/except [on hold]

Good morning beautiful coder, so I am ashamedly new to Python and to get better I am following a free course on py4e.com (quite nice with lessons, exercises etc.). On chapter 5 there is an exercise ...
2
votes
1answer
43 views

Object-oriented model of a machine gun using Pygame

I just started to use classes in Python, so I don't know all concepts, rules and conventions about it. I made a little program of a machine gun, which simulates firing by user's action. Here it is: <...
1
vote
1answer
44 views

Python Text-based Card Game

I have programmed a card game in Python. How can I improve the code? There is a deck of cards. Each cards has a colour (red, black or yellow) and a number from 1-10. There are two players. Every ...
-4
votes
0answers
25 views

How do you find the maximum value in a list of lists? [on hold]

In Python 3, Say you have a list of lists: x = [(1,2,3),(43,21,-1),(1,-10, 5)] Define a function(x) that returns the max value of the above list.
-2
votes
0answers
24 views

Design a class to have several attributes or one attribute as dictionary with many keys, Python3 [on hold]

I have class for calculating temperature of an object at different positions, based on ambient temperature. ...
4
votes
1answer
48 views

Check if we can form a word across words in a sentence

I've come across a simple challenge: given a phrase, check if we can form the given word vertically by stacking words in rows. For example, we can form the word ...
-2
votes
0answers
14 views

Python Text RPG (Help/Suggestions) [on hold]

So I have been wanting to work on a solo programming project after trying to learn for the past 10 months. Right now I am working on this Texted Based RPG. I made a complete version that was awful, ...
9
votes
4answers
1k views

Program to accept numbers, then calculate the mean, median, and range

I created a basic program that allows a user to continuously input values until he or she is satisfied; furthering, the program outputs the mean, median, and range. Then, the code gives you the option ...
5
votes
1answer
51 views

Deal three Poker hands of five cards each in Python

I'm a beginner at coding who recently started learning Python, and I think I have grasped the basics. Now I'm working on my first "proper" project in Python. The problem is to have the program: ...
0
votes
0answers
14 views

Querying DB inside SQLAlchemy Model [on hold]

I have a SQLAlchemy model that looks something like this: ...
0
votes
1answer
42 views

Control the input of the user according to a sample string and get some info from it

I made this Python code that prints a sample string and ensures that the input of the user agrees with the sample, and then do an action with this inputted string, in this case a multiplication table. ...
-2
votes
0answers
25 views

i need to know how can my following pearson correlation finding code be better to select features(attributes) in dataset [closed]

My question lies in the better use of array... i can understand the working of most of the code however there is so much room for improvement... because i came from a java,c++ working environment to ...
2
votes
1answer
55 views

Pythonic quick sort

I'm new to the world of python, and wrote this quick sort implementation which was taught to us in an algorithms class. I would like to learn to write code less like C++ and more pythonic. Could you ...
0
votes
0answers
19 views

Python Class conversion [closed]

I am to encapsulate the GUI part of the code below into a Class. ...
0
votes
1answer
34 views

Namedtuple and list to populate each record of a JSON file

I had a JSON file in this format: ...
4
votes
1answer
40 views

Optimizing large file reads with a custom line terminator in Python

I asked for help accomplishing this on StackExchange. How to efficiently read a large file with a custom newline character using Python? And ended up providing my own answer which is duplicated ...
0
votes
2answers
31 views

Python Pandas - finding duplicate names and telling them apart

(Somewhat) new to python and coding in general! Using python 3.7 and pandas, I'm running code to create a searchable list of people in my dataframe, and I feel like my way of telling duplicates apart ...
12
votes
2answers
2k views

Tower of Hanoi Recursive Implementation using Python with OOP

I have just finished a small program for Tower of Hanoi using recursion. I did it to practice OOP which I recently learnt. It took me about 2 hours to research about the recursive algorithm and write ...
-1
votes
0answers
44 views

How to Implement a Tic Tac Toe board in Python [closed]

The desired board is below: 0 | 1 | 2 ----------- 3 | 4 | 5 ----------- 6 | 7 | 8 NOTE: The code below works ...
3
votes
0answers
37 views

Amateur Python Sudoku Solver

I'm self-taught in Python and would have a lot of room for improvement. I made this basic Sudoku Solver mainly in order to practice the use of Class creation. I would greatly appreciate any feedback ...
1
vote
2answers
73 views

Prime factorization program

Compute the prime factors of a given natural number. A prime number is only evenly divisible by itself and 1. Note that 1 is not a prime number. My solution will catch every prime up to and including ...
-1
votes
0answers
15 views

Read txt file, whose content is not homogenous, into dict format, Python3 [closed]

The content of my_file.txt is in the following style. The actual case has tens of city names. The first column is the city name, ...
2
votes
0answers
49 views

Solo dice game (from Reiner Knizia’s Decathlon)

I'm trying to implement Reiner Knizia’s Decathlon, a set of 10 solo dice games played with 8 dices named after Decathlon events in Olympics. The first event is called "100 Metres". The player divides ...
1
vote
1answer
75 views

Sourcing content from a webpage in an organized manner

I've written a script in python to grab different title and address from different pages of a website. Firstly the script will ...
4
votes
2answers
680 views

2-player dice game

This is a game for two users who roll 2 dice 5 times. If the total of dice is even, the player gains 10 points; if it is odd, they lose 5. If there is a tie after the five rounds, then the users have ...
0
votes
0answers
24 views

Text file combining script - Python - Big Data

I was wondering if anyone could help me come up with a better way of doing this, basically I have text files that are formatted like this (some have more columns some have less, each column separated ...
5
votes
1answer
71 views

Python card game [closed]

I have programmed a card game in Python. It is over 700 lines long. How can I improve the code? There are two players. Every round, each player takes one card from the top of the deck. Those cards ...
1
vote
1answer
58 views

IP Scanning program Python 3

This is the code I made to scan IP addresses. I am new to python and just want to learn how I can optimize it. I know the subprocess is slower than others to IP scanning but if there is a way to make ...
1
vote
1answer
45 views

Function that performs a test of whether a number is greater or less than some expected result

The program that contains the function I'm asking (handle_non_exact_answer) about has several instances of a class Test, with ...
8
votes
2answers
2k views

Restaurant Menu System

I wrote a basic menu application for my intro to python. I'm fairly new, and python does look promising. ...
1
vote
1answer
47 views

Search dictionary for matching values

I have a dictionary self.indexList = {} filled with 3-item-lists values = [lineId, nominalLineId, vertex] for each dictionary ...
0
votes
1answer
41 views

Find minimum and maximum coordinates for a set of points [closed]

I wrote the Python3 code below. This is actually a stripped down version of a bigger project, but in essence it boils down to this code. There are two classes: Point...
1
vote
0answers
15 views

SpaceSaving frequent item counter in Python

In the code below, I implemented the SpaceSaving frequency estimation algorithm described in this paper. Given a parameter eps, the algorithm finds all elements of ...
1
vote
0answers
61 views

Using most constraining variable and least constraining value for N-queens challenge

I was trying to solve the N-Queens(Only 1 solution) problem and I succeeded but my program could only calculate up to N = 47 in a good amount of time so I tried to implement least constraining value ...
0
votes
1answer
52 views

Formatting list of queries in python

I have a file of SQL (actually HiveQL) queries terminated by semicolon (;). I need to obtain ...
0
votes
1answer
49 views

Delete temp files and empty recycle bin

I was wondering if someone could help critique this code I put together. It is supposed to delete all temp files and folders and then empty the recycle bin. I had to make some adjustments because ...
0
votes
0answers
16 views

Python Tkinter Calculator

So this is a fine working calculator, everything is implemented except the period operation. I want to improve the code as much as possible, speaking about the following basics: clean code type ...
1
vote
0answers
20 views

Gomoku game with socket client(multithread) and server

I've write a gomoku terminal game with socket client and server. The main suggestions I am looking for: Am I using the multithread in right way? As when I tried to migrate the terminal game to GUI(...
0
votes
2answers
31 views

Remove the second number from every group of three numbers

I have this simple loop that prints numbers from 0 to 29 (30 in total). I want to "split" the results in threes and remove the middle number. So the first set is 0,1,2 and I only want 0,2. The second ...
-2
votes
1answer
47 views

Parsing of text file to a table [closed]

I was able to make a program that parse my samtools output file into a table that can be viewed easily in excel. While I was able to get the final result, is there a recommended improvements that be ...
3
votes
1answer
50 views

Good randomness in Python code for a lottery-like game

I'm trying to build a lottery-like game in Python 3.6 where a function selects a winner from a participant list where every participant has a winning chance weighted by the value of the tickets they ...
0
votes
1answer
28 views

Make a perfect Split based on absolute difference between max of two arrays

I was solving a problem in Python3 on Codechef website. The problem is this: https://www.codechef.com/problems/PSPLIT Here I've to split an array such that the absolute difference between the maximum ...
2
votes
1answer
81 views

Python tkinter Snake

I have made a little Snake game with Python tkinter. It's my first Python program with one GUI. What can I improve? ...
1
vote
0answers
35 views

Scraping symfonycasts.com using BeautifulSoup

I'm learning python 3.x and I'm still feeling like a newbie. The program below scrape a given course in https://symfonycasts.com/ and creates a file containing all the dynamics download links to all ...
5
votes
0answers
108 views

Secure Password and Passphrase Generator in Python 3

I'm aware that people have implemented password/passphrase generators before, but I still went ahead and wrote my own, which I actually use for my own passwords and/or phrases. By "secure", I mean ...
1
vote
1answer
60 views

Python finding next word permutation with function generator

Learning how to use function generators in Python I practiced with the following code that finds the next permutation of a word and then uses this new word as input for the next one until there are no ...
2
votes
0answers
44 views

450 line Python card game

I have just finished a big project in Python. It is a card game. Here are the rules: There are 30 cards in the deck. Before the game starts, the deck is shuffled. Each card has a colour (red, black ...
4
votes
1answer
59 views

Python program computing some statistics on Scottish geographic areas

This simple script computes some basic descriptive statistics, like mean, standard deviation, kurtosis, etc. on data column imported from a CSV file with use of ...
1
vote
0answers
44 views

Arabic Language lesson program Part 3

This is the third time I am asking for a review of this code (first time can be found here: Arabic language lesson program and the second can be found here: Arabic language lesson program Part 2). ...