Chapter 2 - Strings and numbers Flashcards
1
Q
How to keep the console window open?
A
input (“\nPress Enter to exit: “)
2
Q
Examples of string methods?
A
astring.upper() = return astring all in uppercase
astring.index(item) = returns the index of first occurrence of item in astring, or an error if not found
astring.find (item)= returns the index of the first occurrence of item in astring or -1 if not found
astring.replace(old,new) replaces all occurrences of old substring with new in astring,
3
Q
What are some conversion functions?
A
float(x) = converts a string to a floating point value
int(x) = converts a string to an integer
str(x) = converts a number x to a string value
4
Q
A