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
117 votes
6 answers
16k views

How clean is my snow?

I just wrote a snow animation in Python. I think this is fairly clean but I have a few things that I don't like. ...
user avatar
  • 1,680
44 votes
3 answers
2k views

We'll be counting stars

Lately, I've been, I've been losing sleep Dreaming about the things that we could be But baby, I've been, I've been praying hard, Said, no more counting dollars We'll be counting stars, yeah we'll be ...
user avatar
39 votes
4 answers
5k views

Beheading of knights, who survives?

We have a round table of n knights, where n is some positive integer. These have failed to satisfy the expectations of the mad ...
user avatar
38 votes
6 answers
21k views

Random IP Address Generator

randip.py I know there are probably better, easier ways to do this. It was just a bit of a learning exercise for the sake of familiarising myself with Python. It takes a single argument (positional ...
user avatar
  • 729
37 votes
7 answers
7k views

Increase performance creating Mandelbrot set in python

I created a program in python that generates an image of the mandelbrot set. The only problem I have is that the program is quite slow, it takes about a quarter of an hour to generate the following ...
user avatar
  • 579
36 votes
5 answers
6k views

Beginner's snake game using PyGame

I am a complete beginner when it comes to programming and writing games and this is my first ever game. I made it with python 3 using pygame library. I would ...
user avatar
36 votes
2 answers
4k views

Markov country name generator

I wrote a country name generator in Python 3.5. My goal was to get randomized names that would look as much like real-world names as possible. Each name needed to have a noun and an adjective form (e....
user avatar
  • 465
35 votes
3 answers
2k views

Bush Wanderer - code intended for teaching

I am teaching computing to an AS class and this was their assignment: Bush Wanderer Task 1 Create a 5x5 grid of hashes(#) where the player is an ...
user avatar
33 votes
7 answers
9k views

Tiny image scraper for xkcd.com

This came out on the spur of the moment, as a quick and dirty tool to have the job done. This is a simple image scraper for immensely popular and legendary comic website inspired by a Python Easter ...
user avatar
  • 1,286
32 votes
7 answers
7k views

Car crash reaction time

In physics class we are doing an investigation thing. Some of the numbers might seem plucked out of thin air but they aren't. The maths is right(I think) I just want some feedback on the code. ...
user avatar
  • 321
32 votes
8 answers
5k views

Project Euler Problem 45

As a self-teaching Python beginner for almost 4 months, I have mostly been doing online challenges including Project Euler problems. Problem 45 asks: Triangle, pentagonal, and hexagonal numbers ...
user avatar
28 votes
5 answers
6k views

Fishing simulator

I'm new to Python, for a school project I created a "fishing simulator". Basically, it is a use of random. I know that my code is repetitive towards the end, but I don't know how to simplify it. <...
user avatar
  • 554
28 votes
5 answers
6k views

A first "Hangman" game in Python

I am new to Python (it's my first language), been coding for a couple of weeks now. I have already made a couple of simple scripts to download and manipulate some financial data, but lately I thought ...
user avatar
  • 381
28 votes
4 answers
7k views

Sieve of Eratosthenes - Python

I've been doing a lot of Project Euler lately and just wanted to make sure my implementation was as good as it could be. Does anyone have any suggestions to speed this up? ...
user avatar
  • 437
27 votes
7 answers
8k views

Python program to calculate GCD

...
user avatar
27 votes
4 answers
2k views

1, 2, Fizz, 4, Buzz: FizzBuzz

I just recently started working on python (interesting language, actually), and, as I always do when I learn a new language (with the exception of BrainFuck, that's too hard), I write a FizzBuzz ...
user avatar
  • 9,414
27 votes
3 answers
736 views

Calculate questions per day on CodeGolf.SE

I wrote a short script in Python 3 that connects to the Stack Exchange API, gets all questions on Programming Puzzles & Code Golf over the past two weeks, and determines the average number of ...
user avatar
  • 544
27 votes
2 answers
686 views

Telling fibonaccis to the user

Though this program tells the truth (unless you change the source code), it does tell Fibonacci numbers, depending on the user's input. Keeping in mind of all (or most) of the feedback given from ...
user avatar
  • 9,414
26 votes
6 answers
26k views

Monte Carlo pi calculation

In order to learn the basics of Monte Carlo I calculated pi with it. I also wrote an explanation of the reasoning behind the code. Down here you can see the circle with random points that I simulated ...
user avatar
  • 27.2k
26 votes
2 answers
6k views

Printing 1,000,000 numbers in 1 sec. in Python

Here's a fairly simple task from CSES Problem Set - Permutations 1070 that reads: A permutation of integers 1,2, …, n is called beautiful if there are no adjacent elements whose difference is 1. ...
user avatar
  • 507
26 votes
3 answers
54k views

BFS Implementation in Python 3

...
user avatar
  • 363
26 votes
3 answers
610 views

Python review_generator

Given a Python file containing a Python script written with bad style, this script will output a review adressing its problems. ...
user avatar
  • 27.2k
26 votes
4 answers
2k views

Translating from English to Entean

I wrote a python script that converts English to Entean language from an anime called "The Devil is a part timer". I am sloppy at coding and know that the script can be made better. In the anime, the ...
user avatar
26 votes
2 answers
3k views

Send daily email alerts of the Bitcoin Price

My script sends daily alerts of the bitcoin price to my inbox. I am using CoinDesks API, and the following libraries: requests==2.18.4 schedule==0.5.0 and gmail sender: https://github.com/...
user avatar
26 votes
2 answers
1k views

Spin-the-bottle-like game

I've started coding about 3 weeks ago, just for fun and maybe practical uses later. My GF dared me to make a PGM that would replace this dice game where you roll two dice, one with body parts and one ...
user avatar
  • 325
25 votes
4 answers
5k views

Formatting 3 integers (hours, mins, secs) to `00:00:00`?

I have this at the moment, wondering if there's a cleaner way to do it or if this is already as compact as it gets. ...
user avatar
  • 371
25 votes
6 answers
8k views

Simulating an OOP Coffee Machine

Today I learnt the basics of OOP. I have tried to apply them to this coffee machine project. However I'm still a beginner, and so I feel my code can be improved. Are there any tips, trick or other ...
user avatar
  • 1,180
25 votes
4 answers
6k views

Functions to convert camelCase strings to snake_case

I have written two functions, one actual and one helper, to convert camelCase strings into snake_case strings (I call it joint-lower case). Any ideas for improvement are welcome. ...
user avatar
25 votes
1 answer
1k views

Backpropagation in simple Neural Network

I've been working on a simple neural network implemented in python. Currently, it seems to be learning, but unfortunately it doesn't seem to be learning effectively. The graph below shows the output ...
user avatar
  • 269
24 votes
4 answers
2k views

My first calculator

I've just wrote my first code, which is basically a calculator. Please rate it and suggest improvements (keeping in mind that I'm a beginner). ...
user avatar
24 votes
2 answers
5k views

Zork-like text adventure w/ Python

I've been using Python for around 3 months and decided to make a simple text adventure game for fun and to exercise a lot of ideas I've been learning about. I've just recently learned about classes ...
user avatar
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 ...
user avatar
23 votes
1 answer
2k views

Simple Morse code interpreter

This is a simple Morse code interpreter with a CLI. It's a naive table-lookup implementation, and uses my-py for type checking. It automatically detects the input (English or Morse) and converts ...
user avatar
  • 335
22 votes
7 answers
7k views

Converting JPG images to PNG

I had a task to convert some JPG images into PNG format using Python. I successfully did it but I was wondering if somehow I could make my code better than my current one. Code - ...
user avatar
22 votes
6 answers
5k views

Add 'ing' or 'ly' suffix to a string

I have been practising Python Practice questions and came across this question: Write a Python program to add 'ing' at the end of a given string (length should be at least 3). If the given string ...
user avatar
22 votes
3 answers
2k views

Pythons Around the Rose

Based off my Java Petals Around the Rose, I thought it would be good practice to write something again in a different language. Because the language is Python, I named it "Pythons Around the Rose", ...
user avatar
  • 9,414
22 votes
5 answers
6k views

Battleships game in Python

The idea is, you enter an amount of ships, for example 10. It will then place 10 ships on a 10x10 grid (0-9). You may enter a coordinate, and it will tell you if it is a hit or a miss. A simplified ...
user avatar
21 votes
8 answers
39k views

Program to check if a date is valid or not

I am a novice programmer and am currently learning Python programming by myself through a book. I stumbled upon a question in a chapter and it took me 2 days to figure out a solution for it. Although, ...
user avatar
21 votes
4 answers
7k views

System that manages employee data for managers

This code is for an employee management system. The goal that I am trying to reach is to allow managers to access data of their employees more easily. The data that is entered is saved to a CSV file ...
user avatar
21 votes
2 answers
38k views

Turn-based battle simulator

I am embarking on the daunting journey of learning to program on my own two feet and have created a turn-based battle simulator (think Pokémon). The idea came from here. It's very crude and could ...
user avatar
20 votes
9 answers
4k views

Approximating constant π² to within error

This function takes as input float error and approximates constant π² to within error by computing this sum, term by term, until the difference between the new and the previous sum is less than error. ...
user avatar
20 votes
6 answers
8k views

Python function to map True, False, and None to symbols for display

I have a use case in which I need to check whether a given value is explicitly True or False: ...
user avatar
20 votes
6 answers
4k views

Password validator

I have made a password verification "program" which takes user input and checks whether the password is valid or not. Based on that, a reply is printed. ...
user avatar
  • 303
20 votes
5 answers
6k views

Count Even Digits In Number

I was asked to complete this CodeStepByStep problem. Here's a quick summary: Write a function named count_even_digits that accepts two integers as parameters ...
user avatar
  • 9,587
20 votes
5 answers
3k views

Generating a random MAC address

I need the ability to generate random MAC addresses, so I wrote up a little function that does that: ...
user avatar
20 votes
4 answers
43k 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 ...
user avatar
20 votes
2 answers
336 views

Select external resource to feed data into a processing function

I wrote an application a while back to plan and manage drones races. (Well, it could be anything with identification numbers going through checkpoints.) At that time, communication between the gates (...
user avatar
19 votes
6 answers
5k views

Premier League simulation

I've created a simulator for the Premier League, which takes in all of the 20 teams and plays them against each other, recording the results and outputting a table at the end. The skill levels are ...
user avatar
19 votes
4 answers
3k views

How can I make this tax calculator cleaner?

I recently created this Income Tax calculator based off your filing status (Single, or Married Filing Jointly) and which tax bracket you fall into for the 2020 tax year, taking into account the ...
user avatar
  • 191
19 votes
4 answers
1k views

Optimising a list searching algorithm

I've created the following code to try and find the optimum "diet" from a game called Eco. The maximum amount of calories you can have is 3000, as shown with MAXCALORIES. Is there any way to make ...
user avatar
  • 293

1
2 3 4 5
102