Question

Task 1: Calling a Function PROGRAM IS IN PYTHON) SHOW INPUT AND OUTPUT SCREEN SHOTS Task...

Task 1: Calling a Function PROGRAM IS IN PYTHON) SHOW INPUT AND OUTPUT SCREEN SHOTS

Task 1: Calling a Function Defining a function gives it a name, specifies the parameters that are to be included in the function and structures the blocks of code. Once the basic structure of a function is finalized, you can execute it by calling it from another function or directly from the Python prompt. Following is an example to call the printme() function

#!/usr/bin/python

3

# Function definition is here

defprintme(str): "This prints a passed

string into this function" print(str

return

# Now you can call printme function

printme("This is first call to the user defined

function!") printme("Again second call to the

same function")

0 0
Add a comment Improve this question Transcribed image text
Answer #1
#!/usr/bin/python3

# Function definition is here

def printme(str):
    "This prints a passed string into this function"
    print(str)
    return


# Now you can call printme function

printme("This is first call to the user defined function!")
printme("Again second call to the same function")

Add a comment
Know the answer?
Add Answer to:
Task 1: Calling a Function PROGRAM IS IN PYTHON) SHOW INPUT AND OUTPUT SCREEN SHOTS Task...
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
  • Task 4: for Loops (PROGRAM IS IN PYTHON) SHOW INPUT AND OUTPUT SCREEN SHOTS #!/usr/bin/python3 # ...

    Task 4: for Loops (PROGRAM IS IN PYTHON) SHOW INPUT AND OUTPUT SCREEN SHOTS #!/usr/bin/python3 # Measure some strings: words = ['cat', 'window', 'defenestrate'] for w in words: print(w, len(w)) #!/usr/bin/python3 # Measure some strings: words = ['cat', 'window', 'defenestrate'] for w in words: print(w, len(w)) forvar in list(range(5)): print (var) for letter in 'Python': # traversal of a string sequence print ('Current Letter :', letter) print() fruits = ['banana', 'apple', 'mango'] for fruit in fruits: # traversal of List...

  • "PYTHON" 1. a. Create a file (module) named camera_picture.py. b. Write a function, take_picture_effect, that takes...

    "PYTHON" 1. a. Create a file (module) named camera_picture.py. b. Write a function, take_picture_effect, that takes two parameters, the filename and an effect. c. Take a picture with the filename and effect. Use camera.effect to set the effect. Use help(PiCamera) to find the effects which you can apply. d. Create a second file use_camera.py. e. Import the take_picture_effect function from the camera_picture module. f. Prompt the user for the filename. g. Prompt the user for the image_effect. help(PiCamera) to see...

  • using this code to complete. it python 3.#Display Program Purpose print("The program will show how much...

    using this code to complete. it python 3.#Display Program Purpose print("The program will show how much money you will make working a job that gives a inputted percentage increase each year") #Declaration and Initialization of Variables userName = "" #Variable to hold user's name currentYear = 0 #Variable to hold current year input birthYear = 0 #Variable to hold birth year input startingSalary = 0 #Variable to hold starting salary input retirementAge = 0 #Variable to hold retirement age input...

  • Please use Python 3, thank you~ Write a program that: Defines a function called find_item_in_grid, as...

    Please use Python 3, thank you~ Write a program that: Defines a function called find_item_in_grid, as described below. Calls the function find_item_in_grid and prints the result. The find_item_in_grid function should have one parameter, which it should assume is a list of lists (a 2D list). The function should ask the user for a row number and a column number. It should return (not print) the item in the 2D list at the row and column specified by the user. The...

  • Can you send the code and the screenshot of it running? 1) Create a PYHW2 document...

    Can you send the code and the screenshot of it running? 1) Create a PYHW2 document that will contain your algorithms in flowchart and pseudocode form along with your screen shots of the running program. 2) Create the algorithm in both flowchart and pseudocode forms for the following two functions: A. Write a Python function that receives a real number argument representing the sales amount for videos rented so far this month The function asks the user for the number...

  • Task 1: Write a Python program that takes as input from the user the name of a file containing po...

    python code: Task 1: Write a Python program that takes as input from the user the name of a file containing postcode/location information. Each line in the file consists of the postcode followed by a tab followed by a comma-separated list of locations that have that postcode. For example, the file Small.txt contains: 3015 Newport,South Kingsville,Spotswood 3016 Williamstown 3018 Altona,Seaholme 3019 3021 Albanvale,Kealba,Kings Park,St Albans Braybrook, Robinson Your program should create a list of postcode/location pairs with each pair stored...

  • Write a python program (recursive.py) that contains a main() function. The main() should test the following...

    Write a python program (recursive.py) that contains a main() function. The main() should test the following functions by calling each one with several different values. Here are the functions: 1) rprint - Recursive Printing: Design a recursive function that accepts an integer argument, n, and prints the numbers 1 up through n. 2) rmult - Recursive Multiplication: Design a recursive function that accepts two arguments into the parameters x and y. The function should return the value of x times...

  • 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...

  • Python Question Task 4 Create a function named poker_table that uses Turtle Graphics to create a...

    Python Question Task 4 Create a function named poker_table that uses Turtle Graphics to create a single poker table to accommodate all players. There should be four parameters: num_players indicates the number of players; side_length indicates the length in pixels of each side of the table; and x and y, which give the location where you should start drawing the table. The poker table should be a simple regular polygon (that is, with sides of equal length). The number of...

  • Python 3 coding with AWS/IDLE. DDI&T a Python program to input, store, and process hourly temperatures for each hour...

    Python 3 coding with AWS/IDLE. DDI&T a Python program to input, store, and process hourly temperatures for each hour of the day (i.e., 24 temperatures). Your program should be divided logically into the following parts: In function main() declare an empty List container:          HourlyTemperatures = []     Pass the empty HourlyTemperatures list to a function, GetTemperatures(HourlyTemperatures)          This function must interactively prompt for and input temperatures for each of the 24 hours in a day (0 through 23). For each temperature that...

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