Question

In: Computer Science

which statements are true about Python functions? a)Different functions cannot use same function name b)a function...

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]

Solutions

Expert Solution

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.


Related Solutions

Use Python for this quetions: Write a python functions that use Dictionary to: 1) function name...
Use Python for this quetions: Write a python functions that use Dictionary to: 1) function name it addToDictionary(s,r) that take a string and add it to a dictionary if the string exist increment its frequenc 2) function named freq(s,r) that take a string and a record if the string not exist in the dictinary it return 0 if it exist it should return its frequancy.
Python 3 Forming Functions Define and complete the functions described below. * function name: say_hi *...
Python 3 Forming Functions Define and complete the functions described below. * function name: say_hi * parameters: none * returns: N/A * operation: just say "hi" when called. * expected output: >>> say_hi() hi * function name: personal_hi * parameters: name (string) * returns: N/A * operation: Similar to say_hi, but you should include the name argument in the greeting. * expected output: >>> personal_hi("Samantha") Hi, Samantha * function name: introduce * parameters: name1 (string) name2 (string) * returns: N/A...
Python 3 Functions that give answers Define and complete the functions described below. * function name:...
Python 3 Functions that give answers Define and complete the functions described below. * function name: get_name * parameters: none * returns: string * operation: Here, I just want you to return YOUR name. * expected output: JUST RETURNS THE NAME...TO VIEW IT YOU CAN PRINT IT AS BELOW >>> print(get_name()) John * function name: get_full_name * parameters: fname (string) lname (string) first_last (boolean) * returns: string * operation: Return (again, NOT print) the full name based on the first...
Which of the following statements about the acquisition / payment process is least true? The same...
Which of the following statements about the acquisition / payment process is least true? The same document is an output of the first step and an input to the second step. The document commonly used in the second step is both an output and an input. The document commonly used in the second step is never used in other steps of the acquisition / payment process. Many documents from the first step can be combined into a single document in...
USING PYTHON PROGRAM ONLY (cannot use list, max, or index function because have not learned about...
USING PYTHON PROGRAM ONLY (cannot use list, max, or index function because have not learned about it in class yet) Part C builds on parts A and B, so just need the final code from part C. USING PYTHON PROGRAM Part 4a: Addition Table Write a program that prompts the user for two integers that are greater than or equal to zero. Ensure that the first integer is less than the second integer. Next, write a program that generates an...
Which of the following statements are true different companies will use different charge of accounts based...
Which of the following statements are true different companies will use different charge of accounts based on an individual company me? The chart of accounts contains the balance all the accounts to let her? The general ledger contains all of the accounts that a company uses along with the detail balances in those accounts? The general ledger of the chart of accounts can be ordered in any sequence because they are not formally financial systems?
Which of the following statements is true about the use of a single, firm-wide cost of...
Which of the following statements is true about the use of a single, firm-wide cost of capital for evaluating all of a firm's investment projects? Question 6 options: A) Firms do not ever do that, nor should they. B) Firms that operate in multiple divisions, spanning the globe, can view their cost-of-capital calculation as diversifiable and thus use a single cost-of-capital. C) Firms operating in a single, narrow line of business are most likely to appropriately use one cost of...
You can only use built in Lisp functions and you cannot use setq function. Write a...
You can only use built in Lisp functions and you cannot use setq function. Write a function in Lisp called f1 that counts the number of lists in a list. Example: (f1 ‘(a (a b (b c)) c d (e))) returns 2
Which of the following statements is true of the functions of human resource management?
Which of the following statements is true of the functions of human resource management?
Which of the following statements about "meaning" is true? A) Group of answer choices B) Point...
Which of the following statements about "meaning" is true? A) Group of answer choices B) Point of view is synonymous with meaning. C) Setting and action are unrelated to meaning in a story ENglish 1302 D) The subject of a story states its meaning E) Meaning is made up of separate themes
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT