6 ms·
If I'm teaching young'ns per se using a toy language, I'd reach for Scratch. It's history and Google's embrace of it seem like strong endorsements. Are there ot
by braindongle 6y ago
If I'm teaching young'ns per se using a toy language, I'd reach for Scratch. It's history and Google's embrace of it seem like strong endorsements. Are there other good candidates in that space?
If I'm teaching an intro class using a general purpose language, it's Ruby or Python. My heart lies with Ruby, but having basic Python chops is such a bigger win downstream.
for i in range(1, 101):
if i % 15:
print ('FizzBuzz')
elif i % 3 == 0:
print ('Fizz')
elif i % 5 == 0:
print ('Buzz')
else:
print (str(i))
(1..100).each do |i|
if i % 15 == 0
puts 'FizzBuzz'
elsif i % 3 == 0
puts 'Fizz'
elsif i % 5 == 0
puts 'Buzz'
else
puts i
end
end
- deleted 6y ago[deleted]
- setpatchaddress 6y ago(1..100).each do |i| puts case when i % 15 == 0 'FizzBuzz' when i % 3 == 0 'Fizz' when i % 5 == 0 'Buzz' else i end end
- hobby-coder-guy 6y agoWhy is this better?
- braindongle 6y agoYes, cleaner, and no switch in Python.
- anitil 6y ago(offtopic) You might be missing an '== 0' in the second line there? I've never done fizzbuzz so I honestly don't know, but the ruby version has it.
- Semiapies 6y agoZero and empty lists and dictionaries are treated as False in Python.