15,190 Topics
![]() | |
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 + … ![]() | |
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 … | |
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 … | |
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 … | |
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: ")) … | |
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 … | |
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 … | |
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 | |
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 … | |
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 | |
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 … | |
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 … | |
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, … | |
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 … | |
how can i extact the photo from this website>>[url]http://www.it.usyd.edu.au/about/people/staff/tomc.shtml[/url] ? | |
Hello all. I been messing around with this port scanner for a while now and can't wrap my head around the speed issue. I tried to create a few threads to help speed it up, but I'm pretty sure I havn't made any progress. Could someone explain why the speed … | |
Hi all, I can convert my .py or .pyw files into EXE no problem. The thing is they only display a console for about a tenth of a second if they have a GUI made with tkinter. If it is a console only program then the exe works fine. Any … | |
Hello, I would really appreciate some help with tkinter. Does anyone know how to change border colour of a widget and if it is possible to display border on just one side of the widget (so for example only the left or bottom border)? I tried to find the answer … | |
Hi im having trouble with a lab that was assigned today. The program has take input from the user which lights are on button 1 controls the NW and SE hallways, button 2 controls the NE and SW hallways, button 3 controls the SE and NE hallways, and button 4 … | |
I'm trying to put in some code that will delete a list from a list. For example if the user decides to delete the first names he would type in 'first' (w/out quotes). however after they input the name nothing prints out. Any suggestions? [CODE] person = ' ' first … | |
![]() | hi currently I am developing a game in python called TankWar, it is basically 1vs1 game style and each player has its own turn. Both players control their respective tanks using the control keys and WASD and they can specify the missile's angle, velocity, tank position. I am using an … ![]() |
Python has some powerful functions, like the math expression evaluator eval(). You can embed this function and others in your Development C++ code. All you need to do, is to download and install the free Python Development Pak and feed the Python code in the form of a string to … | |
hello im currently installed cx_freeze on linux. and want to make win32 exe file on linux by use cx_freeze. and then will distribute on widows platform. one of my problem is ,i can build with no problem. but whenever i run,it something weird error message was show. follow is my … | |
In the program below, how does the value "Poochie" know where to go in the line [CODE]crit = Critter("Poochie")[/CODE] And how do the get_name and set_name functions know when to do their thing, they don't seem to get called or anything? Thanks. [CODE]# Property Critter # Demonstrates get and set … | |
![]() | this is my version of the popular snake game. The snake is controlled by the mouse so be careful when you start :) it grows infinitely long...you should download the apple.jpg file for the game, or graw one of your own just name it apple.jpg and place it in the … |
i'm a beginner,.. please help! here is the question. [I]Download the [U]TICTACTOE[/U] program. Complete it by writing the cellOpen and the winnerCheck functions. This does not require any changes to the rest of the program. Modify the program so that the two players enter their names (no validation is needed) … ![]() | |
I'm having trouble with a program I'm writing and any help would be greatly appreciated. I'm supposed to use an if statement to return an error message if the values entered aren't either the strings 'on' or 'off'. Right now I have [CODE]if (b1 and b2 and b3 and b4 … | |
Hi, I want to sort a tuple consisting of two floats and one array by the absolute value of the first float in reverse order. What I did is the following: [CODE]from numpy import * test = [(-0.02, 100.2, array([1, 0, 0])), (-4.02, 300.4, array([1, 1, 0])), (3.57, 503.7, array([1, … ![]() | |
If I do this [CODE]mylist = [1,2,3,4] a = mylist a[0] = 'hello' >>>mylist output : 'hello',2,3,4 [/CODE] I find that the value of mylist has changed to 'hello',2,3,4 So my question is.. If I assign one variable as a value of another (like saying a is mylist), then is … | |
hi I am a complete novice and have written the following code and it work as required, with the exeption of the text being in a tidy format when printed. The origDict.txt has been exported in a fixed file format, and I am trying to acheive a fixed file layout … |
The End.