- 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
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. |