4,305 Posted Topics

Member Avatar for Learner010

Nice tutorial! Sometimes an endless loop comes in handy ... // an endless loop with break condition int k = 0; while(true) { k++; cout << k << " "; if (k >= 10) break; } You can put this into a function and replace break with return. Also, put …

Member Avatar for Markland
7
707
Member Avatar for vegaseat

Sometimes it's easier to pick an image from the internet to display in your Python Tkinter GUI toolit program.

Member Avatar for vegaseat
1
5K
Member Avatar for vegaseat

Shows how to convert a comma separated value (csv) string to a list of records, and then do some data processing. The csv strings usually come from csv files created by spreadsheets.

Member Avatar for vegaseat
1
3K
Member Avatar for vegaseat

Let's assume you would have to design a 500 ml (about 1.1 pint) food/beverage container like a can and use the least amount of material. Here is a Python program that explains the steps to achieve this.

Member Avatar for vegaseat
2
1K
Member Avatar for TObannion

In Python3 the **input()** function returns a string. If you want an integer you use **int(input())**.

Member Avatar for vegaseat
0
205
Member Avatar for Chinnaiah_1
Member Avatar for Chinnaiah_1
0
233
Member Avatar for Xantipius
Member Avatar for Xantipius
0
253
Member Avatar for DaveAmour
Member Avatar for Teo_1

The Tkinter widgets you are dealing with in your program are ... tk.Entry() for data input tk.Label() to display info and results tk.Button() to start an action in the form of a function or method You can also bind the entry instance to a function after, let's say, the Enter …

Member Avatar for vegaseat
0
153
Member Avatar for Ma Nicole Ydralyn
Member Avatar for Ma Nicole Ydralyn
Member Avatar for vegaseat

This shows you how to create a flashcard like quiz game using a Python dictionary. It's up to you to explore the approach and make this a more meaningful game.

Member Avatar for Chance_1
2
7K
Member Avatar for matjojo
Member Avatar for vegaseat

I thought it would be fun to code all the different ways to show Hello World on the display. Let's start simple ... `print("Hello World")` Can anybody print out "Hello World" vertically?

Member Avatar for ZZucker
1
909
Member Avatar for XP78USER

Icons with a Kindergarten look, refreshing! To be new you have to change something. Let's hope it is security that was improved.

Member Avatar for Lardmeister
0
361
Member Avatar for humorousone

I get errors when I try to compile this code ... typedef struct n{int a:3, b:29;struct n*c;}t;t* f();r(){}m(u)t*u;{t*w,*z; z=u->c,q(z),u->b=z->b*10, w=u->c=f(),w->a=1,w->c=z-> c;}t*k;g(u)t*u;{t*z,*v,*p, *x;z=u->c,q(z),u->b=z->b,v =z->c,z->a=2,x=z->c=f(),x ->a=3,x->b=2,p=x->c=f(),p ->c=f(),p->c->a=1,p->c->c= v;}int i;h(u)t*u;{t*z,*v,* w;int c,e;z=u->c,v=z->c,q( v),c=u->b,e=v->b,u->b=z->b ,z->a=3,z->b=c+1,e+9>=c&&( q(z),e=z->b,u->b+=e/c,w=f( ),w->b=e%c,w->c=z->c,u->c= w);}int(*y[4])()={r,m,g,h}; char *sbrk();main(){t*e,*p,*o; o=f(),o->c=o,o->b=1,e=f(), e->a=2,p=e->c=f(),p->b=2, p->c=o,q(e),e=e->c,(void)write (1,"2.",2);for(;;e=e->c){q(e), e->b=write(1,&e->b["0123456789"], 1);}}t*f(){return i||(i=1000, k=(t*)sbrk(i*sizeof(t))),k+--i; }q(p)t*p;(*y[p->a])(p);} I am using Windows7.

Member Avatar for ZZucker
0
501
Member Avatar for Mubsahir Ijaz

Using the Standard Template Library (STL) vector might make your life easier.

Member Avatar for misi
0
186
Member Avatar for karmstrong

Without thinking ... mylist = [0, 3, 6, 8, 8, 5, 2, 0, 7, 1, 9, 5, 0, 7, 7, 4, 2] s = "" n = 1 for ix, k in enumerate(mylist): if ix == n: s += ' ' n += 4 s += str(k) print(s) # 0 …

Member Avatar for vegaseat
0
482
Member Avatar for Tcll
Member Avatar for vegaseat
Member Avatar for vegaseat
0
241
Member Avatar for karmstrong
Member Avatar for vegaseat
0
5K
Member Avatar for TekknoDraykko

Have you seen any "dark matter" lately? Actually you can only see the "dark matter effect" as it distorts light through gravitation. When two galaxies collide their shape will change, but the shape of the "dark matter effect" will stay the same. Some newer discoveries ... http://www.bbc.com/news/science-environment-32066013 So, what is …

