Search Results
Search type | Search syntax |
---|---|
Tags | [tag] |
Exact | "words here" |
Author |
user:1234 user:me (yours) |
Score |
score:3 (3+) score:0 (none) |
Answers |
answers:3 (3+) answers:0 (none) isaccepted:yes hasaccepted:no inquestion:1234 |
Views | views:250 |
Code | code:"if (foo != bar)" |
Sections |
title:apples body:"apples oranges" |
URL | url:"*.example.com" |
Saves | in:saves |
Status |
closed:yes duplicate:no migrated:no wiki:no |
Types |
is:question is:answer |
Exclude |
-[tag] -apples |
For more details on advanced search visit our help page |
Python is an interpreted, general-purpose high-level programming language whose design philosophy emphasizes code readability. Use the python tag for all Python related questions. If you believe your question may be even more specific, you can include a version specific tag such as python-3.x.
2
votes
1
answer
152
views
Turtle language parser in python 3
I a creating a program to parse a simple language in a text file and delegate those actions to python-turtle. …
6
votes
Write a program that asks the user to input 10 integers, and then prints the largest odd num...
Your code is good, but could use a few improvements:
The while loop
You could just do this with a for loop:
for i in range(10):
...
Your way of finding the largest (odd) number
This is impracti …
3
votes
1
answer
92
views
Finding the number of "block chains" that are a certain length and begin with a certain string
I'm currently practicing for the british informatics olympiad by doing past papers.
I was doing question 3 of the 2019 paper:
A set of children’s blocks, each illustrated with a single different lett …
0
votes
1
answer
1k
views
Drawing a tilemap using python and pygame
I am creating a tile-map in python using pygame. The code I have (see below) works OK, but I was wandering if there were any improvements. …
5
votes
chess game: loading images for the rooks
First of all; rook_image, rook_image_2, black_rook, black_rook_image_2, rook_image_2, etc. can be improved, although they are somewhat descriptive. Something like this might be better:
SCALE = ...
OFF …
8
votes
Checking if a chessboard presented as a dictionary, is a valid chessboard
You might want to name your functions in snake case, as it is the convention for python. (is_valid_chess_board not isValidChessBoard.) …
3
votes
Accepted
Text based naval game
Your code is good, but there are a few improvements to be made.
First, the repeated code. You repeat the same code for player1 and player2, when you could just use a method:
# inside the Ship class
d …
4
votes
1
answer
165
views
Roman numerals look and say sequence
I wrote this python code to attempt to solve this:
ROMAN_NUMERALS = {
1000: "M",
900: "CM",
500: "D",
400: "DC",
100: "C",
90: "XC",
50: "L",
40: "XL",
10: "X", …
4
votes
1
answer
418
views
Simple encryption/decryption program using python (and tkinter)
I am creating a simple program with a GUI to encrypt/decrypt text using different ciphers. I tried to make it so that it would be easy to add new ciphers.
This is my code:
import tkinter as tk
ALPHA …
2
votes
1
answer
118
views
Pong using pygame module
I made a game in Python where you play Pong against an AI. As I am quite new to pygame, I would be grateful to hear any possible improvements. …
3
votes
1
answer
132
views
Python tic-tac-toe using tkinter
Note that the actual tic-tac-toe logic is being done by the python-tictactoe library. …
7
votes
Separating a String of Text into Separate Words in Python
While your program is functional and solid, there are plenty of improvements to be made.
How I would solve it.
A better way to solve this would probably be:
import re
test_string = "she sat down bes …
1
vote
simple Rock, paper, scissors game
This code is good, but it has a few problems.
Review
The options
Instead of handling rock, scissors and paper as strings, I'd use an enum:
from enum import Enum
class Options(Enum):
ROCK = 0
…