For Loops Challenges

For this set of challenges, we are going to teach our AI:Bot some basic maths skills such as how to count in 5 from 0 to 500 or how to count down from 100 to 0. We are also going to make our AI:Bot practise the times tables.

But first we need to make sure that our AI:Bot is fully focused and willing to complete the work when asked to. So let him learn our expectations by making the AI:Bot copy the following lines on the screen:

Can you tweak the code below for the following line to appear 100 times on the screen:

“I will listen to my teacher and complete my work on time.”

Counting in 5

We are now going to use a step in our for loop to count in 5.

Check the code below and tweak it to train your AI:Bot to count in 5 from 0 to 500.

# Counting in 2 from 0 to 100
for i in range(0,100, 2):
   print(i)

Counting down

Tweak the code above to train your AI:bot to count down from 100 to 0! (Tip you will have to use a negative step of -1)

Times Tables

Train your AI:Bot to display the 12 times table as follows:

Once done, tweak your code so that it starts by asking for a number. It will then display the times table for this given number.

Did you like this challenge?

Click on a star to rate it!

Average rating 5 / 5. Vote count: 2

No votes so far! Be the first to rate this post.

As you found this challenge interesting...

Follow us on social media!