Posts
 
Reputation
Joined
Last Seen
Ranked #57
Strength to Increase Rep
+15
Strength to Decrease Rep
-3
92% Quality Score
Upvotes Received
916
Posts with Upvotes
812
Upvoting Members
325
Downvotes Received
66
Posts with Downvotes
60
Downvoting Members
38
192 Commented Posts
~3.78M People Reached
About Me

IT Pro doing Eng-Fin-Eng translations

Interests
Python, Mojo, Julia, multiculturalism, translation
PC Specs
TUF Gaming 10th gen laptop and various desktops
Favorite Tags

3,386 Posted Topics

Member Avatar for Steph102

More concisely the same as vegaseat wrote could be writen: ''' coinflip102.py flip a coin 100 times and count heads and tails ''' import random tails = sum(random.choice(['head', 'tail']) == 'tail' for k in range(100)) print("""The Number of heads was {heads} The Number of tails was {tails}""".format(tails=tails, heads=100-tails))

Member Avatar for Dani
0
16K
Member Avatar for deepakgupta2186
Member Avatar for masocha

Paste a piece of code which is unclear to you and we can clarify it's meaning in pseudocode. Do not post externally, but include as normal attachment or preferably just code block. The files in your rar file seemed to be OK, except wrong file types and one of the …

Member Avatar for Mike_106
0
6K
Member Avatar for isendre

Post your code and we will check it out. It is not very hard if you keep your head straight! If you have learned about dictionaries, simplest to operate with is to index dictionary like: board['b2'] or board['b',2] and get user input like: b2, 4

Member Avatar for cossy254
1
6K
Member Avatar for RoqueyB

Your display routine is at least too complicated and line 12 does not make sense. Same shorter: [CODE]def count(sticks): print("* %s *" % (sticks * '|')) count(33) [/CODE] Indents of lines 64 and 65 does not make sense. I see for example "How many sticks would you like to pick …

Member Avatar for Ben_493
0
9K
Member Avatar for colby.christensen

