15,175 Topics

Member Avatar for
Member Avatar for CurtisEClark

I am building a code that needs to find the average of a set of scores in a list that can have amounts added and removed. I know how to find the average of a list of scores of a fixed number can someone help me on how to find …

Member Avatar for CurtisEClark
0
136
Member Avatar for lrh9

I always wondered how a programmer could efficiently generate a random number from a set* of numbers once and only once. I quickly realized the inefficient solution. Simply generate the number and if it equals one you have all ready generated then regenerate the number. Regenerating the number is a …

Member Avatar for lrh9
0
376
Member Avatar for masterofpuppets

A simple function to return the number of occurances of a letter in a text. An easier way to implement this would be by using a dictionary :) P.S sorry if there already is a code snipped like that somewhere.

Member Avatar for lrh9
1
763
Member Avatar for AutoPython

I can't find a simple command that does this. If there's no command that does this I'm going to spam python.org until they finally agree to put this in the next version of python.

Member Avatar for bumsfeld
0
169
Member Avatar for xaeubanks

I'm writing code in python for a tic tac toe game. I have ran into a problem. can any one help me out. thanks # TIC TAC TOE # Started: 10/19/09 # Ended: still in progress #GLOBAL CONSTANTS X = "X" O = "O" Empty = " " TIE = …

Member Avatar for bumsfeld
0
134
Member Avatar for simpatar

I've got a book for python 2. in school and the problem is that we're programming in 3. which makes it difficult from time to time to get it right, cause you cant just copy the text in the book to the shell. I'm stuck with this ex: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # …

Member Avatar for bumsfeld
0
262
Member Avatar for Gribouillis

This snippet shows a fast and efficient way to cut strings in substrings with a fixed length (note that the last substring may be smaller).

Member Avatar for bumsfeld
1
616
Member Avatar for srk619

i need to write code for two "robots" that will chase each other around the screen. im stuck on a command which is the step(x,y) command which take the (x,y) coordinates of the other robot as a parameter which should just contain "pass" and will be overridden by the subclass. …

Member Avatar for jlm699
0
98
Member Avatar for Kruptein

