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

Newborn pythonic calculator

Let me start off by saying that I have several years of experience in Java, but now I need to learn Python, so I decided to make a calculator as it also is a community challenge. Please review the ...
18
votes
6answers
6k 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 ...
18
votes
3answers
5k views

Password Strength Detector

I'm just a beginner in Python. I wrote a simple code that detects the user's password strength, but I feel that it isn't very efficient. How can I improve it? ...
18
votes
5answers
3k views

Flipping coins performance

This is the Flipping coins problem on CodeChef: There are \$N\$ coins kept on the table, numbered from \$0\$ to \$N - 1\$. Initially, each coin is kept tails up. You have to perform two types of ...
18
votes
4answers
7k views

User login database intended for beginners

I have been working on a small project intended for helping beginner Python programmers getting an idea of what a real project could be like (as opposed to programming exercises and such). This ...
18
votes
6answers
3k views

Comma Code - Ch. 4 Automate the Boring Stuff

I am new to programming and currently learning Python using "Automate the Boring" by Al Sweigart. I've just completed the "Comma Code" task in Chapter 4 and would like some ...
18
votes
6answers
5k views

Rock, Paper Scissors game in Python

I wrote a simple Rock, Paper Scissors game in Python for class. As a beginner, I would like some input as to how I could abstract or make my code smoother. I feel like the repeated use of ...
18
votes
3answers
3k views

Providing advice based on user's favourite YouTuber

I have written this code which provides advice based on user's favourite YouTuber. I wonder if there is a better way to do absolutely any of it. Also, if there is any way to optimise it or if there is ...
18
votes
2answers
2k views

Simple game of Hangman in Python

I'm starting out with learning how to program in Python and created a Hangman game. I think there is a lot of unnecessary code but I am not sure how to improve it. I wanted to avoid using global ...
18
votes
2answers
3k views

Python bot to answer mathematical questions for a remote server

The MSP Tech Club puts on an annual CTF, available here. I've worked on a solution but was wondering if there's a better way to write it or if I have any particular bad habits showing themselves? The ...
18
votes
1answer
29k views

Adjacency List Graph representation on python

I began to have my Graph Theory classes on university, and when it comes to representation, the adjacency matrix and adjacency list are the ones that we need to use for our homework and such. At the ...
18
votes
1answer
15k views

Python Executer that kills processes after a timeout

Imagine you want to run a bunch of tasks in parallel, but you can't be sure that all of your tasks will eventually terminate or rather decide to eat up all your memory and CPU time. This should be ...
17
votes
4answers
10k views

20 Ways to do Random Sampling

Here is a (small project) code for practicing Python, it comprises 20 variety of functions that each works to return \$n\$ random samples from a set of data. The code mostly uses the ...
17
votes
4answers
4k views

Beginners Python Hangman Code

I just started learning about Python at school and decided to start this little project with the basic knowledge I have. Most of the code is pretty lengthy and I know there are probably more efficient ...
17
votes
4answers
21k views

Bitcoin wallet address and private key generator

I wanted to learn how to create a Bitcoin wallet in code. I used as reference this guide which has code examples in JavaScript. I wrote my implementation in Python. Here is the resulting code: ...
17
votes
2answers
3k views

Discount Pokemon Battles

I have decided to create a discount Pokemon battle simulator using a module called guizero. It's basically a wrapper for Tkinter that is easier to learn. Recently, ...
17
votes
2answers
2k views

Yandex programming contest: Alarms

I've tried to solve this challenge about 4 hours during the contest, but all my attempts exceeded the time limit. I tried to solve it with min-heap, but can't pass all the tests. How it can be solved ...
17
votes
4answers
34k views

RSA algorithm implementation in Python 3

First, a reminder of the RSA algorithm and what my program implements: Take two distinct, large primes p and q Ideally these ...
17
votes
2answers
20k views

Python Back-Up Script

I wrote this script to backup some important files. It backs up the files to a local folder as well as to an external hard drive. It creates a new subdirectory which has its name constructed with ...
17
votes
2answers
286 views

Gimme some random passwords

pwgen is a nice password generator utility. When you run it, it fills the terminal with a bunch of random passwords, giving you many options to choose from and ...
17
votes
1answer
2k views

Rock Paper Scissors Lizard Spock

I got some good feedback from the last code I posted which I have incorporated in to this project (enum, try, f string formatting), so again just looking for some feedback on how the code could be ...
17
votes
2answers
2k views

Split mp3 of album into individual tracks

Recently, I've been transferring some of my old vinyl records to MP3 files. One of the things I did to make some progress was to automate things, so I initially set things up so that it would record ...
16
votes
6answers
11k views

Verifying IPv6 addresses

While trying to learn Python I stumbled upon a question which asks you to write a code that is able to take an input and verify it to see whether it meets the IPv6 Criteria. I wrote the following ...
16
votes
11answers
3k views

Check if array has the same number of even and odd values in Python

Task: Complete the following function that determines if the number of even and odd values in an list of Integers is the same. ...
16
votes
7answers
3k views

Stack data structure in Python 3

I have implemented a stack in Python 3, and it works well. If anything needs to be improved, I would appreciate the criticism. ...
16
votes
5answers
34k views

Reversing a String in Python

I have a simple function that takes a string and reverses it: ...
16
votes
5answers
5k views

Python 3: Why is my prime sieve so slow?

I've implemented the sieve of Eratosthenes in Python 3 as follows: ...
16
votes
2answers
2k views

