Part One - Using a main function, Docstrings Write a function called hello. The function has no arguments and no return value. It simply prints the text "Hello World". Include a docstring that describes the function. Write a main function, as described by the Python main function reading. Call main, as described by the Python main function reading. From main, call hello and then print hello's docstring. Part Two - Error Handling Write a function called printListElement. The function has two arguments and no return value. The first argument is a list, and the second argument is a list index. The function will print an element from the list as determined by the list index. If the list index is invalid, print an error message We could accomplish this with a logic test, but instead, we will manage this with error handling. Write a try block that attempts to print the list element. Catch any errors with an except block, print From main, create a myList list with elements 0, 1, 2 by using the list and range commands. Then, call printListElement with your list and a list index value of 3. Part Three - How Python function arguments are treated There can be some confusion as to how Python functions treat their arguments - is it by reference or by value? Explore this for yourself. From main, create a myint variable and give it the value 3. Also create a myList list with elements 0, 1, 2 Print the IDs of myInt and myList. Also print the ID of the last element of myList. Now create a function called by Val which has one argument. In the function, add 7 to the argument. Print the ID of the argument before and after the change. Create a second function called byRef which has one argument. In the function, add 7 to the last element in the list. Print the ID of the argument and the ID of the last element of the argument before and after the change. Now call by Val with myInt and then call byRef with myList. Next, again print the IDs of MyInt, myList, and the last element of myList. Finally, print myInt and MyList from main. Can you explain the results? Here are two sites that do a good job of explaining how Python functions work: Is Python call by reference or call by value error message.
Part One - Using a main function, Docstrings Write a function called hello. The function has no arguments and no return value. It simply prints the text "Hello World". Include a docstring that describes the function. Write a main function, as described by the Python main function reading. Call main, as described by the Python main function reading. From main, call hello and then print hello's docstring. Part Two - Error Handling Write a function called printListElement. The function has two arguments and no return value. The first argument is a list, and the second argument is a list index. The function will print an element from the list as determined by the list index. If the list index is invalid, print an error message We could accomplish this with a logic test, but instead, we will manage this with error handling. Write a try block that attempts to print the list element. Catch any errors with an except block, print From main, create a myList list with elements 0, 1, 2 by using the list and range commands. Then, call printListElement with your list and a list index value of 3. Part Three - How Python function arguments are treated There can be some confusion as to how Python functions treat their arguments - is it by reference or by value? Explore this for yourself. From main, create a myint variable and give it the value 3. Also create a myList list with elements 0, 1, 2 Print the IDs of myInt and myList. Also print the ID of the last element of myList. Now create a function called by Val which has one argument. In the function, add 7 to the argument. Print the ID of the argument before and after the change. Create a second function called byRef which has one argument. In the function, add 7 to the last element in the list. Print the ID of the argument and the ID of the last element of the argument before and after the change. Now call by Val with myInt and then call byRef with myList. Next, again print the IDs of MyInt, myList, and the last element of myList. Finally, print myInt and MyList from main. Can you explain the results? Here are two sites that do a good job of explaining how Python functions work: Is Python call by reference or call by value error message.
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
Related questions
Question
can you wite the in pyth ,please?
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 2 steps with 4 images
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY