Python

2.More assignments

1. The Vowel Counter (String Analysis)

Instead of just checking for one character (like the "!" in the previous suggestion), in this task you should look for several specific characters.

  • The Task: Ask the user to type a sentence. The program should loop through the sentence and count how many vowels (a, e, i, o, u) are in it.
  • Concepts: for loops, if statements with multiple conditions (or), and "accumulator" variables (e.g., count = count + 1).
  • The "Aha!" Moment: Realizing that a string is just a collection of characters you can inspect one by one.

2. Rock, Paper, Scissors (Logic & Comparison)

This is the ultimate test of if/elif/else logic. It doesn't require complex loops, but it requires "nested" logic (if inside an if).

  • The Task:
  1. Player inputs "rock", "paper", or "scissors".
  2. Computer picks one randomly.
  3. Use if statements to determine the winner.
  • Concepts: Random selection, comparing strings, handling a "Tie" vs. "Win" vs. "Loss."
  • The "Aha!" Moment: Seeing how many different outcomes need to be accounted for in a simple game.

3. The "Even-Odd" Sum (Looping with Math)

This moves away from strings and focuses on the relationship between loops and numbers.

  • The Task: Ask the user for a number (e.g., 20). The program should loop from 1 to that number and:

  • Print whether each number is "Even" or "Odd".

  • At the very end, print the sum of all the even numbers it found.

  • Concepts: range(), the modulo operator % (to check for even numbers), and keeping a running total.

  • The "Aha!" Moment: Using a loop to do math that would be tedious to do by hand.


Comparison of Practice Goals

Assignment Primary Focus New Skill
Vowel Counter for loops Using a variable to "keep track" of a count.
Rock, Paper, Scissors if / elif / else Organizing complex logic/rules.
Even-Odd Sum range() + Math Using % 2 == 0 to identify patterns.