Commands And Requests
11 previous year questions.
High-Yield Trend
Chapter Questions 11 MCQs
While defining a function in Python, the positional parameters in the function header must always be written after the default parameters.
If the content of the file STORY.TXT is:
Our parents told us that we must eat vegetables to be healthy. And it turns out, our parents were right! So, what else did our parents tell? Then the function should display:
Our parents told us that we must eat vegetables to be healthy.
And it turns out, our parents were right!
So, what else did our parents tell? def callon(b=20, a=10): b = b + a a = b - a print(b, "#", a) return b x = 100 y = 200 x = callon(x, y) print(x, "@", y) y = callon(y) print(x, "@", y)
A tuple named subject stores the names of different subjects. Write the Python commands to convert the given tuple to a list and thereafter delete the last element of the list.
Write a user-defined function in Python named showGrades(S) which takes the dictionary S as an argument. The dictionary S contains Name: [Eng, Math, Science] as key:value pairs.
The function displays the corresponding grade obtained by the students according to the following grading rules:
Example: Consider the following dictionary: The output should be:
XML, PPP Give one difference between circuit switching and packet switching.
Consider the following Python statement:
F = open('CONTENT.TXT')
Which of the following is an invalid statement in Python?
F.seek(1, 0)
F.seek(0, 1)
F.seek(0, -1)
F.seek(0, 2)
While handling exceptions in Python, name of the exception has to be compulsorily added with except clause.
event = "G20 Presidency@2023"
L = event.split(' ')
print(L[::-2])
'G20'
'Presidency@2023'
'G20'
'Presidency@2023'
d = dict()
e = {}
f = []
g = dict{}
myStr[:4]extracts the first 4 characters, which are"MISS".myStr[-5:]extracts the last 5 characters, which are"SIPPI".- These two substrings are concatenated with a
"#"in between, resulting in"MISS#SIPPI".
YELLOW # RED #
GREEN # RED #
YELLOW # GREEN #