Posts Tagged 'python'

Things we do while waiting for the NVC: counting

The NVC has still not invoiced us for the IV-package (the last package of information they need to give us a ‘case complete’  and send our paperwork to the consulate). I’m getting mightily impatient. Why are they so slow in asking us for money? I’m pretty much waving dollar bills in their face as if they’re a second hand book store, but so far to no avail.

However, there is plenty of other stuff to keep us occupied. We’ve signed up for an ‘Open House Day’  to get more people to come look at our house. We obtained the board game Pandemic and are totally in love with it. We’ve taken walks and cooked food and did other things of which I will yet write.

And, I’ve been programming. A while ago, I asked Beloved to, as a birthday present, buy me a book that would allow me to learn some basic programming. He gave me this:

I recommend Python Programming for the Absolute Beginner by Michael Dawson wholeheartedly. I mean.. I’m pretty smart. I’m not totally computer illiterate. Sure, I may have an unrealistic amount of Command Line Interface Anxiety*, but I did once, singlehandedly, install Debian on my computer. I even taught Debian which of the three soundcards present in that computer should be used (but don’t ask me why there were three to begin with). Still.. programming is a realm of arcane knowledge that just doesn’t look all that accessible to the average liberal-artsy educated almost-thirty-year-old.

However, I decided that programming would be a good thing to learn and I had an inkling that I might like it. I am, after all, a writer, editor and translator by profession and one programs by means of a language, right? I figured that if I just told myself that translating from human to human is not that far removed from translating from human to computer, this could be a fun experience. So far, it has been. The learning curve in the book is not as steep as other materials I had sampled (and which were all disheartening, really). The approach is lighthearted and fun and practical.

So, currently, I am working  on the tail end of chapter four. At the end of each chapter, there are little challenges to help you be more creative with the things you’ve learned so far. And just now, I managed to complete one of the challenges in less than ten minutes and have it execute perfectly. I didn’t even make a single typo or forgot a single bracket, even though I made a point of typing everything from scratch. I’m proud, mmkay?

The few lines below make a little counter program. It allows the user to indicate an integer at which to start counting and one at which to stop counting. You also indicate how big the count interval has to be. The program then counts for you and shows all the numbers it counts.


# Challenge 1 - Autocount
# Shows learning in chapter 4.
# by Smitten Immigrant, March 12, 2013

# introduce program
print ("\n\nWelcome to AutoCount")

# ask for user input
startnr = int(input ("\n\nType the number at which I start counting:"))
endnr = int(input ("\n\nType the number at which I stop counting:"))
interv = int(input ("\n\nType at what interval I should count:"))

# run the counter and show count
print ("\n\nYour count is:")
for i in range (startnr, endnr, interv):
 print (i, end=",")

# end program
input("\n\nPress the enter key to exit.")

* You see.. Breaking a computer by pointy-clicky navigation is really hard. I don’t even know if I could do it if I tried. The command line interface is a wholly different beastie, though. You can type things there and I have this suspicion those words can break things. So far, not one of my geek-friends has seen fit to disabuse me of the notion.

Advertisements