with the function: list(string) you put every letter from the string in a list, I want to put each 2 letters in a list so If I had the string: ThisIsATestt I want to get a list: ['Th','is','Is','AT','es','tt'] (There will never be a letter alone, so you don't have to …

Member Avatar for jice
0
99
Member Avatar for Snake Hunter

Do you use or abuse list comprehensions? Do you recognise a duck when you see one? Do you unpack when you start assignments? I'm looking to connect with raw 'professionals' but exceptionally talented coders with good academics and who know Python inside out. The company are one of the fastest …

0
41
Member Avatar for rociel

Hello, I'm trying to create a program that calculates the hypotenuse and area of a right triangle. I need to round the hypotenuse to 2 places after the decimal, and one place for the area However, I can't seem to get it to work If I tried c = int(round(math.sqrt(a**2) …

Member Avatar for rociel
0
274
Member Avatar for srk619

how do you write a command that turn left or right at an angle in a superclass is it like this: def left(self): self.position += self.angle return (self.position) its part of Object oriented Python

Member Avatar for vegaseat
0
82
Member Avatar for jmark13

I've gotten some great responses to my questions here, so I'm really grateful for this resource of programmers on this website. I've been working on an algorithm and am almost completed with it, but I'm finding out the very last steps are the most difficult for me because they require …

Member Avatar for masterofpuppets
0
106
Member Avatar for A_Dubbs

Hello everyone, I need some help with instances and loops (I am a very new programmer). Basically, I have a problem where I need to make a program that has a circle move around a window every time the user clicks. This circle is suppose to have a text box …

Member Avatar for Gribouillis
0
382
Member Avatar for vanand

Hi guys, I saw quite a few posts regarding this but I was unable to solve this problem that I am facing. First off, when I do the following in my setup.py, windows=[ { 'script': 'gulhane.py', 'icon_resources': [(1, "icon.ico")] } ], Python crashes and I am unable to run the …

Member Avatar for masterofpuppets
0
102
Member Avatar for jsw24

I am trying to add to an empty list in python and I am having trouble. Ill give an example of the code to see if anyone can help me out.... num = 0 mylist = [] while num < 10: num = num + 1 mylist = mylist + …

Member Avatar for masterofpuppets
0
15K
Member Avatar for lewashby

I more than half way through the book "Python programming for the absolute beginner" 2nd Ed. and things are really starting to get hairy. The book has me to write some code just before or after explaining each part. But I have to really concentrate on the paragraph I'M reading …

Member Avatar for willygstyle
0
300
Member Avatar for Kruptein

I need to split a float in 2, but the split function doesnt work with floats... What is an alternative for this? If I have 2.4 I want to get 2 and 4 In math you've got a function fpart and ipart, but I don't know this is possible in …

Member Avatar for jlm699
0
257
Member Avatar for Kruptein

okay I tried to make a reverse of finding the num value of a letter bu it returns in an error :f [quote]Traceback (most recent call last): File "/home/darragh/Bureaublad/t.py", line 15, in <module> numtolet('A') File "/home/darragh/Bureaublad/t.py", line 6, in numtolet letters['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'] TypeError: list indices must be integers, not tuple[/quote] [code=python]def …

Member Avatar for bumsfeld
0
201
Member Avatar for saikeraku

I want to use a while loop to count up numbers. The output would be something like this: Start: 1 End: 10 Count by: 3 1 4 7 10 Here's my code right now: [CODE] start = int(raw_input("Start at: ")) end = int(raw_input("End at: ")) count = int(raw_input("Count by: ")) …

Member Avatar for cornflakes
0
344
Member Avatar for kenmeck03

I have a this bonus problem for class that I don't have a clue where to start. We have been using the cImage module and the question is: [B]Write a function called DrawTriangle that takes parameters img, x1, y1, x2, y2, x3, y3 and col, where col is a Pixel …

Member Avatar for vegaseat
0
98
Member Avatar for lewashby

I more than half way through the book "Python programming for the absolute beginner" 2nd Ed. and things are really starting to get hairy. The book has me to write some code just before or after explaining each part. But I have to really concentrate on the paragraph I'M reading …

Member Avatar for vegaseat
0
117
Member Avatar for Kruptein

Is there a built-in function to give the value of a letter? what I mean is a=1 b=2 c=3 d=4 e=5 f=6 ... something like letval(a) would give me 1

Member Avatar for Kruptein
0
9K
Member Avatar for jmark13

So the Goal is: given a Nested list that contains 3 elements in each element in the nest, i.e. L1=[[1,2,3],[4,5,6],[7,8,9],[10,11,12]] how can I take a flat list, i.e. L2=[1,2,3,4,11] where if the elements within the nested list, i.e. L1[0], L1[1], etc. intersect with any single element in L2, the element …

Member Avatar for lukerobi
0
191
Member Avatar for lukerobi

How would i do this? [code] import random name = random random.name [/code] I dont cant to use name = random.random, as name is something that could change

Member Avatar for lukerobi
0
163
Member Avatar for lrh9

Out of curiosity, how would you reverse a string's case in Python? Make uppercase characters lowercase and lowercase characters uppercase. Here's the function for the naive implementation. [CODE] #!/usr/bin/env python def flip_case(input_string): temp_list = list(input_string) for index, character in enumerate(temp_list): if character.islower(): temp_list[index] = character.upper() else: temp_list[index] = character.lower() output_string …

Member Avatar for lukerobi
0
251
Member Avatar for edificationtube

I am taking a Python programing class at college, but we've haven't done very many complicated things and I want to develop this program for my wife for one of her music classes: A program that takes mp3s with specific titles, artists/composers, and year written/composed, and outputs random 30 sec …

Member Avatar for lukerobi
0
65
Member Avatar for moedoc10

1) Write a function called divisors that takes two natural numbers m and n, and returns a List object containing all natural numbers (starting from m, and going down to 2) by which n is divisible. For example: divisors(6, 6) should return a List object equivalent to List(6, List(3, List(2, …

Member Avatar for lukerobi
0
104
Member Avatar for Judgment

I can't seem to figure out how to make a program that asks for a Start input, End input, and an amount that the program counts by. My request might not be so clear so here's an example: Start at: 1 End at: 20 Count by: 3 1 4 7 …

Member Avatar for vegaseat
-1
264
Member Avatar for akie2741

how can i extact the photo from this website>>[url]http://www.it.usyd.edu.au/about/people/staff/tomc.shtml[/url] ?

Member Avatar for vegaseat
0
173

The End.