p.13
Finding and Replacing Substrings
What does the replace() command do?
It replaces all occurrences of a specified substring in a string.
If you have 5 miles, how many kilometers does that equal?
Approximately 8.04672 km.
p.19
Tuples as Data Sequences
What is required for swapping values using tuples?
The variables must be elements of the tuple.
p.5
String Data Type in Python
What type of object is created when using num_one = 'one'?
An object of type str with the value 'one'.
p.24
User Interaction with Input
What is the purpose of storing input in a variable?
To hold data that can be used later in the program.
p.22
User Interaction with Input
What should be included in the parentheses of the input() command?
A string object that represents the prompt for the user.
p.16
Tuples as Data Sequences
What does the len() function do when used on a tuple?
It returns the number of objects inside the tuple.
p.15
Tuples as Data Sequences
What does the tuple (1, "2", False) contain?
An integer, a string, and a Boolean object.
p.20
User Interaction with Input
Can you print multiple expressions in one print statement?
Yes, by separating them with commas, e.g., print('Value:', value).
p.13
Finding and Replacing Substrings
What is the result of the command 'variables have no spaces'.replace(' ', '_')?
'variables_have_no_spaces'.
p.5
String Data Type in Python
What does the statement num_two = '2' create?
An object of type str with the value '2'.
p.17
Tuples as Data Sequences
How do you index into a tuple?
You use the [] operator, similar to indexing into a string.
p.24
User Interaction with Input
What is an example of storing input in a variable?
name = input('Enter your name: ')
p.14
Mathematical Operations on Strings
What is concatenation in the context of strings?
Addition of two string objects.
p.12
Finding and Replacing Substrings
Can the count() method be used to count overlapping substrings?
No, it counts only non-overlapping occurrences.
p.15
Tuples as Data Sequences
What is a tuple in Python?
A data type that represents a sequence of any objects.
p.4
String Data Type in Python
Can a string in Python contain numbers?
Yes, for example, "525600".
p.15
Tuples as Data Sequences
What does the tuple (5, (6, 7)) contain?
An integer and another tuple made up of two integers.
p.16
Tuples as Data Sequences
What is the result of len((3, 5, '7', '9'))?
4, because the tuple has four elements.
p.13
Finding and Replacing Substrings
Does the replace() command replace only the first occurrence of a substring?
No, it replaces all occurrences.
What is the output format for converting 5 miles?
miles 5 km 8.04672 meters 8046.7
p.9
String Case Conversion Methods
What does the capitalize() method do?
It converts the first character to uppercase and the rest to lowercase.
p.5
String Data Type in Python
Why is '2' considered a string in the context of num_two?
'2' is a string and not the integer 2.
p.10
Finding and Replacing Substrings
What can you search for using the find() command?
A particular substring inside a larger string.
p.21
User Interaction with Input
Can you print different data types together in Python?
Yes, Python allows printing different data types together using the print() function.
p.9
String Case Conversion Methods
What does the swapcase() method do?
It converts lowercase letters to uppercase and vice versa.
p.20
User Interaction with Input
How do you print a simple string in Python?
Using the print() function, e.g., print('Hello, World!').
p.19
Tuples as Data Sequences
What can you use tuples for regarding variable names?
To swap the object values associated with variable names.
p.1
User Interaction with Input
What are the main topics covered in Session 3 of ISEM 2006?
Strings, Tuples, and Interacting with The User.
p.24
User Interaction with Input
How do you store user input in a variable in Python?
By using the input() function and assigning it to a variable.
p.12
Finding and Replacing Substrings
What parameters can be passed to the count() method?
Optional start and end parameters to specify a substring search range.
p.9
String Case Conversion Methods
What does the lower() method do in Python?
It converts all letters in the string to lowercase.
p.21
User Interaction with Input
How can you print multiple objects in Python?
By using the print() function with commas to separate the objects.
p.4
String Data Type in Python
What is an example of a string with spaces and special characters?
"a long string with Spaces and special sym&@L5_!".
p.20
User Interaction with Input
What is the purpose of printing expressions in Python?
To display output to the user.
p.11
Finding and Replacing Substrings
What does the expression '"a" in "abc"' evaluate to?
True, because the substring 'a' is in the string 'abc'.
p.22
User Interaction with Input
How do you prompt the user to input their name using input()?
By placing a string object in the parentheses of input(), like input('Enter your name:').
p.14
Mathematical Operations on Strings
What are the two mathematical operations that can be performed on string objects?
Addition (concatenation) and multiplication (repetition).
p.21
User Interaction with Input
What will happen if you print multiple objects without commas in Python?
It will result in a TypeError because Python will not know how to concatenate them.
p.16
Tuples as Data Sequences
What type of data can be included in a tuple?
Tuples can include various data types, such as integers and strings.
p.13
Finding and Replacing Substrings
What are the two items you need to provide in the parentheses for replace()?
The substring to find and the substring replacement, separated by a comma.
p.6
String Indexing and Slicing
What is indexing into a string?
Determining the value of a character at a certain position in the string.
p.21
User Interaction with Input
What is the purpose of printing multiple objects in programming?
To display information or results from various variables or data structures at once.
p.24
User Interaction with Input
Can you store different types of input in a variable?
Yes, input can be stored as strings, integers, or other data types depending on conversion.
p.14
Mathematical Operations on Strings
What does multiplication of a string by an integer represent?
Repetition of the string.
p.20
User Interaction with Input
How can you format strings when printing in Python?
Using f-strings or the format() method.
p.11
Finding and Replacing Substrings
How can you check if a substring is in a string in Python?
By using the keyword 'in'.
p.2
Temperature Conversion
If the temperature in Fahrenheit is 75, what is the Celsius equivalent?
Celsius value is approximately 23.89.
p.10
Finding and Replacing Substrings
In what scenarios might you use the find() command?
To check if a specific file exists or to search for a word in a text document.
p.18
Tuples as Data Sequences
How can you repeat a tuple multiple times?
By multiplying it by an integer.
p.7
String Indexing and Slicing
What is the process of extracting data from a string called?
Getting a substring of the string.
p.9
String Case Conversion Methods
What does the upper() method do in Python?
It converts all letters in the string to uppercase.
p.15
Tuples as Data Sequences
Why is there an extra comma in the singleton tuple (5,)?
To indicate that it is a singleton tuple and not for mathematical precedence.
p.20
User Interaction with Input
What happens if you try to print a variable that hasn't been defined?
It will raise a NameError.