# Tag Archives: python

Coding Club today.

There’s a chance I may be getting more takers for my ‘Codecademy’ – based coding club at FSCC soon. Several students have shown interest and I look forward to opening up the class towards becoming a more open space with students (including myself) pursuing a number of projects simultaneously.

If anyone (local, at least) is interested in joining our group, please feel free. We take all comers and look forward to building our numbers with anyone interested in learning, teaching or challenging themselves.

If you’re not local, I’d still be interested in hearing from you if you’d like to start an online learning community tied to codecademy, code school, or any other online resource.

Posted by on August 30, 2013 in Uncategorized

## New Coding Challenge – The Quincunx!

The Quincunx – A triangular pegboard that will create a nice normal distribution as balls are dropped from the top and bounce down randomly over the triangular array of pegs.

Society’s greatest achievement, The Price Is Right, demonstrates the use of a plinko board in this video with the most excited player ever.

The coding challenge is to design a quincunx that demonstrates each of the following four points… No animation is required, simply (1)show the board as an array of X’s with a (2) user-determined number of rows (1-20) and the (3)resulting bins filling with integers as a (4)user-determined number of balls (1-100,000) is dropped. This time, I’m awarding prizes to the cleanest, most clearly documented entries in each language represented on Codecademy (Ruby, JS, Python).

As always, the prizes are bragging rights, presentation of your code on my blog with full attribution to you and a promo copy of any of my eBooks on iPad for you to share with the youngster in your life (or keep yourself). Each of my books presents educational material  in the form of a story (Heracles and the Gas Laws, Sisyphus and the Laws of Motion, Zombies and Fractions).

Happy Coding!

Posted by on July 10, 2013 in Uncategorized

## RubyMonk

I mention codecademy all the time here and rant about how great a way it is to learn a variety of languages and markups online, on your own time and free. I’ve been following both the web programming track and the Ruby tracks aggressively lately (I’m on a 20 day streak presently). However, I have to also mention another free site that does much the same thing. RubyMonk offers free online courses in Ruby (and Python, under PythonMonk). The Monk websites are clean, well structured and provide an element of atmosphere as well.

Unfortunately, RubyMonk does not provide a forum where I can pitch my project challenges – er, I mean Koans. But if you are learning Ruby or Python with the Monk, please feel free to come here from time to time to see if there are any simple programming challenges open.

Posted by on June 28, 2013 in Uncategorized

## Winding down Coding Challenge I

I’ve received several entries answering my coding challenge to demonstrate / test Goldbach’s Conjecture that all even numbers > 4 are the sum of two primes. So far python has been the language of choice for entries.

I will be closing down this challenge as of June 30 at 11:59pm.

Once I take a look at the entries, I’ll award the prize, a copy of my iBook, In Parts to the winner and post the code here with a walkthrough to show how the problem was tackled as well as any interesting comparisons between entrants.

Posted by on June 26, 2013 in Uncategorized

## Coding Challenge II: Make Mine a MASTERmind

Don’t worry, Coding Challenge I is still open, but someone was writing about games to develop in the codecademy discussion groups.

A while ago, when I was first following the JavaScript pathway, there, I decided to write a MasterMind program. Many of the versions I saw prohibited players from using the same number/color more than once, but I felt that was a cop-out. My solution works, but as usual for me, had some tortuous logic.

So, here’s the challenge:

In any language, write a MasterMind game where the computer chooses the numbers and the user deduces them.

1. use numbers (four of them,#s1-4, randomly chosen by the computer), rather than colors

2.  that allows multiple uses of the same numbers, i.e. ‘1122’

3. provides appropriate feedback to the user to help them close in on the correct sequence.

4. keeps track of the number of turns taken

5. (optional) can also be played with 2 users -or- user sets the code and computer guesses

6. (optional) allow user to select # of positions and range of numbers used.

simple code trumps tangly code. I prefer languages I can read (C++, javascript, python) but all are welcome.

Posted by on June 22, 2013 in Uncategorized

## Coding Challenge

Recently, there have been a couple new revelations about number theory published in Science Within the article was a pair of theories about prime numbers that I had never heard before, one of which was:

Goldbach’s conjecture, [which] makes two assertions: that every even number greater than 2 is the sum of two primes, and that every odd number greater than 5 is the sum of three primes.

I thought it would be fun to start with the first part of this problem and write a program to accept user input in the form of an even integer > 2  and then look for the two primes whose sum is equal to the user provided:

prime1 + prime2 = user input

where prime1 and prime2 may be any prime number (even the same number twice)

I could easily see this escaping the processing power of my machine if the numbers get high, but I think it shouldn’t be too hard to at least write a code that could look for them and demonstrate whether this worked with known input.

Are you up for a quick challenge?

Learn Fractions with Zombies

If so, submit your documented answer here as a comment. Feel free to use any language you would like (I just did it in C++, but I’m eager to see better answers than my own). My favorite submissions will win a free copy of  my iBook, In Parts, Tales of Fractional Zombies, which you can enjoy yourself or regift to a youngster in your life who wants a fun way to learn the concept of fractions.

You can use these links as resources to help check your work:

If you are new to coding and are looking for a coding environment to work in, check out this posting for help setting up a C++ coding environment using Xcode (on your mac)

Posted by on June 19, 2013 in Codecademy, Coding

## Two minutes into my latest coursera lecture….

Two minutes into my latest coursera lecture (introduction to interactive programming in python) the instructor indicated his frustration in javascript programming saying that it’s a terrible language. This may be the case… so far I don’t have a lot to compare against, but I have been enjoying learning JS in codecademy and I’m dying to know why he thinks so.

If you have experience programming in javascript and python (or other languages…ruby?) let me know if you agree with the above statement and what makes you think so. As a new programmer I am interested in learning as much as possible – if I can understand what faults people see in these languages I think that would be very instructive.

Thanks

Posted by on October 25, 2012 in Uncategorized

## Rock Paper Scissors Lizard Spock

The first project in ‘An Introduction to Interactive Programming in Python’, a course I am taking / watching in Coursera is writing code to analyze the results of randomly generated  rock paper scissors lizard Spock games. This game is an adaptation of the standard rock paper scissors with two added items… because it comes from Big Bang Theory, of course it has Spock.

By the way, we often play Rock Paper Scissors at home, but try to come up with new symbols  fairly often.

(Alien populates asteroid, asteroid smashes spaceship, spaceship shoots alien)

(The witch commands the flying monkeys, The flying monkeys carry away Dorothy, Dorothy melts the witch)

The trick for me when writing this code was remembering to import the random module and getting the syntax correct for the if/elif/else statements:

if difference == 1 or difference == 2:
winner = “player”
if difference == 3 or difference == 4:
winner = “computer”
if difference == 0:
winner = “tie”

Posted by on October 17, 2012 in Uncategorized

## Just a quick note, then off to bed

Codecademy is now adding python modules. I look forward to pursuing this even more than the javascript courses (although I’ll keep up with them as well). I’ve also just signed up as a beta tester for new javascript and python courses. You should do the same if you’re also interested in coding and education.