14,952 Topics
| |
An example how to use Tkinter's OptionMenu() as a combobox to allow one year to be selected from an option list of let's say the past 15 years. | |
don't work this: bg_fon2 = PhotoImage(file='2.GIF') from tkinter import* import random root = Tk() root.geometry("896x626") canv = Canvas(root, height = 626, width = 896) bg_fon = PhotoImage(file='fon.GIF') canv.create_image(0,0,image=bg_fon,anchor='nw') class Fish: image = 0 coor = 0 direct = 0 real_img = 0 obj = 0 canv = 0 def fiish1(): … | |
hii I have a list having m1 m2 m3........ m922 and in each there are a1 a2 a3 a4 are there like m1=a1 a2 a3 a4 a5 a6 m2=a1 a2 a3 a4 a5 a6 m3=a1 a3 a5 a7 a8 a2 etc and i want this as m1=a1 a2 a3 a4 … | |
Is this considered good form when writing cross-platform code? #! /usr/bin/env python3 And how about this? if __name__ == "__main__": main() I've reviewed some recent sample snippets and not all of them use the shebang and the conditional main call, so I wasn't sure whether that is still considered good … | |
Hi guys Just started to get into Python so this site seems liek a gtreat resource for hints and tips. Nice to meet you all. Ben | |
I'm learning python (and programming in general) through Runestone Interactive. What do people think of that site as a place for beginners to learn python? Also, is there any harm in trying to learn perl and web design languages at the same time? I'm concerned about becoming confused. | |
Hello again :) I'm trying to define a simple "spelling correction" function that takes a string and sees to it that 1) two or more occurrences of the space character is compressed into one, and 2) inserts an extra space after a period if the period is directly followed by … | |
I am trying to get the following ENUM to work, but it's not working. Any help is appreciated. class Colour(Enum): WHITE = (255,255,255) BLACK = (0,0,0) RED = (215,45,45) BLUE = (45,87,214) YELLOW = (230,223,48) GREEN = (45,194,64) Using it: `Colour.BLACK` Error: /System/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7 "/Users/blooop/main.py" Traceback (most recent call last): File … | |
num = int(input("Enter a number: ")) if num==0 or num<0: continue else: if num > 1: if (num % i) == 0: print(num,"is not a prime number") print(i,"times",num//i,"is",num) break else: print(num,"is a prime number") | |
I've to write a function that takes a list of English words and returns a list of Swedish words. For example, {"merry":"god", "christmas":"jul", "and":"och", "happy":gott", "new":"nytt", "year":"år"} used to translate English into Swedish. def translate(a): a = {"merry":"god", "christmas":"jul", "and":"och", "happy":"gott", "new":"nytt", "year":"år"} for k, v in a.iteritems(): print k,v … | |
I'm a beginner to Python and I decided to make a permutation finder program. Have fun and don't question the name. :) | |
Hello, I'm trying to define a function that takes an integer 'n' and a character and returns a string, 'n' characters long. I'm totally lost and I've nothing. I read in a forum "".join might help. But that too is beyond perceivable for me at this moment. I do have … | |
Hello, I've been trying to write a function that takes a value (i.e. a number, string, etc) x and a list of values a, and returns True if x is a member of a, False otherwise. This is the script I could think of. I'm not even sure what might … | |
I"ve been working on this dice game for the past few days. I made sure the game itself worked properly then I added a draw dice function that would show you the dice that were rolled on the canvas. I needed a continue button to make the rest of the … | |
I'm actually helping my wife. She's learning Python. Me? VB.net and C# are my preferance. So I try to help her. All she wants to do is paint a command button, use this to launch another program written in python. I have spent the past few days trying to find … | |
I'm trying to learn scripting in Python. So, I started using an exercise and it had this question for me. Define a function that computes the length of a given list or string. And I can't use the built in function len(). I tried the code below and I can't … | |
Hi I installed a different version of Python but how to choose edit with IDLE to open scripts in python 2.7 or python 3.2 on my Windows desktop? | |
For those of you who are inquisitive, here is a little Python program to approximate the value of pi to 77 digits. You can easily go further, just change the value n in range(n+1). | |
Recently I've been fooling around with some fun mathmatic (dont knwo if that is even a word) stuff. I recently took on the task of trying to calcualte PI. I have a very simple program in python that does this for me: import math from datetime import datetime top = … | |
I have a computer science project and it has all to do with list and such could someone please help me with it! | |
I've been messign around with Python a little recently. Though I now want to import one of my .py files into my "main" file, but I get an `"module" object is not callable` error. How do I actually do this then. My files: KeyGenerator.py main.py Code I use to import: … | |
Im personally learning how to program in python though I do know of other languages. Is Python the best to learn off? | |
Hello Guys, i am new to python, for a assingment i need to create a game (binary puzzle). im having problems to start with creating the bord, i saw some examples of creating a bord game on this forum but it didnt worked out for me. i want to create … | |
This snippet shows you how to animate a dice roll with the Tkinter GUI, useful for many games that require a dice to give a random number from 1 to 6. An interesting use of Tkinter's grid(), grid_forget() and after() functions. | |
A series of different parts of sentences will be randomly put together to come up with new interesting sentences. using with Random, Integers, Print, Strings, Breaks, Functions, For, Range | |
I am trying to write a program that graphically presents three doors and ask the user to choose the “special” door (randomly selected by the program). If the user correctly chooses the special door, it’s a win. If either of the other two non-special doors is selected, it’s a loss. … | |
I was testing this in prompt mode: import re def checkurl(url): check = re.match(r'^(:?https?://)?[^\/#?&]+\.[^\/#?&]+.*$',url) if check == None: print “NNOOOOOO!!!!” else: print “YESSSS!!!!!” checkurl("javascript:void(0);") checkurl("/account/general?ru=https%3a%2f%2fwww.bing.com%3a443%2fsearch%3fq%3dukraine%2bcrisis&FORM=SEFD") checkurl("/?FORM=Z9FD1") checkurl("http://choice.microsoft.com") I have no idea why this won't work. Ignore the regex its only supposed to weed out relative paths and fragments of strings. … | |
| Hello folks, I am currently in 2nd year of Masters Degree and I am expected to develop a project this year from the given topics. I find Command Based text editor like vi fascinating as others were boring. So, here is the project definition. **In this project you are expected … |
* * * * * * * * * * * * * * * * * * * * * * | |
Hey, guys! Newbie here. =) I try to reverse an image but an error came and i don't know why :/ This is the error: Traceback (most recent call last): File "C:/Users/Florian/Documents/ISN/S10/défi11.py", line 10, in <module> im.putpixel((x,600-y),(p[0],p[1],p[2])) File "C:\Python27\lib\site-packages\PIL\Image.py", line 1267, in putpixel return self.im.putpixel(xy, value) IndexError: image index out … |
The End.