Question

CIS 103 Fundamentals of Programming HW 4 CIS 103 Fundamentals of Programming HW 4 Student Name Section Due Date Instructor St
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Part 1

a. def is a keyword in Python which is used to define a function.

for example :

def factorial(num) :

   return n

here we have defined a function factorial which is preceded by the keyword def.

b. Function Argument

When a function is being called and the values which are passed to the function it is called as function argument.

def sum(a,b):

    print(a+b)

sum(4,5)          // 4 and 5 are the arguments

c. Function call

It is the process to call a particular function to start it's execution and that function should already be defined prior to callinng it.

For example :

disp():
print("Hello World")

disp() // Here we are calling the disp() function which is already defined

d. Parameter

When we define a function and the variables which is declared at that time ,this is called as parameter

def sum(a,b):    // a and b are the parameters

    print(a+b)

sum(4,5)

e. return statement

It is the statement which is used to return the result/values to the calling function and it also ends the execution of a function which is called.

def sum(a,b):   

    return a+b         // this will return the value 9 to the variable res

res = sum(4,5)

print (res)

Note : As per HOMEWORKLIB POLICY only first 4 questions can be answered ,post the remaining again.

Add a comment
Know the answer?
Add Answer to:
CIS 103 Fundamentals of Programming HW 4 CIS 103 Fundamentals of Programming HW 4 Student Name...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Programming Exercise 11.4 m | Instructions expo.py + An alternative strategy for the expo function uses...

    Programming Exercise 11.4 m | Instructions expo.py + An alternative strategy for the expo function uses the following recursive definition: 1 def expo (base, exponent): 2 expo.calls += 1 # Used to track recursive call count 3 # Write you recursive expo function here 4 5 expo.calls = 6 7 def main(): ***"Tests with powers of 2."" 9 for exponent in range (5): 10 print (exponent, expo(2, exponent)) 11 12 if name == "_main_": 13 main() 14 expo(number, exponent) =...

  • 3. A cylindrical bar magnet has radius a and finite length 2, centered at the origin; it has uniform axial magnetization M. (a) Detail the correspondence with the solenoid in HW 5, #3: Evaluate the m...

    3. A cylindrical bar magnet has radius a and finite length 2, centered at the origin; it has uniform axial magnetization M. (a) Detail the correspondence with the solenoid in HW 5, #3: Evaluate the magnetzation surface-current density i and check the value found for the total magnetic dipole moment m against the definition of M as its volume-density. (b) Express B(o and H) on the axis, inside and outside the magnet, in terms of M, I , a, and乙Draw...

  • C programming Write a function that accepts an array of integers as an input, and output...

    C programming Write a function that accepts an array of integers as an input, and output the sum of all values and the multiplication of all values. e.g. Suppose that the array contained the following values: 1 2 3 -4 5. The function should calculate and output the sum of values (i.e. 1+2+3+(-4)+5=7) and the multiplication of all values (i.e. 1*2*3*-4*5=-120). Start by carefully writing the function prototype - put some thought into this. Think about the good programming habits,...

  • Problem 4 (programming): Create a MATLAB function named mynewton.m to estimate the root for any a...

    Problem 4 (programming): Create a MATLAB function named mynewton.m to estimate the root for any arbitrary function f given an initial guess xo, an absolute error tolerance e and a maximum number of iterations max.iter. Follow mynewton.m template posted in homework 2 folder on TritonED for guidance. You are not required to use the template. The function should return the approximated root n and the number of steps n taken to reach the solution. Use function mynewton.m to perform the...

  • Programming Exercise 1. Show fully functioning code that can be pasted into a new Python IDLE...

    Programming Exercise 1. Show fully functioning code that can be pasted into a new Python IDLE file and function correctly. Show the output that would result from each of the following possible inputs: 3, 4, 5 a) wollot sd 3, 3, 3 b) c) 5, 4, 3 d) 3, 5, 2 oaeb e) 5, 4, 7 f) 3, 3, 2 Programming Exercises 1. Many companies pay time-and-a-half for any hours worked above 40 in a given week. Write a program...

  • python 2..fundamentals of python 1.Package Newton’s method for approximating square roots (Case Study 3.6) in a...

    python 2..fundamentals of python 1.Package Newton’s method for approximating square roots (Case Study 3.6) in a function named newton. This function expects the input number as an argument and returns the estimate of its square root. The script should also include a main function that allows the user to compute square roots of inputs until she presses the enter/return key. 2.Convert Newton’s method for approximating square roots in Project 1 to a recursive function named newton. (Hint: The estimate of...

  • Problem 4 (programming): Create a MATLAB function named mynewton.m to estimate the root for any a...

    Problem 4 (programming): Create a MATLAB function named mynewton.m to estimate the root for any arbitrary function f given an initial guess xo, an absolute error tolerance e and a maximum number of iterations max iter. Follow mynewton.m template posted in homework 2 folder on TritonED for guidance. You are not required to use the template. The function should return the approximated root ^n and the number of steps n taken to reach the solution. Use function mynewton.m to perform...

  • Using Python Programming Language: 4. Implement the following function in the PyDev module functions.py and test...

    Using Python Programming Language: 4. Implement the following function in the PyDev module functions.py and test it from a PyDev module named t04.py: def print_matrix_char(matrix): Prints the contents of a 2D list of strings in a formatted table. Prints row and column headings. Use: print_matrix_char (matrix) Parameters: matrix - a 2D list of strings (2D list) Returns: None. Sample testing: Number of rows: 3 Number of columns: 4 0 1 2 3 i 0 с u r 1 с у...

  • C Programming Language only please. Your help is greatly appreciated. Will give thumbs up for quality...

    C Programming Language only please. Your help is greatly appreciated. Will give thumbs up for quality work. Lab 8 (this is to be turned in) Palindrome is a string that is the same as backwards or forwards “otto” “ababa” “noon” “ababbbbaba” In this lab we will work with strings (so we will be using character arrays). 1. Write a program that reads two strings strl and str2 from the keyboard 2. Print both strings 3. Write a function computeLength and...

  • Question 1 (1 point) Which of the following is a reason to use functions? Question 1...

    Question 1 (1 point) Which of the following is a reason to use functions? Question 1 options: To make it easier to read by keeping sections of code shorter. To avoid duplicating code. all of the above To make the code more organized. Question 2 (1 point) When the execution of a function ends, what Python code is executed next? Question 2 options: The function is automatically executed again. The line of code immediately after the end of the function....

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT