Cool python script to have fun learning Python teens in programming?

So, I teach my son's friends some kind of python programming, just controlling the flow, the basic data types / structures.

I want to go through a textbook through it and, I hope, create something simple, but healthy, so that he will be delighted with the power of the python.

Any ideas?

+8
python
source share
7 answers

Take a look Come up with your own Python computer games from Albert Sweigart.
It was written for beginners. It is available on the link website, but you can also buy the book if you want.
There is a blog with additional material with good games like classic gorillas or tetris.

+13
source share

Teach him a map, zoom out, lambda and other simple things :)

And then show him this code to find the factorial of a series of numbers on one line.

 (lambda k: reduce (int .__ mul__, range (1, k + 1), 1)) (8)

He will surely be thrilled

+10
source share

If he's in math, http://projecteuler.net/ might be worth checking it out.

What is Project Euler?

Project Euler is a series of complex mathematical / computer programming problems that will require more than just mathematical information to solve. While math will help you come up with elegant and effective methods, using computer skills and programming skills needs to solve most problems.

+3
source share

I know something simple, some children who had fun messing around with it are very helpful just by looking, as this will help the kid learn a little.

age = input("How old are you?: ") if age > 60: print "If you're", age, "years old then why the **** are you clicking my python script?" if age < 60 and age > 18: print "Good for you..." if age < 18: print "You're", age, "shouldn't you be doing homework or something?" import os os.system("pause") 
+3
source share

Yes,

ths might work .. im currently just for fun reading some things on encryption, i dont know what it is exactly, but what it can do is use python to be able to encrypt the message and perform some string manipulations.

something simple to demonstrate what i mean:

 plaintext = list('ABCDEFGHIJKLMNOPQRSTUVWXYZ') encrytedtext = list('DEFGHIJKLMNOPQRSTUVWXYZABC') def message(text, plain, encryp): dictionary = dict(zip(plain, encryp)) newmessage = '' for char in text: try: newmessage += dictionary[char] except: newmessage += ' ' print text, '\nhas been encrypted to:' print newmessage 

("SEND MATERIAL NOW")

: LTFR ZIT DQZTKOQS FGV

no power md5 etc. but only basic letter replacement scheme

now also get random sequences and then try to crack them

eg:

"EKNHZGUKQHIN OL ZIT LEOTFET ZIQZ EKTQZTL ZIT EOHITK LNLZTDL XLTR ZG IORT DTLLQUTL YKGD XFOFZTFRTR KTEOHOTFZL."

 Notice first that the most frequent cipher letter is T, probably replacing the E. The 3-character stretch ZIT which appears twice could very well be THE and since Z stands for T in that case, the word ZIQZ might be THAT. The 6th word now reads **EATE* whose completion CREATES appears as a good choice. At this point, these successive guesses yield the following partial decryption scheme, Alphabet: ACEHRST Substitution: QETIKLZ 
+2
source share

You can try using the turtle built-in module to create fractals such as the Koch snowflake .

+1
source share

The game is clearly a nice thing. Maybe Tetris or Snake?

While the files on the command line are wonderful, since you donโ€™t have to worry about the graphic material, they can be boring for a child.

0
source share

All Articles