Tagged Questions
0
votes
0answers
8 views
how do i round to 3 decimal places
My code shows 3 decimal places but in the 3rd decimal place its always a 0. What can I do to fix this to where it gives me the third number.
print ('Radius Area Circumference')
for Radius in ...
0
votes
0answers
14 views
Drawing the Dominica Flag (Not Dominican) Using Python Turtle
I am trying to draw the Dominica Flag (not to be confused with dominican flag) using python turtle. I currently have everything in the code except for the bird (which I have no idea how to do either). ...
-1
votes
2answers
18 views
How do i get the print outs to show up correctly under the final output
Im trying to create a chart for radii that the output looks like this.
Radius Area Circumference
1.000 3.142 6.283
2.000 .... ....
...
0
votes
1answer
23 views
python import ttk and * from tkinter
i'am new in tkinter.
i see video tutorials to learn it.
in this video he import from tkinter with this code:
from tkinter import *
from tkinter import ttk
i know first line mean import all class, ...
0
votes
2answers
18 views
How do i get the prints under main to show up in final output
Im trying to create a chart for radii that the output looks like this.
Radius Area Circumference
1.000 3.142 6.283
2.000 ... ...
...
0
votes
1answer
10 views
Python Web Scraping - Trying To Extract Text
from bs4 import BeautifulSoup
import requests
a = 0
while a == 0:
word = input("What word do you want to know? ")
url = "http://dictionary.cambridge.org/dictionary/british/" + word.lower()
...
-2
votes
0answers
22 views
server not working-Beginner level [on hold]
I want to create an simple web server which accepts my request and sends response messages.
I have developed the below code. There is some error through which it is unable to accept request and send ...
0
votes
0answers
5 views
How to deal with Python slice objects in boost::python?
Suppose there is a class MyArray in C++. It implements an array of SomeType In order to make a __getitem__ function for it in Python, I do something like this
const SomeType& getitem(const ...
0
votes
1answer
17 views
Why does half my numbers not line up in my radii chart
Program seems to work just fine. It gives a output but from number 6 through number 9 it throws my circumferences out of line. is this a format problem and if so what would I need to do to fix this. ...
0
votes
1answer
15 views
Combination with Replacement in Python [duplicate]
I am trying to find all the possible whole number lengths of sides of a triangle the perimeter of which cannot exceed 10 million. In order to do this, I need to figure out how to use Python to find ...
0
votes
1answer
26 views
Returning a class instance from a module?
I have a class I created, and in a module, I create an instance of the class. Unfortunately as it is now, whenever the module ends, so does the class instance (as expected). I want to keep that class ...
0
votes
0answers
17 views
PyCharm does not recognize modules installed in development mode
I have two pure python projects in PyCharm 3.4.1 Professional Edition. The first one, let's call it p (like package), is structured as a setuptools package (i.e. with setup.py, all requirements etc., ...
-3
votes
3answers
52 views
How to extract a number from a string in Python?
How do you extract a number from a string to be able to manipulate it? The number could be either an int or a float. For example if the string is "flour, 100, grams" or "flour, 100.5, grams" then ...
1
vote
1answer
31 views
Neumann's Random Generator - Python 3
I am working on Code Abbey problem 23, Neumann's Random Generator. The goal is to use a given algorithm to generate a series of random numbers from each value in the list, and continue until the ...
1
vote
1answer
15 views
Populating “data” section of a post request with function
Trying to populate the "data" section of a urllib request in python with values from a list, and some formatting.
Say I have a list like this [1492, 1493, 1493, ...]
and I want to get those two ...
0
votes
1answer
11 views
how do I get my paint program to contenue after user inputs wall info in python 3.4
Im writing a paint program that's supposed to determine the cost of painting the walls of a shed with a rectangular floor. Im supposed to assume the shed has no windows and that the paint cost is $40 ...
0
votes
1answer
39 views
python 3.x - text based adventure game, save game function
I am making a text based adventure game. I am about half way done and before I get much farther with the story line I want to implement a save game function. I've been trying to figure it out all ...
0
votes
1answer
27 views
AttributeError: 'Thread1' object has no attribute '_initialized'
well i got this problem when trying to stop a thread with the .join method
TRACEBACK
Traceback (most recent call last):
File "<pyshell#16>", line 1, in <module>
t1.alto()
File ...
-3
votes
1answer
28 views
Key error in dna complement [on hold]
import string
import os,sys
file=open("C:\Python27\\New Text Document.txt",'r')\
seq =file.readlines() basecomplement = {'A': 'T', 'C': 'G', 'G': 'C', 'T': 'A'}
def translate(seq):
aaseq = []
...
0
votes
1answer
18 views
Pulling certain data from an input
Im trying to extract a certain part of my input from the first line and use it to calculate the problem and then put it back together.
For example,
Please enter the starting weight of food in ...
-2
votes
1answer
22 views
Python - Race Results - Issues sorting dictionay entries and printing out data in particular form
FYI I am new to python and there could be a more efficient way to produce the desired results. Please feel free to suggest an alternative method.
Problem 1 -
I cannot figure out a way to add "1st ...
0
votes
1answer
15 views
GtkIconView Right Click Activate
I'm building an application using GTK 3+ with Python, and I'm having trouble with GtkIconView. When there are icons in the view, I would like to be able to left and right click on the icon. A single ...
0
votes
3answers
51 views
Reading textfile into dictionary
My code:
fd = open('C:\Python27\\alu.txt', 'r')
D = dict(line.split("\n") for line in fd)
It shows the following error
traceback (most recent call last):
File ...
-1
votes
1answer
24 views
how do I better setup the dice program to get a better output
I am trying to create a dice program that rolls two dice 5 times and have each dice roll out its value and add the output combined total. I cant seem to get it to give me the combined total.
import ...
-4
votes
2answers
36 views
Is it possible to make a variable an object of a class by changing its type?
Assume that we have a test()class defined as below :
>>> class test():
pass
Normally when I run the below code I make Obj as an object of my test() class :
>>> obj=test()
...
0
votes
0answers
13 views
Pyvenv cannot create virtual environment
Usually I use virtualenv for python2.x. After some bitter experience with unicode encoding/decoding clash, I decided to upgrade to 3.x, But I can't create a virtualenv using pyvenv.
$ pyvenv-3.4 env
...
-1
votes
2answers
36 views
Instantiate a class but don't call its __init__ method [duplicate]
I want to know if is there any way to make an object of a class, but don't call its __init__ method :
Look at the below code :
>>> class test():
def __init__(self):
print("an ...
2
votes
5answers
47 views
using break in an inline if statement in a loop causes a syntax error
I was trying this
while True:
break if input() == 'q' else input()
This causes a syntax error
break if input() == 'q' else input()
^
SyntaxError: invalid syntax
I know there ...
0
votes
2answers
21 views
ValueError: max() arg is an empty sequence [python 3]
IS the list being nullified after calculating sum??
t = int(input())
while t > 0:
n,m=map(int,input().split())
a=map(int,input().split())
l,o=sum(a),max(a)
print(l)
if ((o * ...
0
votes
1answer
14 views
python 3.x - AttributeError: 'user' object has no attribute '__plusPotion'
I can't figure out how to add two potions after I beat the enemy in the fight. Driving me nuts, I know it's probably something simple. Any help is appreciated. What I am trying to do is have the fight ...
-1
votes
1answer
16 views
Extend Python object in run-time using inheritance
I would like to extend an object with new attributes and methods, but in run-time. Basically I would prefer to just inherit and extend a class, but new objects of the base class are not usually ...
0
votes
1answer
23 views
Filter csv rows with multiple conditions
Hi I want to filter out rows whose 2nd column (Hex) has value 80 or 81 and filter out rows whose 2nd column is 0 only if its below the row which has 81 in the second column:
sample.csv :
...
0
votes
1answer
23 views
NameError: name 'user' is not defined; class related I think
I am trying to create a battle function for a simple text based adventure game. We haven't covered classes yet in class but after doing some searching, it seemed the best way to do it. However, I keep ...
-1
votes
1answer
34 views
How would i create two lists and add items to that list in python 3.2?
alright so im wanting to make a statistical file and i want to creat two lists... Player Names, and High scores, after having these two list i want to add items to it such as names and ...
0
votes
1answer
11 views
PRNG Error (Python)
So I'm trying to make a PRNG:
import math;
import datetime;
print("Please input the seed number.")
seed = input()
systime = datetime.datetime.now().time()
int result = seed + 24252561651525166 - ...
-3
votes
1answer
27 views
Count Consonants Before First Vowel in a String
I'm creating a simple pig Latin translator. Here's what I have so far:
while True:
phrase = input('Translate > ').lower().split()
for word in phrase:
if word[0] in 'aeiou': #if the ...
-5
votes
3answers
57 views
Please give me an explanation of what this means (Basic) [on hold]
Just starting python, the book tells me I can create a this matrix diagonal if I use this following code, someone please explain what it means? The for i in, the Matrix[i][i] and why it's [0,1,2]
...
0
votes
1answer
14 views
LNK4001 while still supplying obj files when building Python extension?
I am porting my C Python extension to Python 3(.4.1) and Windows 7. I have the Windows 7.1 SDK (includes the VS 2010 tool chain) installed, and am getting linker error that appear to be incorrect. I ...
0
votes
1answer
38 views
Pass a Variable Name to the Arguments of a Function (Python 3, Pandas)
Say I have a DF defined as variable DF1:
Words Score
The man 10
A Plan 20
Panama 30
And say I have a function:
def func(w, df):
pattern = ...
0
votes
5answers
47 views
Making my While loop terminate with the input of “Done”
I am currently writing a program for my Intro to Programming class. The requirements are to have a user input a list of celebrity names, add them to a list, print out how many celebrities were ...
-1
votes
4answers
35 views
“IndexError: string index out of range” when loop is already ended! - Python 3
I'm recently studiying sockets trying to make them work inside a Python script (Python3), inside Windows.
Here the Python script of the server side.
import socket
import time
MSGLEN = 2048
server = ...
0
votes
0answers
13 views
Django Cascading Forms
Python 3.3.2, Django 1.6.5, Fedora 20
I've got a form in Django and I would like the options in a drop down menu to be restricted based on the selection of a previous item. I've got a model, Sport, ...
0
votes
2answers
21 views
Access array based on number of named key
json_data = {"fruits": ["apple", "banana", "orange"],"vegetables":["tomatoe", "cucumber", "potato"]}
How do I access my array numerically without having to include a numeric key?
ex:
...
0
votes
1answer
30 views
subclassing a class which contains a class
I am trying to change around a class to more match my specifications. I start by subclassing the main class
from flask.ext.sqlalchemy import SQLAlchemy
class SpecialSQLAlchemy(SQLAlchemy):
def ...
0
votes
0answers
19 views
IO operation timeout
I had an issue with os.path.exists() when working with UNCs and network paths in general.
Some servers tend to die in weird fashion that instead of returning error they hang for 130 seconds and then ...
0
votes
1answer
31 views
how to put in a list the values of multiple command line arguments
I have a cli build.py I call it build.py -t -c -f
When I parse the command line arguments, Is there a built in way to get a list of
['t' = true,'c'=true,'f'=true,'s'=false]
Below are the ...
-3
votes
0answers
41 views
why am i getting traceback errors with my program [on hold]
trying to write a program that generates ten random integers, all from 1-100, and stor es them in a list. Use a loop. Process the list to determine the sum of the odd numbers and the sum of the even ...
-2
votes
1answer
37 views
#list index out of range
def isexact(pat):
for c in pat.upper():
if c not in 'ATGC':
return 0
return 1
def print_matches(ofh, enz, matches):
if matches:
print >>ofh, "Enzyme %s matches ...
-2
votes
0answers
53 views
python behavior with pow function [on hold]
I believe all the following statement are evaluated to 30**21 yet they yield different results. Py 3.4.1 (x64)
>>> 30**21
10460353203000000000000000000000
>>> 30 ** ((43-1) / 2)
...
0
votes
1answer
21 views
Is there a way to add a task to the windows task scheduler via python 3?
I have a main python script that generates a GUI, and through that GUI I want the user to be able to create, amend, and delete schedules managed by the windows task scheduler.