Computer Science Homework Answers Explained
Computer Science Homework Answers Explained
Answer: True
Explanation: In Python, 'in' is used to check if a value is present in a sequence, such as a list, tuple,
or string.
Explanation: Variable names cannot start with a number. Valid variables can start with a letter or an
underscore.
3. What will be the output for the following Python statements?D= {"Amit":90, "Reshma":96, "Suhai
Explanation: "John" is a key in the dictionary D, so 'John' in D returns True. However, 90 is a value,
4. Consider the following expression: not True and False or not False
Explanation: The expression evaluates as follows: not True is False, False and False is False, and
5. Select the correct output of the following code:str1 = 'India is a Great Country'str1.split('a')
Explanation: The split() function splits the string at each occurrence of 'a', resulting in the list ['Indi', '
Page 1
Computer Science Homework Answers - Class XII
6. Consider the tuple in python named DAYS=("SUN","MON","TUES"). Identify the invalid statement
Explanation: Tuples are immutable, meaning their elements cannot be changed after their creation.
Answer: @@
Explanation: The slice [-2:] gets the last two characters of the string.
9. Write the output of the code given below:my_dict = {"name": "Aman", "age": 26}my_dict["age"] =
Explanation: The items() method returns a view object that displays a list of a dictionary's key-value
Page 2
Computer Science Homework Answers - Class XII
10. Predict the output of the Python code given below:K=[]for i in range(4): K.append(2*i+1)print(K
Answer: [7, 5, 3, 1]
Explanation: The loop appends the odd numbers 1, 3, 5, 7 to the list K. The slice [::-1] reverses the
list.
Page 3