Member Avatar for vegaseat
0
183
Member Avatar for Shalu.23
Member Avatar for cjohnweb

On first glance look at the items with the highest tottime values. Then check the number of calls and the percall time. Remember that function calls are expensive because of the overhead.

Member Avatar for vegaseat
0
368
Member Avatar for Edward_6
Member Avatar for RobertHDD
Member Avatar for Reverend Jim
1
364
Member Avatar for davijhon

An oldy but goody: Age of Empires II I find it very relaxing, yet challenging.

Member Avatar for XP78USER
0
345
Member Avatar for vegaseat

The Tkinter GUI toolkit's canvas object is very nice for all sorts of drawings and plotting. However, when it comes to saving the image Tkinter limits you to postscript printer files. One solution is to draw the same image in parallel on PIL's image-draw object in memory. This is made …

Member Avatar for MatthiasBl
4
19K
Member Avatar for clhamon
Member Avatar for Niloofar24
Member Avatar for vegaseat
0
441
Member Avatar for joshuawilson11

Hmm ... import textwrap mylist = [83, 111, 109, 101, 119, 104, 101, 114, 101, 32, 105, 110, 32, 108, 97, 32, 77, 97, 110, 99, 104, 97, 44, 32, 105, 110, 32, 97, 32, 112, 108, 97, 99, 101, 32, 119, 104, 111, 115, 101, 32, 110, 97, 109, …

Member Avatar for vegaseat
0
140
Member Avatar for rinston

The problem with Google is that they keep track of who is searching for what. Let's say you are looking for a brand of shoe, soon after you get shoe sales sending you e-mails.

Member Avatar for XP78USER
0
441
Member Avatar for jeffcogswell

The lack of communication between Microsoft's different departments seems to be obvious. It is my distinct feeling that Microsoft never liked Python, so they put it in Irons. Years ago Microsoft tried to take over Java, this might have been an attempt to take over Python.

Member Avatar for Tcll
3
2K
Member Avatar for Ragunath_1
Member Avatar for manofprogram

Another thing to watch out for is the value of the Enter key. On Windows it is '\r\n' on Linux it is '\n'. I have seen this giving strange skip effects with the Go language.

Member Avatar for deceptikon
0
129
Member Avatar for Niloofar24
Member Avatar for Niloofar24
Member Avatar for CodeWarrior14

Your keys have to be adjusted for the removed spaces ... class MessageEncoder: '''change the order of spaces in a text''' def __init__(self): pass def get_key(self): '''create and return the space char index key''' return ':'.join(str(ix) for ix, c in enumerate(self.text) if c==' ') def remove_space(self): '''return a list of …

Member Avatar for vegaseat
0
352
Member Avatar for vegaseat

We have had several snippets on the format() function. This one gives a condensed overview of the many options you have.

Member Avatar for BustACode
6
932
Member Avatar for posiblehost

I enjoy hiking in the nearby Sierra Nevada mountains, even on Friday the 13th.

Member Avatar for vegaseat
1
211
Member Avatar for CodeWarrior14
Member Avatar for RobertHDD

Not counting reading the financial and international news on my iPad, I would say 3 to 4 hours.

Member Avatar for <M/>
1
277
Member Avatar for Mate_1

You are better off drawing three triangles ... ''' turtle_triangle_up.py use Python module turtle to draw a triangle pointing up draw three triangles and fill with different colors ''' import turtle as tu tu.title("triangle up") def triangle_up(x, y, side, color='black'): """ draw an equilateral triangle of size side starting at …

Member Avatar for vegaseat
0
984
Member Avatar for <M/>
Member Avatar for linus72982
Member Avatar for Nation
Member Avatar for vegaseat

A very basic pygame sprite example. Moving a sprite with the arrow keys, could be the start of a great space game.

0
6K
Member Avatar for BustACode

A note to coding style: In just about all computer languages programmers try not to exceed about 80 characters per line of code. You could add your comments above the code line to help out, otherwise word wrap makes code pretty hard to read and understand. Again, there are a …

Member Avatar for vegaseat
1
336
Member Avatar for BustACode

Try ... sf = "For {} Root floor: {}, Ceiling: {}" n = 91 print(sf.format(n, math.floor(n**0.5), math.ceil(n**0.5))) n = 161 print(sf.format(n, math.floor(n**0.5), math.ceil(n**0.5)))

Member Avatar for vegaseat
0
456
Member Avatar for BustACode

@BustACode we just want to help you with your coding style. Python was written for readability, so yes PEP 8 is good to follow. See ... https://www.python.org/dev/peps/pep-0008/ Also, don't use unnecessary imports. They just clutter your code and are somewhat misleading. Remember ... import this The Ninja IDE helps you …

Member Avatar for vegaseat
0
376

The End.