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
126 votes
6 answers
17k 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. ...
J Atkin's user avatar
  • 1,790
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 ...
Simon Forsberg's user avatar
40 votes
6 answers
22k 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 ...
voices's user avatar
  • 749
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 ...
N3buchadnezzar's user avatar
38 votes
7 answers
8k 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 ...
Ian's user avatar
  • 589
38 votes
2 answers
5k 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....
DLosc's user avatar
  • 485
37 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 ...
RandomDude_123's user avatar
36 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 ...
Toby Adams's 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 ...
baduker's user avatar
  • 1,348
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. ...
Danny's 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 ...
ifsoMarcus's user avatar
29 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? ...
Igglyboo's user avatar
  • 447
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. <...
myang0630's user avatar
  • 564
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 ...
Mike's user avatar
  • 381
28 votes
6 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 ...
TheCoffeeCup's user avatar
  • 9,454
27 votes
7 answers
8k views

Python program to calculate GCD

...
Delfin Biju's user avatar
27 votes
6 answers
12k 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 ...
Anonymous's user avatar
  • 1,204
27 votes
3 answers
747 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 ...
Alex A.'s user avatar
  • 544
27 votes
2 answers
702 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 ...
TheCoffeeCup's user avatar
  • 9,454
26 votes
6 answers
27k 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 ...
Caridorc's user avatar
  • 27.4k
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. ...
Bor's user avatar
  • 507
26 votes
3 answers
56k views

BFS Implementation in Python 3

...
Apollo's user avatar
  • 363
26 votes
3 answers
644 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. ...
Caridorc's user avatar
  • 27.4k
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 ...
user3620828's 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/...
Walid Mujahid وليد مجاهد's 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 ...
LuukV's user avatar
  • 325
25 votes
4 answers
7k 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. ...
DavidPH's user avatar
  • 371
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. ...
Richard Neumann's 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 ...
penalosa's 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). ...
Inteemum Ahsan's user avatar
24 votes
2 answers
7k 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 ...
digital_drako's 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 ...
Longroadahead's 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 ...
bsima's 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 - ...
Praguru 14's user avatar
22 votes
6 answers
8k 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 ...
FoundABetterName's 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", ...
TheCoffeeCup's user avatar
  • 9,454
22 votes
5 answers
7k 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
43k 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, ...
mathlover92's 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 ...
RonsJurisdiction's user avatar
21 votes
2 answers
40k 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 ...
acardnell24's user avatar
21 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
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. ...
Akhil Ghosh's 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: ...
Richard Neumann's 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. ...
morloq's user avatar
  • 303
20 votes
5 answers
7k 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 ...
Linny's user avatar
  • 9,948
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: ...
Carcigenicate's user avatar
20 votes
4 answers
2k views

CodeReview question markdown downloader

This is an update to my earlier question From Q to compiler in less than 30 seconds. As with that version, this Python script automatically downloads the markdown from any question on Code Review and ...
Edward's user avatar
  • 65k
20 votes
2 answers
344 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 (...
301_Moved_Permanently's user avatar
19 votes
6 answers
7k 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 ...
Linny's user avatar
  • 9,948
19 votes
6 answers
6k 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 ...
woody101298's user avatar

1
2 3 4 5
107