- Strength to Increase Rep
- +10
- Strength to Decrease Rep
- -2
- Upvotes Received
- 107
- Posts with Upvotes
- 94
- Upvoting Members
- 49
- Downvotes Received
- 5
- Posts with Downvotes
- 5
- Downvoting Members
- 4
Working as a business analyst and system designer for financial companies in Hungary.
- Interests
- Software design, python
304 Posted Topics
Re: [code] n=6 print "\n".join([str(i+1)+'.'*n for i in range(n)]+["".join(chr(i) if i>=97 else '.' for i in range(96,97+n-1))]) [/code] | |
Re: Yes. Someone can. But there is [no real automated converter](http://stackoverflow.com/questions/11792529/c-to-simpler-language-python-lua-etc-converter). This task sounds like (boring) work. And work is paid. To get someone to do this you have to motivate them with your own effort. If you write down the specification and the goal of the program, someone will help. | |
Re: I hope nobody thinks these algos are used in the real world. There are much better [algos](http://en.wikipedia.org/wiki/Primality_test) to determine if a number is prime. Since the beginning of the 20th century. These functions are good to understand how to program, and how to program in python. They are hardly usable … | |
Re: Your teacher is right. If you see lots of lines in the code, that differ from each other only in a few characters, then your code (or your programming language) is inefficient. Please remove globals. They render the code very hard to read. If you use "import \* " then … | |
Re: Simple RSA primtest. Does not work on universal pseudo primes. [code=python] def isprime(n,PROB): '''returns if the number is prime. Failure rate: 1/4**PROB ''' if n==2: return '1' if n==1 or n&1==0:return '0' s=0 d=n-1 while 1&d==0: s+=1 d>>=1 for i in range(PROB): a=random.randint(2,n-1) composit=True if pow(a,d,n)==1: composit=False if composit: for … | |
Re: One solution would be putenv. On linux: abc.py: [code] import os uname="Some uname value" os.putenv("UNAME",uname) os.system("./test.sh") [/code] test.sh: [code] echo $UNAME [/code] | |
Re: Beside Gribouillis' explanation. > Although, sounds simple but still not able to understand the concept behind. Core concepts are the most hard things. > I would like to know how they picked up the module sys or how we gonna decide from where we need to import. The author picked … | |
Re: I know, you did not ask, but the program should be more tight (compact). Something like this: import random def main() : tie_message="It's a draw. You both threw %s." win_message="You win! Your opponent threw %s." lose_message="You lost. Your opponent threw %s." values=("rock","paper","scissors") # must be in increasing beating order while … | |
Re: Good luck! from random import randint def guess(): if int(input("Guess the number (1-10):"))==randint(1,10): print("Got it") else: print("Wrong!") guess() guess() | |
Re: You did not mention any reason that justifies creating a new tkinter mainloop. So take a look at these: http://tkinter.unpythonic.net/wiki/ModalWindow http://effbot.org/tkinterbook/tkinter-dialog-windows.htm You can make FirstScreen a modal toplevel window. If you want to keep the functionality to run the FirstScreen separately, then you can put it in a module (separate … | |
Re: First try to make a version of it, that actually can be run by others. If I copy-paste your code into notepad, then save it, it does not run. I would recommend the following improvements after that: * Place imports at the top * Remove global variables, get rid of … | |
Re: > I am not very clear about what does this mean, my original understanding is that x will keep data's first two dimensions, and take a slice from data on the third and fouth dimension. It keeps the first and fourth dimension and slices the two inbetween. `x=data[:,c:-c,d:-d]` The first … | |
Re: I/ if you import everything from turtle, like this: `from turtle import *` Then you cannot make statements like this: `point = turtle.Point(x,y)` You should do: `import turtle` II/ allTriMedian function is never called. So it is never executed. You should call it like: `allTriMedian()` III/ There is no Point … | |
Re: Google is your friend. https://www.google.hu/search?q=python+smtplib+tutorial+gmail First hit: http://naelshiab.com/tutorial-send-email-python/ Which sais: [ EDIT: Gmail made some security change change recently. You now have to allow “less secure apps” on your account. Otherwise, you won’t be able to connect to it with your python script. ] | |
Re: * You are not adding up the even cubes. You are adding up all cubes of numbers between 0 and natn-1.Look up [range documentation](https://docs.python.org/3/library/functions.html#func-range), how to generate even numbers. * Average is sum divided by count. You can count the numbers by (python3): add = 0 counter=0 for i in … | |
Re: I do not understand. * Do you want to draw the maritime flag images using turtle graphics or you want to put the downloaded flag images on a canvas? * What is the expected output of the function? | |
Re: python3: import tkinter as tk master = tk.Tk() menu={'pizza':1,'Burger':1,'sandwitch':0} menuvars={} for row, (key, value) in enumerate(menu.items()): menuvars[key]=tk.IntVar() menuvars[key].set(value) tk.Checkbutton(master, text=key, variable=menuvars[key]).grid(row=row, sticky=tk.W) tk.mainloop() | |
Re: > How to make panel in tkinter or which widget will be used to hide and show checkbox? I am not sure, I understand this sentence. Something about the keywords "widget" and "hide" http://effbot.org/tkinterbook/pack.htm#Tkinter.Pack.pack_forget-method | |
Re: Line 46: v = IntVar() ** v goes out of scope.** If you bind v to something persistent (self), then it works. How did you plan to read that variable anyway? | |
Re: Yes. There is a way to convert it to a GUI based program. Before you do that, I would recommend: * Make a self containained version, so others can run it. That helps you to get help. * Make the program shorter. At first glance the program can be reduced … | |
| |
Re: Hello there! Short version: I do not understand the question. Long version: My eagle eye detected you posting the [second](https://www.daniweb.com/programming/software-development/threads/504480/python-comparing-two-values-of-lists-) question about the same project. This should be a very secret project. If you would tell us what this is about, we could provide much more help. However your code … | |
Re: Please post a working code, to help others. Try to copy-paste your own posted code into a .py file and see, that it does not work. There is a syntax error, not just intendation problems. The mainloop call is missing, too. I have corrected the code, and hopefully solved your … | |
Re: You use global imported variables locally. There is no need to pass ScrolledText and Tk to the Scratchpad class's dunder init. This is redundant. This is the same, but cleaned up: from tkinter import Tk, END, INSERT from tkinter.scrolledtext import ScrolledText from tkinter.filedialog import asksaveasfilename, askopenfilename class Scratchpad: def __init__(self): … | |
Re: class Date(object): def __init__(self, year, month, day): self.year=year self.month=month self.day=day def __add__(self, other): if not isinstance(other,Delta): raise Exception("can only add Delta object") #FIXME handle the calendar year=self.year+other.year month=self.month+other.month return Date(year,month,self.day) def __str__(self): return "("+",".join(map(str,(self.year,self.month,self.day)))+")" class Delta(object): def __init__(self, year, month): if not (1<=month<=12) or year<0 or \ not isinstance(year,int) or … | |
Re: Besides from [whathaveyoutried.com](whathaveyoutried.com) , I can only say: values=[int(input("Give the number(%s): " % i)) for i in range(1,6)] print("Highest: {} \n Lowest: {} \n Average: {}".format(max(values),min(values), sum(values)/len(values))) But beleve me. You should try something. | |
Re: I think the most used layout for tkinter is grid. So grid paper and pen. I know, this is not software. [Others](http://stackoverflow.com/questions/14142194/is-there-a-gui-design-app-for-the-tkinter-grid-geometry) recommend that, too. | |
Re: Here you are. I hope, this makes you a really good programmer. f=open("states.txt").readlines() states=sorted([(f[i].strip(),f[i+1].strip(),int(f[i+2])) for i in range(0,len(f)-3,3)],key=lambda x:x[2]) print("minimum population:",states[0]) print("maximum population:",states[-1]) | |
Re: Python3 nums=[(int(input("Give me the number numero {}: ".format(i+1)))) for i in range(20)] print("Lowest: {}\nHighest: {}\nTotal: {}\nAverage: {}".format(min(nums),max(nums),sum(nums),sum(nums)/len(nums))) I hope that makes you smarter. | |
Re: [mylist[i:i+3] for i in range(0,len(mylist),3)] | |
Re: I suggest to calculate it in a spreadsheet (excel) before you program it. The first x rows will be the conditions, then every row is a date where a payment is due. The columns will be the variables you are using in the program. Let me inform you, that this … | |
Re: This is a horrible post, you have made here. 1. Your code does not run. Bad indent. 2. Are you sure, we need all the data from the database to answer your question? 3. You did not give us the python version you are using. 4. You did not give … | |
Re: There is a script in the python distribution: pythonhome\Tools\Scripts\ftpmirror.py Maybe itt will help you if you look at it. | |
Re: I would create a decorator, that decorates the function. Something like: @menu_item(Name="Save", enabled=True) def save_menu(): function body The decorators would add a dictionary (for example with the name menu_data) to the decorated function with the arguments. The program code would scan the functions and if a function has menu_data attribute, … | |
Re: You put the space and data coma separated into the text file. So you have no hope of retrieving the fields reliably. You have to make some thoughts how to store and search the data (pickle, shelf, sqlite etc...) Otherwise it is working. Some ideas in the code: import shelve … | |
Re: I am not sure, I understand your problem. These two one liners start a webserver in the current directory. If you point your browser to the localhost, and the port given on the commandline, you will get a directory listing. Python 2.x: python -m SimpleHTTPServer Python 3.x: python -m http.server | |
Re: First of all the program won't run. Line 27,28 have syntax errors. Secondly, if I fix that errors, then the explanation follows: * There is a story, that has 3 parameters. Food, animal and city. * The program asks the user on the command prompt for an example of the … | |
Re: You probably have to open the file in binary mode ("wb"). I do not think you have to convert the_page to anything before writing. Otherwise use urlretrieve, as you already found out. | |
Re: Can you tell us what exactly do you want to accomplish? Are you sure, do you really want [system programming?](http://en.wikipedia.org/wiki/System_programming). | |
Re: I have python2 so I changed tkinter to Tkinter. I am not a big tkinter expert. Firstly the code does not work. root.mainloop() or similar is missing. If I put it in, it works. Secondly. If you have created the code, then there was something on your mind, or not? … | |
Re: You have no values in result_list or in resultlist_key. Try to print out the length of the structures in the matching_image function. Most likely you have a naming conflict. You have global variables that are recreated at the function level. | |
Re: I am not participating just thinking of it a little bit. One approach would be to try to construct an ideal setting, like this: c.... ..... ...** ***** ***** And examine the corner cases, like one row, one columne, too much mines, too few mines etc. Other approach would be … | |
Re: I do not understand. Where is the html? What is a,b,c supposed to mean? | |
Re: Firstly this is not the mentioned algo. The real one does NOT have an isprime function. That is the main advantage of it. Secondly it is not slowed down. It is slow. If you are interested, we can discuss it. Thirdly look up this algo's implementation here: http://www.daniweb.com/software-development/python/code/217082/eratosthenes-sieve | |
Re: > Thanks if you've taken an interest but have figured it out: needed to assign a variable to the function. Better formulated: Needed to assign a variable to the function's return value. | |
![]() | Re: In python 3 print is a function. You should write: print("Hello, World") |
Re: Your 7th line has an error. You need to convert the output of the input function to int. Not the input function itself. It is an over kill to calculate all the diceroll for all the possible inputs. It is enough to calculate it after the input. No need for … | |
Re: Hello Zahra! I would make a Game class that holds the characters. Then I would make the characters that generates the attributes. The attributes are generated by rolling a dice. Something like this: # python 2 code import random class Dice(object): __slots__=("sides",) def __init__(self,sides): self.sides=sides def roll(self): return random.randint(1,self.sides) class … |
The End.