Worksheet 1

Worksheet 1#

Exercise (For loop)

Level:

Take the code used to do Exercise 8 but this time, for each iteration, print the index of the word in list l next to the string.

Exercise (Odd and even numbers)

Level:

Modify the code that identifies an odd or even number to create a list of even numbers, and another list of odd numbers.

Exercise (Simple calculator)

Level:

Creat a program that works like a simple calculator:

  • First, print a user menu that shows the operations available with this calculator: 1. Addition
    2. Subtraction
    3. Exit

  • Then ask the user to enter two numbers.

  • The calculutaor would then add or subtract these two numbers depending on the operation selected previously.

Tip

The input() function is used to read in the user’s input from the console.