Bucky's divide by 4 challenge

+6 Kabir Knight · May 25, 2015
Backstory: So, I was teaching my young nephew Python, as always referred him to Bucky's Python 3.4 tutorials which he posted last year (I think). So in one of the first few videos when he introduced loops, he challenged (assigned homework - his words, not mine) to leaner to write a code to print all numbers divisible 4 between 1 and 100. My nephew had very limited exposure to computers, let alone programming. He paused the video and wrote out the code (given below) in 10 minutes - all from lessons in less than 10 videos.

I just want to thank Bucky  and his buddies for the wonderful and entertaining sessions. Good job and keep it up!!!

Here's the code (Keep in mind - the first code by a 14 year old without any programming experience and less than 30 minutes of Bucky's tutorials)

divFour = []
ndivFour = []

for x in range(1,101):
 if x%4:

print('Numbers Divisible by 4 between 1 and 100 are: ')
for y in divFour:

print("Here's a list of numbers not divisible by 4 between 1 and 100: ")
for z in ndivFour:

I am not exactly sure if anyone else posted a similar code, but I was impressed.

NOTE: The original "assignment" by Bucky was just to print all multiples of 4 between 1 and 100. There was no mention of use of arrays or printing other numbers.

Post a Reply


- page 1
Oldest  Newest  Rating
0 mark uihlein · July 15, 2015
for n in range(101):
if n % 4 is 0:
0 Raaghavv Devgon · July 11, 2015
Here is my solution. :D
0 Oppai Dragon · June 30, 2015

  • i took an extra step to do a more advance version

while 1:
r = int(input("please input the range (from 0)"))
mult = int(input("multiple of what\n"))
for x in range (r-1):
if x%mult == 0:
print (mult,"x",x/mult,"=",x,"\n")
0 Halcyon Abraham Ramirez · June 28, 2015
@Majedur Rahman 

indentation that's whats wrong

indent your code propery
0 Majedur Rahman · June 25, 2015
I tried but its not working can any one help me out ??/images/forum/upload/2015-06-25/3be1887bb2597b95df0db2f549ea4cc6.PNG
0 Siddarth Krishnan · June 17, 2015
All i did was this

for f in range(0,101,4):

That is all
And this is the most straightforward way
0 Tim Samuel · June 11, 2015
I was really thinking of a million ways to do this when I decided that this would be the most straightforward and simple way to achieve it.

for n in range(101):
if n % 4 is 0:
0 Frederick Bvalani · June 7, 2015
This is what I came up with:

for n in range(1,100):
if n%4 is 0:
+1 Adam Schulz · June 5, 2015
Took me awhile but turns out re-watching your video helped me tenfold more than searching the internet these past 10 minutes...
for x in range(4, 101, 4):
0 Pavel Dimi · June 4, 2015
Well yeah that the beauty of python. Its so easy to read and understand that its pretty much just like typing normal text and doing magic :)
  • 1
  • 2



This section is all about snakes! Just kidding.

Bucky Roberts Administrator