September 2009
5 posts
2 tags
Numbers, Python
Write a program which tells you: how many hours are in a year? how many minutes are in a decade? how many seconds old are you? Code: print 24*365, 60*24*365*10, (60*60)*((365*32)+(30*8)) Output: 8760 5256000 42912000 Harder: If I am 1031 million seconds old, how old am I? print '1,031,000,000 seconds = %s minutes' % (1031000000/60) print 'or %s hours' % (1031000000/(60*60)) print 'or...
Sep 13th
2 tags
Numbers, PHP
Write a program which tells you: how many hours are in a year? how many minutes are in a decade? how many seconds old are you? Code: <?php echo 24*365, ", ", 60*24*365*10, ", ", (60*60)*((365*32)+(30*8)); ?> Output: 8760, 5256000, 42912000 Harder: If I am 1031 million seconds old, how old am I? <?php echo "1,031,000,000 seconds = ", 1031000000/60, " minutes<br>"; ...
Sep 13th
2 tags
Numbers, Ruby
Write a program which tells you: how many hours are in a year? how many minutes are in a decade? how many seconds old are you? Code: puts 24*365, 60*24*365*10, (60*60)*((365*32)+(30*8)) Output: 8760 5256000 42912000 Harder: If I am 1031 million seconds old, how old am I? minutes = 1031000000/60 puts '1,031,000,000 seconds = ' + minutes.to_s + ' minutes' hours = minutes/60 puts 'or '...
Sep 13th
2 tags
Numbers, Perl
Write a program which tells you: how many hours are in a year? how many minutes are in a decade? how many seconds old are you? Code: #!/usr/local/bin/perl print 24*365, ", ", 60*24*365*10, ", ", ((60*60)*((365*32)+(30*8))); print "\n"; Output: 8760, 5256000, 42912000 Harder: If I am 1031 million seconds old, how old am I? #!/usr/local/bin/perl print "1,031,000,000 seconds = ",...
Sep 13th
1 note
1 tag
The Point
This site is an attempt to work through Learn to Program by Chris Pine. I don’t know the fundamentals as well as I should. I’m very good with HTML, CSS, and JS, but web technologies have rapidly moved far beyond these client-side languages. I don’t have a firm grounding in any server-side language. Learn to Program teaches Ruby, but its concepts are language-agnostic....
Sep 13th