- Pick a language that is not English and look up how to say a few common phrases, such as "Hello", "Goodbye", etc
- Creates a dictionary with these common phrases from the languages selected as the key and their English translation as the values.
- Display a "Welcome" message to the user describing the programmer's purpose.
- Display a list of the phrases from the selected language to the user. Hints: Use the ".keys()" method of the dictionary class.
- Ask the user to type in a phrase to translate.
- Display to the user the phrase they selected and what its English translation is.
- The program should look like this:
All standard sequence operations work with strings
- Indexing
- Slicing
- Multiplication
- Membership
- Length
- Minimum
- Maximum
- Strings are immutable
- All item or slice assignments are illegal
You can not assign a value to a part of a string. You can "Reassign" a new string to a variable, however.
%s parts are "conversion specifiers. Use format to display values.
Conversion specifies where to insert values. "s" means values should be formatted as strings. If they aren't strings, Python uses the _str_ function to convert them to strings. To include a percent sign in a format string, use %%
3 decimal positions of precision.
- Python.org documentation has a complete list of string methods
- The following slides are a sample of methods available.
If the string is not found, it returns -1
The first number is inclusive. Last is exclusive.
- rfind
- index
- rindex
- count
- startswith
- endswith
Can not join string to int.
If no parameters are set default is any whitespace character(space, tab, etc).
Don't forget space!