Translate English to Pig Latin

This is a program for converting English to the pseudo-language Pig Latin. Not the strictest form of Pig Latin but it most likely will accurately output an argument in Pig Latin. I got the idea from a ...
16
votes
3answers
2k views

Newton-Pepys, common birthdays and other probability simulations in Python 3

I have been learning Probability from Statistics 110 and trying to simulate problems that have an unintuitive answer ...
16
votes
2answers
2k views

Car computer in python / GPS tracking

I have an old car that I use for long distance driving and have coded an onboard computer based on a Raspberry Pi 3 and a few other modules. It's my first project in Python and while I've already ...
16
votes
6answers
1k views

Storytelling program: Gathers stories from certain popular story websites/formats and reads them aloud

Audiobooks make my life easier when I have idle ears and a mind free to wander, but something better for my eyes to do. This program is one of my more recent efforts to allow most of the stories ...
16
votes
1answer
1k views

Barnsley's Fern

I recently watched the Numberphile video entitled 'Chaos Game', and in that they showed how Sierpinski's triangle could be made from random numbers. But at the end of the video, they showed how this ...
16
votes
2answers
2k views

ECDH implementation in python

I wrote an implementation of elliptic curve Diffie-Hellman key exchange in python. I would like to know if I could make it faster, cleaner or more secure: ...
16
votes
2answers
403 views

MNIST Deep Neural Network in TensorFlow

I have been working on this code for a while and it gave me a lot of headaches before I got it to work. It basically tries to use the MNIST dataset to classify handwritten digits. I am not using the ...
15
votes
8answers
8k views

Python program to take in two strings and print the larger string

I have written a Python program to take in two strings and print the larger of the two strings. Here is my code - ...
15
votes
8answers
7k views

Program for finding longest run of zeros from a list of 100 random integers which are either 0 or 1

I have written an answer to this question on Stack Overflow. To make it easier for you, I have copy-pasted the main question below. Write a program that generates 100 random integers that are ...
15
votes
5answers
3k views

Project Euler # 25 The 1000 digit Fibonacci index

The Fibonacci sequence is defined by the recurrence relation: Fn = Fn−1 + Fn−2, where F1 = 1 and F2 = 1. Hence the first 12 terms will be: F1 = 1 F2 = 1 F3 = 2 F4 = 3 F5 = 5 ...
15
votes
6answers
3k views

Project Euler, problem # 9, Pythagorean triplet

Project Euler #9, Pythagorean triplet is A Pythagorean triplet is a set of three natural numbers \$a < b < c\$ for which \$a^2 + b^2 = c^2\$. For example, \$3^2 + 4^2 = 9 + 16 = 25 = 5^...
15
votes
5answers
5k views

Program to print a Python list as “a, b, and c”

I am a beginner (with zero Python experience) working through the book Automate the boring stuff with Python. At the end of Chapter 4, the author provides a review problem. I was supposed to write a ...
15
votes
5answers
3k views

Performance for simple code that converts a RGB tuple to hex string

I'm rewriting a full color Mandelbrot Set explorer in Python using tkinter. For it, I need to be able to convert a Tuple[int, int, int] into a hex string in the ...
15
votes
3answers
3k views

A Caesar cipher in Python3

This code basically just does a Caesar cipher on the contents of the variable "s" with a shift of 1. Sorry if the comments on the code don't explain it well. I'm quite new to Python and I'm not very ...
15
votes
4answers
1k views

A top-like live monitor for virsh/kvm/qemu VM's

I needed a tool to monitor VM's running on my server in relatively real-time (similar to top or the many variants out there). The main things I need to keep track ...
15
votes
4answers
6k views

Checking if two strings are anagrams in Python

The code written in Python 3.6 mostly using Python's built in functions sorted and len. First I'm checking for the edge case that the two given strings are not of ...
15
votes
5answers
3k views

Markov-chain sentence generator in Python

I wrote a Markov-chain based sentence generator as my first non-trivial Python program. I mainly used C before, so I probably have ignored a lot of Python conventions and features, so any advice would ...
15
votes
3answers
3k views

class fizzbuzz():

This is now an iterative review. The next iteration can be found here. Yep. Fizzbuzz in Python. I've been coding in Python for all of 90 minutes. Thoughts? Program Flow Take a ...
15
votes
2answers
1k views

Calculate the Degrees of a Clock Hand Based on Input Time

I'm a novice programmer. I started with Java years back and now mostly use VBA to automate tasks for my internships. I want to graduate from VBA and get into Python/R to properly automate tasks. The ...
15
votes
2answers
717 views

Counting density of Python code

I created a tool to examine Python 3 source code. It measures the density of program. More info in docstring (to not reinvent the wheel). What could be done to increase its usability? Any edge cases ...
15
votes
1answer
1k views

Downloader in Python

I wrote this code in python and it works fine for me but I do know that the code is not optimised and a lot of refactoring needs to be done. So I need review on how this code can be improved. I ...
15
votes
3answers
6k views

Number of Islands in a 2d grid

Recently, I've solved this "Number of Islands" problem on LeetCode, the solution was accepted by the LeetCode OJ. Problem Description Given a 2d grid map of '1's (land) and '0's (water), count the ...
15
votes
2answers
1k views

Project Euler #22 - Names Scores

I programmed Problem #22 from Project Euler in Python. It works but I want to know if it really is pythonic enough. Using names.txt (right click and 'Save Link/Target As...'), a 46K text file ...

1
2
3 4 5
92