Am new to programming. How do I understand the argument function well
Could you clarify what you are having trouble understanding? Maybe show an example of the syntax and ask more specific questions about the example?
question
the exercise will explore the different ways you can specify arguments to a functions
for the question define the following function and then answer the following questions
def president (d _ votes, r _ votes, current = ’ donald trump’, d _ nominee = ’ joe biden’, r nominee = ’ donald trump’)
print (" the current president of USA "; current, end = ‘’)
if (d _ votes > r _ votes);
print (" the new president will be ", d _ nominee)
else:
print ('the new president will be ', r _ nominee)
-
enter the output produced when you type the following:
president (274, 264) -
enter the output produced when you type in the following:
president (332, 206, d _ nominee = " Elizabeth warren ", r _ nominee = mike pence -
enter the cod you would type if the democratic nominee was Hillary Clinton, and the republican nominee was mitt Romney and the number of electoral votes for the democrats was 270 and for the republicans was 268
i do not understand what they are saying. i have done all i seem not to get it. pls explain to me when you do understand . please
question
the exercise will explore the different ways you can specify arguments to a functions
for the question define the following function and then answer the following questions
def president (d _ votes, r _ votes, current = ’ donald trump’, d _ nominee = ’ joe biden’, r nominee = ’ donald trump’)
print (" the current president of USA "; current, end = ‘’)
if (d _ votes > r _ votes);
print (" the new president will be ", d _ nominee)
else:
print ('the new president will be ', r _ nominee)
-
enter the output produced when you type the following:
president (274, 264) -
enter the output produced when you type in the following:
president (332, 206, d _ nominee = " Elizabeth warren ", r _ nominee = mike pence -
enter the cod you would type if the democratic nominee was Hillary Clinton, and the republican nominee was mitt Romney and the number of electoral votes for the democrats was 270 and for the republicans was 268
i do not understand what they are saying. i have done all i seem not to get it. pls explain to me when you do understand . please
(Attachment Lab02 programming.pdf is missing)
it about explaining argument function knowing the keyword and how to answer the question
n this exercise, you will modify the above function code to return the product of the items on the list rather than the sum. There are three lines of code in the above program
:>>>from func tools import
reduce Line 1:
def sum(seq):
Line 2: … def add(x,y):
return x+y
Line 3: … return reduce(add, seq)
For your modified function, you will need to use the exact same number of lines of code.[Note: In the answers you submit below, do not include any indentation in your code. Use appropriate function names and similar spacing as above.
]Q9 Enter the code in your new program for Line 1.
]Q10 Enter the code in your new program for Line 2.
Q11 Enter the code in your new program for Line 3
Q12 Enter the code you would type to run your new function to return the product of the numbers 10, 11, 12, … up to and including 20
Q13 Enter the output produced when you run the code you devised for Q2
pls i need thorough explanation to answer the rest