[Here](http://matrixprogramming.com/2011/03/linear-solve-in-python-numpy-and-scipy) for example is one example about solving by Gaussian elimination with numpy/scipy with reference to LAPACK libraries. Scipy also has matrix IO routines: http://docs.scipy.org/doc/scipy/reference/tutorial/io.html You might like to install Enthought Canopy Python which has numerous libraries ready installed: https://www.enthought.com/products/canopy/

Member Avatar for Reverend Jim
0
4K
Member Avatar for WolfShield
Member Avatar for markusd5454

[code] # program that checks that the username and password are correct # username = input("Please enter your username : ") password = input("Please enter your password : ") print ("Greetings," , username, "you are now logged in now with a password") command = input("Please type a command :") if …

Member Avatar for Reverend Jim
0
86K
Member Avatar for guidely

n is undefined. I do not understand your int statement. I would index a tuple of the values instezd of nested if.. Sorry but mobile posting is not working at the moment correctly. Could you post the error you are getting and how you are using the function.

Member Avatar for Sukant_1
0
18K
Member Avatar for pelin

You are missing essential part calling the main! Otherwise it looks like working, even input is in text window.

Member Avatar for Devarshi_1
0
629
Member Avatar for Peter_TARAS

I do not know pack method so well, but here is how I do it with pack: [CODE]from Tkinter import * import tkFont def killme(): root.quit() root.destroy() root=Tk() dFont=tkFont.Font(family="Arial", size=30) lb=Text(root, width=16, height=5, font=dFont) lb.pack(side=LEFT, fill=BOTH, expand = YES) yscrollbar=Scrollbar(root, orient=VERTICAL, command=lb.yview) yscrollbar.pack(side=RIGHT, fill=Y) lb["yscrollcommand"]=yscrollbar.set root.mainloop() [/CODE]

Member Avatar for bevis.hobbs
0
22K
Member Avatar for daviddoria

I do not get the problem, only I got not found error from mag function found in code, so I replaced it with distance from origin. I did some renaming to make the program more "PEP8 understandable" [CODE]from __future__ import division from math import * class Point(object): def __init__(self, x=0.0, …

Member Avatar for Ratan_2
0
6K
Member Avatar for vegaseat

OK, here is a really optimized version for this classic problem. This is not originally mine (but have done very similar). It utilizes the fact that primes > 4 are 1(mod 6) or 5(mod 6). Actually I editted it a lot now before posting to be more according to format …

Member Avatar for amir_19
3
24K
Member Avatar for Iceman10284

So you have not learned the syntax, good place to start to learn it is to go through the tutorial at http://docs.python.org/tutorial/index.html

Member Avatar for UNIQUE_PRINCE
-1
4K
Member Avatar for tjsilver

I would prefer to have functions themselves as first value and just call it instead of using eval. be sure to rename the functions according to choice. Best naming would be to use verb and if need to join words in name use _. Do not use capital letters.

Member Avatar for August.Garcia
0
3K
Member Avatar for vegaseat

That is because unnecessary update of the screen weakens the quality of the display. Maybe not, or only with slower computer, but it is good practice to avoid unnecessary refresh. Especially when you do more action on screen than just changing number.

Member Avatar for Vinay_17
2
26K
Member Avatar for sarfrazashfaq

Please include the error messages. The variable must of course be global variable in the python file. At least saving the value to text file to be read by the script should work.

Member Avatar for jaakdentrekhaak
0
5K
Member Avatar for Fo.katia
Member Avatar for abders

Gribouillis means that obviously those two functions have no business in being in the class Player. Interestingly I have exactly same functions in module called games for a Blackjack game from one book, without the class Player. in range(low, high) is not the world's most efficient way to check value …

Member Avatar for Kaushik_2
0
989
Member Avatar for abders

Why you are not calling the mainloop at last line? Shouldn't the parameter to parent init be self?

Member Avatar for Gribouillis
0
2K
Member Avatar for TrustyTony

This is one small snippet of after event usage. You could express if you find this kind of simple code to be usefull as snippet. Notice also vegaseat's sticky message threads in begining of Python forum in addition to code snippets.

Member Avatar for Gribouillis
0
5K
Member Avatar for thinkerman

Agreed, WaltP. As example, here is what Code::Blocks AStyle plugin makes out of your code #include<iostream> #include<cstdio> #include<conio.h> using namespace std; int weight[20][20],visited[20],d[20],p[20]; int v,e; void creategraph() { int i,j,a,b,w; cout<<"Enter number of vertices: "; cin>>v; cout<<"\nEnter number of edges: "; cin>>e; for(i=1; i<=v; i++) for(j=1; j<=v; j++) weight[i][j]=0; for(i=1; …

Member Avatar for Aiman_1
0
1K
Member Avatar for sheltask

What was the best program you have done this far? Of course you have to do some kind of design of the program algorithm first and be able to do the task yourself and able to list all steps of it before teaching the computer to do it. Are you …

Member Avatar for Less_1
1
831
Member Avatar for vegaseat

Are you sure that you initialize the midi system like in this snippet before playing the file?

Member Avatar for Rufus_1
5
12K
Member Avatar for ruwach

Everything should work as long as you replace the print command with print function, manually or by 2to3. More shortly: [CODE]# find the last line, change to a file you have with open('test.txt') as myfile: print (list(myfile)[-1]) [/CODE]

Member Avatar for gunjan_3
0
63K
Member Avatar for vegaseat

Of course it could be considered user responsibility, but I do not personally like that the calculator does not allow to continue from result and saves formula to memory instead of evaluating the result automatically. For example: 10/3 M-> = result: 3.333333 * M<- = result: *10/3.0first char not in …

Member Avatar for Charles_24
5
10K
Member Avatar for Gribouillis

Is that 3.2 3.2.2 as there was an issue with input statement with 3.2.1? Probably not reason though, at that problem would make program OK in IDLE and not OK in direct excecution.

Member Avatar for Gribouillis
5
75K
Member Avatar for tjy92

Good luck, we are always ready to help, you only have to post in your code and explain where you have difficulty.

Member Avatar for Reverend Jim
0
3K
Member Avatar for sandman64

Are you sure you need while for this job. BTW it has no else part not to talk about elif. And in you new version while condition is always True as <condition> or -2 is always True.

Member Avatar for Swathi_4
0
222
Member Avatar for Viasur

Would it maybe easier to use my code snippet for text file based database (actualy card file would be more proper term)

Member Avatar for Gribouillis
0
4K
Member Avatar for tkpanther

M+ does addition to existing contents in memory, MS stores there [CODE] M+ =+ MS =[/CODE]

Member Avatar for Gribouillis
0
22K
Member Avatar for sabbib

And how then would you learn anything? See the forum rules or shorter version from my signature! There is plenty of code snippets in sticky threads and code archive for you to adapt yourself and learn how to actually do it yourself.

Member Avatar for Judith_2
0
1K
Member Avatar for steven.rose.94

You could just ignore the error data by try.. except. self is not good name for regular parameter as it is normally used in oo programs for the instance itself. Tony

Member Avatar for steven.rose.94
0
347
Member Avatar for render786

I think you are still here: > Show the > iterative development of the individual solutions with suitable testing throughout the process. Test > the final products and evaluate your solutions against the detailed requirements you identified in the > analysis. I see no indication that this is the case …

Member Avatar for JamesCherrill
0
2K
Member Avatar for vegaseat

This is what I got from theantonio.neal.39's post by tinkering: from tkinter import * def move(): if message.winfo_x() + message.move >= message.x_limit or message.winfo_x() + message.move < 0: message.move = -message.move message.place(x=message.winfo_x() + message.move) message.after(message.delay, move) gui = Tk() gui.geometry('8000x100+1+600') gui.title('ALERTS') gui.config (bg = 'blue') message = Label(gui, text = …

Member Avatar for Mohamed_65
1
4K
Member Avatar for TrustyTony

Sometimes we want to not split by every space character, but we want to split only on those outside of brackets and quotes. This way we can have for example quoted string as single argument for command. EDIT: 1. Added hierarchical nesting of same kind of brackets. 2. Bunching multiple …

Member Avatar for gamesbook
1
3K
Member Avatar for pwolf

It is possible to make it one liner, but the dictionary approach is clearer or using few more if statements. Maybe you should anyway normalize the case of input to take both 'am' and 'AM' and accept hours with ' ' or '0' in front and also extra blanks at …

Member Avatar for Abhinav_4
0
3K
Member Avatar for arindam31

So for some reason I prefer to use Python instead of re language for this. Actually one of my first code snippets here was of same subject. [url]www.daniweb.com/software-development/python/code/280071/1209215#post1209215[/url]

Member Avatar for Syed Sulaiman
3
10K
Member Avatar for gishi

Also you can use namedtuples, and csv module is not really needed for simple cases. [CODE]from collections import namedtuple filein = open("sample.dat") datadict={} headerline = [f.strip() for f in filein.readline().split(',')] print headerline Dataline=namedtuple('Dataline',headerline) for data in filein: data=[f.strip() for f in data.split(',')] print(data) d=Dataline(*data) datadict[d.id]=d print datadict['123'].email for key,value in …

Member Avatar for Gribouillis
0
15K
Member Avatar for joe97

You have here very complete algorithm, but you should show effort of implementing it, even if you do not get everything right. After we can assist you in debugging or point weak points to concentrate in.

Member Avatar for joe97
0
5K
Member Avatar for shamuh2021

You have tagged various programming languages, but I do not get really your point, can you give specific question or your problem. Anything showing were you are stuck and we could advice you.

Member Avatar for shamuh2021
0
247
Member Avatar for Alok_3
Member Avatar for keval_hack

Basically I agree with her divinity's judgement. [QUOTE=thines01;1638376]#3 (lots of conditions) [CODE] #include "stdafx.h" #include <stdlib.h> int CheckNum(int num) { int iCount = 0; while(num > 0) { num -= 2; iCount ++; } return iCount; } bool isOdd(int num) { return CheckNum(num) != CheckNum(num-1); } void main(void) { char …

Member Avatar for Ahamed_1
-1
2K
Member Avatar for jarograv

how about changing to append mode 'a' instead of 'w' Also looks like you have same file open twice, line 26 and 28 for writing. Finally you are not really using the csv module, but doing by hand at line 30.

Member Avatar for Wesley_1
0
13K
Member Avatar for boomtifier

I would prefer to go with more general approach, and definately not use the dangerous input in Python 2: def withdraw_money(): denoms = (100, 50, 20, 10, 5, 2, 1) while True: try: withdraw = int(raw_input('amount of money: ')) break except Exception as e: print('Incorrect input: %s' % e) # …

Member Avatar for boomtifier
0
3K
Member Avatar for Pavol

Yes, you must just make the number split from file line numeric and check if that line had line_value in it if it is lower than current line_value, as you seem to have line_value always increasing and the lines with second value higher do not need checked. You might add …

Member Avatar for TrustyTony
0
159
Member Avatar for vegaseat

Also, see the code snippet on checking numeric input at: [url]http://www.daniweb.com/code/snippet284490.html[/url]

Member Avatar for vegaseat
23
34K
Member Avatar for vegaseat

[B]Gigasecond vs nanosecond[/B] Your computer has worked so hard that you want to give it generous holiday of one second by replacing it in it's job. The computer calculates your program one operation per nanosecond, so you have little much job to do. How much real time must you spend …

Member Avatar for vegaseat
20
18K
Member Avatar for vegaseat
Member Avatar for vijaykrishnabor

These are applicable to programming in general (Python -> import this) > The Zen of Python, by Tim Peters > > Beautiful is better than ugly. > Explicit is better than implicit. > Simple is better than complex. > Complex is better than complicated. > Flat is better than nested. …

Member Avatar for Mayukh_1
-1
7K

The End.