- str type
- String concatenation operator: +
- Substring operators: in, not in
- String indexing, e.g. if mascot = "hawks", mascot
- String comparison: <, <=, = =, >, >=, !=
- String slicing, e.g. mascot[1:3]
- Common methods:
- Determining length: len
- Related to case: upper, lower, capitalize
- Related to whitespace: strip, lstrip, rstrip
- Related to formatting: center, ljust, rjust
- Related to finding substrings: find, rfind, index, rindex
- Related to counting occurrences: count
- Useful constants:
- Online Documentation
- Construct simple examples in the Python shell to illustrate
that you understand the concepts above.
- Write a program that implements a Caesar cipher on lowercase
letters. For example, if the key is 2, each letter is replaced
by the letter that comes 2 positions later in the alphabet.
For example, "a" becomes "c" and "z" becomes "b".
- Download and experiment with demo.py
until you understand it fully. Why can the alternate_case
function be called with either one or two arguments? How would
you explain what the alternate_case function does
to someone who knows nothing about computer science?
- Write a function named double_integer that repeatedly asks the
user to enter an integer until a non-negative integer is entered.
The function should then return twice the integer's value.
For example, the user might enter "apple", then "3.14", then "-34", then
"34". In this example, the function should return 68.