Python 101

Week 5:
Exercises

Expedia Code Academy

Exercises


            random_numbers = [1, 5, 0, -2, 3, -4, -3, 11, 5]
          
  • (⭐️) 5a. Using a for loop, calculate the sum of random_numbers
  • (⭐️⭐️) 5b. Print odd numbers between 1 and 50. Hint:
    
                  # Use % (known as modulo), the remainder operator
                  10 % 2  # 0, as 10 divided by 2 is 5 with no remainder
                  11 % 4  # 3, as 11 divided by 4 is 2 with a remainder of 3
                
  • (⭐️️⭐️) 5c. Create a new list containing only the negative numbers
    Hint: Use append
  • Exercises

  • (⭐️️⭐️) 5d. Bob again! Use a while loop to get Bob to continually talk to you until you say 'bye'.

  • (⭐⭐⭐) 5e. Count the number of vowels in a string provided by the user using input().
    Example: given input "hello", the program will output 2

  • (⭐️⭐️⭐️) 5f. FizzBuzz! See here for a description
  • Exercises


  • (⭐⭐⭐🔥) 5g. Print some Christmas trees! See here for a description