This section contains carefully selected MCQs and Previous Year Questions with explanations to help students understand concepts and prepare effectively for examinations, interviews, and competitive tests.
Q: 1The given declaration statement in Python Language belongs to which data type?
>>>Student ={‘SUBJECT’ : ‘Compiler’, ‘Marks’ : ‘50’, ‘Grade’ : ‘C’}
Option D
In Python, a Dictionary is a data type used to store data in the form of key–value pairs. Dictionaries are enclosed within curly braces { }. Each key is associated with a value using a colon : (colon).
In the given statement Student = {'SUBJECT':'Compiler', 'Marks':'50', 'Grade':'C'}
Q: 2What is output of the code in Python Language:
>>> str1 = ‘All the Best’
>>> str1[-3]
Option B
In Python, negative indexing is used to access characters from the end (right side) of a string.
| Positive Index | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Character | A | l | l | t | h | e | B | e | s | t | ||
| Negative Index | -12 | -11 | -10 | -9 | -8 | -7 | -6 | -5 | -4 | -3 | -2 | -1 |
The character at index str1[-3] is 'e'.
Q: 3What will be the output of the following Python script?
>>>L=[‘spam’, ‘Spam’, ‘SPAM!’]
>>>L[-2]
Option A
In Python, negative indexes count from the end of the list.
Positive Indexing starts from left to right:
Index: 0 1 2
Value: 'spam' 'Spam' 'SPAM!'
Negative Indexing start from right to left:
Index: -3 -2 -1
Value: 'spam' 'Spam' 'SPAM!'
You have reached the end of this topic. Continue learning with the next topic below.
Thank you so much for taking the time to read my Computer Science MCQs section carefully. Your support and interest mean a lot, and I truly appreciate you being part of this journey. Stay connected for more insights and updates! If you'd like to explore more tutorials and insights, check out my YouTube channel.
Don’t forget to subscribe and stay connected for future updates.