In: Computer Science
which statements are true about Python functions?
a)Different functions cannot use same function name
b)a function always returns some value
c)different function cannot use the same variable names
d) function must use the same parameter names as the corresponding variables in the caller
what benefits does structuring a program through defining functions bring?
a) there is a possibility of reducing the number of variables and/or objects that must be managed at any cost at any one point
b)the program is easier to maintain
c)program with function executes faster
d)the program is easier to debug
in which scenario(s) should the sentinel value be set to -1 to terminate data entry
a)exam scores which can be negative but cannot be more than 100
b) participant name of participants who registered for a run
c)the rainfall data for days it rained
d)the weight of student waiting to undergo a medical examination.
suppose d = {"a": "apple", "b": "banana", "c": "cherry"}
which statement form a list [["a": "apple"], ["b": "banana"[, ["c": "cherry"]]
a) [[k,d[k]] for k in d.keys() ]
b) [[k,v] for k, v in d.items() ]
c) [[d,v] for v in d.values() ]
d) [[k,[0]], k[1]] for k in d]
which statements are true about Python functions? a) Different functions cannot use same function name what benefits does structuring a program through defining functions bring? b)the program is easier to maintain in which scenario(s) should the sentinel value be set to -1 to terminate data entry c) the rainfall data for days it rained d) the weight of student waiting to undergo a medical examination. suppose d = {"a": "apple", "b": "banana", "c": "cherry"} which statement form a list [["a": "apple"], ["b": "banana"[, ["c": "cherry"]]
=> Actually For the last question, there are no correct
options.. The output shown itself is wrong.. Because if a list
contains the dictionary, then it will be shown like below:
[[{'a': 'apple'}], [{'b': 'banana'}], [{'c': 'cherry'}]]
A list can not contain the dictionary directly.. It should be
inside an entry..
So, if the above output is expected, then it will be created using
below statement:
print([[{k[0]: k[1]}] for k in d.items()])
************************************************** I think there is some mistake in fourth question during copy paste may be.. Thanks for your question. We try our best to help you with detailed answers, But in any case, if you need any modification or have a query/issue with respect to above answer, Please ask that in the comment section. We will surely try to address your query ASAP and resolve the issue.
Please consider providing a thumbs up to this question if it helps you. by Doing that, You will help other students, who are facing similar issue.