13 – Extra Exercises 1
From easiest to hardest.
Loops
- Write a loop that counts from 0 to 100 in 7s.
- Write a loop that outputs multiples of 2 up to 20,000,000.
- Using
switch
statements, write a set of nested loops that outputs every playing card: Ranks: Ace, 2—10, Jack, Queen, King. Suits: Clubs, Diamonds, Hearts, Spades.
Functions
- Write a function that takes a number and returns true when it is positive.
- Write a function that takes a number in Celsius and returns the same number in Fahrenheit.
- Write a separate function to do the reverse.
- Write a function that prompts the user to to enter either 1, which will convert Celsius to Fahrenheit, or 2 which will do the opposite, and accordingly return the result.
- Write a function that takes a string and returns the tally of spaces.
- Write a function that takes a string and returns the tally of non-alphanumeric characters.
- Write a function that takes a string and returns only the digits found in the string.
- Write a function that takes a string and returns the word count.
- Write a function that takes a string and reduces multiple spaces into one space.
- Write a function that takes a sentence and returns the sentence in Title Caps.