Remember: String formatting can be very useful when creating strings for printing to the console

Step 1

Using the documentation on this page write a script, that takes user input (see exercise 2). And checks whether it is (either)1:

  1. uppercase
  2. numeric
  3. contains the substring ":-)"2 or
  4. none of the above

report which of these it was. If multiple branches are true, you need only report one.

Step 2

Expand the ‘uppercase’ branch, to not only report that it was uppercase, but also print a lowercase version. 3

Step 3

Expand the ‘numeric’ branch to request a second number from the user and then reporting the sum of the two numbers. 4

Step 4

Expand the ‘none of the above’ branch to split the string at every letter ‘a’ 5 and join these strings together into a new string, inserting semicolons between them. 6

'aglloatyat' -> ['', 'gllo', 'ty', 't'] -> ';gllo;ty;t'

  1. python does not have a case statement ↩

  2. The using in checks for subelements and substrings as well. ↩

  3. Python String Documentation Page ↩

  4. Typecasting is done by calling the constructor of the target type on the source value* ↩

  5. Strings can be split with the split(separator) method. This method also accepts a second parameter (int) how often it should split the string at maximum. ↩

  6. Strings are joined with the separator_string.join(['list', 'of', 'strings']) method. ↩