Answered step by step
Verified Expert Solution
Question
1 Approved Answer
1. What is the purpose of using functions in a Python script? 2. Write Python code to define a function called greetings() that when
1. What is the purpose of using functions in a Python script? 2. Write Python code to define a function called greetings() that when called will greet the user by name and on the next line display the current date. [hint: use the os.system() function to display the current date.] 3. Why is it useful for functions to accept arguments passed-up upon function execution? 4. What is the purpose of the import command? What can be the consequence if the import command is not used prior to running a function by name? 5. Write Python code to declare a function called join() that accepts two arguments which will be be stored as word1 and word2 respectively during the execution of the function. 6. What is the command to return a value from a function? 7. What is the purpose of the system() function in the os module? 8. What is the purpose of a list object? 9. Assume that the following list has been defined: mylist = ['apple', 1, 'grape', 2, "banana', 3, ] Based on that, what will the following contain? mylist[0] mylist[3] mylist[-1] mylist[0:1] 10. Assume that the following list has been defined: combined_list = [[7, 5], ['x', 'y'], [5,'f']] Based on that, what will the following contain? combined_list[0] combined_list[1] combined_list[1][0] combined_list[2][0:2] 11. Briefly explain the purpose of each of the following methods that can be used with lists: append, insert, remove, sort, copy. 12. Write the functions that perform the following operations on a list: 1. Returns the length of the list 2. Returns the smallest value in the list 3. Returns the largest value in the list 13. Make a Python script to display all of the items in a simple list, one item per line.
Step by Step Solution
★★★★★
3.34 Rating (163 Votes )
There are 3 Steps involved in it
Step: 1
Following are the answers to the given questions 1 The main purpose of using functions in Python is to encapsulate a block of code into a reusable and ...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started