0% found this document useful (0 votes)
36 views

Computer Science Homework Answers Personalized

Uploaded by

sinhaop565
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
36 views

Computer Science Homework Answers Personalized

Uploaded by

sinhaop565
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Computer Science Homework Answers - Class XII

Prepared for: Soma Chaudhary

Date: June 7, 2024

1. 'in' is a logical operator in Python.

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.

2. Which of the following is an invalid variable?

Answer: (b) 1st_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, "Reshm

Answer: (a) True#False

Explanation: "John" is a key in the dictionary D, so 'John' in D returns True. However, 90 is a value,

not a key, so 90 in D returns False.

4. Consider the following expression: not True and False or not False

Answer: (a) True

Explanation: The expression evaluates as follows: not True is False, False and False is False, and

not False is True. Finally, False or True is True.

Page 1
Computer Science Homework Answers - Class XII

5. Select the correct output of the following code:str1 = 'India is a Great Country'str1.

Answer: (a) ['Indi', ' is ', ' Gre', 't Country']

Explanation: The split() function splits the string at each occurrence of 'a', resulting in the list ['Indi', '

is ', ' Gre', 't Country'].

6. Consider the tuple in python named DAYS=("SUN","MON","TUES"). Identify the inv

Answer: (c) DAYS[0]="WED"

Explanation: Tuples are immutable, meaning their elements cannot be changed after their creation.

Therefore, trying to assign a new value to DAYS[0] is invalid.

7. How will the following expression be evaluated in Python?2 + 9 * ((3 * 12) - 8 ) / 10

Answer: (a) 29.2

Explanation: Following the order of operations (PEMDAS/BODMAS):

First, calculate inside the parentheses: (3 * 12) = 36.

Next, subtract: 36 - 8 = 28.

Then, multiply: 9 * 28 = 252.

Next, divide: 252 / 10 = 25.2.

Finally, add: 2 + 25.2 = 27.2.

8. Given is a Python string declaration:myexam='@@CBSE Examination 2022@@'Wr

Answer: @@

Explanation: The slice [-2:] gets the last two characters of the string.

Page 2
Computer Science Homework Answers - Class XII

9. Write the output of the code given below:my_dict = {"name": "Aman", "age": 26}my

Answer: dict_items([('name', 'Aman'), ('age', 27), ('address', 'Delhi')])

Explanation: The items() method returns a view object that displays a list of a dictionary's key-value

tuple pairs. Here, we updated the 'age' and added 'address'.

10. Predict the output of the Python code given below:K=[]for i in range(4): K.appen

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

You might also like