1. What is the purpose of using functions in a Python script? 2. Write Python code...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
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. 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.
Expert Answer:
Answer rating: 100% (QA)
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 ... View the full answer
Related Book For
Principles Of Information Security
ISBN: 9780357506431
7th Edition
Authors: Michael E. Whitman, Herbert J. Mattord
Posted Date:
Students also viewed these programming questions
-
The two-speed windshield wiper operates in HIGH position only. Technician A says the low-speed brush may be worn. Technician B says the motor has a faulty ground connection. Who is correct? and why.
-
A study was conducted on a sample of 53 patients presenting with prostate cancer who had also undergone a laparotomy to ascertain the extent of nodal involvement (Collett 1991). The result of the...
-
This exercise is meant to help you to understand how to use functions in Python. In this week's exercise, you are asked to create a simple tool that converts temperatures from one temperature type to...
-
A sphere of 80 mm diameter lies at a depth of 500 m in sea water. The bulk modulus of sphere is 200 GPa. If the specific weight of sea water is 10.3 kN/m, the decrease in the volume (in mm) of the...
-
Consider carefully the interplay of chance events and partial information in each of the games in Exercise 6.10. a. For which is the standard expectiminimax model appropriate? Implement the algorithm...
-
The notes to recent financial statements of Colgate-Palmolive contained the following information (dollar amounts in millions): 3. Acquisitions and Divestitures On June 20, 2011, the Company ......
-
Kemesia Boota Ward signed a contract on February 17, 2010, to hold her wedding reception at the Deauville Hotel on July 9, 2010. (The wedding ceremony was being held elsewhere.) Renting the ballroom...
-
At Quickie Car Wash, the wash process is advertised to take less than 7 minutes. Consequently, management has set a target average of 390 seconds for the wash process. Suppose the average range for a...
-
(a) Explain the following terms as used in international finance: (i) Floating rate notes (FRNs). (1 mark) (ii) Forfaiting. (1 mark) (iii) Crowd funding. (1 mark) (iv) Green bond. (1 mark) (b) One of...
-
The L. Young & Sons Manufacturing Company produces two products, which have the following profit and resource requirement characteristics: Last months production schedule used 350 hours of labor in...
-
Suppose the bid price of the Nordstrom call option is $2.90 and the ask price is $3.30. Would this bid-ask spread make the arbitrage trade in part unprofitable? Explain why or why not in a sentence...
-
Distinguish between a job description and a job specification.
-
Paul Jackson saved 6,200 over last 2 years and decided to invest in an individual savings account (ISA), which is a type of savings account that offers tax exemptions to residents of the United...
-
What is meant by the terms personality and proactive personality?
-
Discuss the issue of fairness and an ethical approach in employee selection.
-
Lisi Ji just won $12 million in the Hong Kong mega lottery. She is given the option of receiving a lump sum immediately, or she can elect to receive an annual payment of $1 million at the end of each...
-
Review Questions: 1. What is the theory on which Rockwell hardness testing is based? 2. What is the purpose of the minor load in Rockwell hardness testing? 3. What are the advantages of the Rockwell...
-
Bobbie Singh provides writing services for small businesses. He blogs for companies that need professionally written content. His business records at November 15, 2023, are shown below: During the...
-
True or False: Penetration testing is a set of security tests and evaluations that simulate attacks by a hacker or other malicious external source.
-
Discuss the criteria on which selecting information security personnel is based, including the principles of supply and demand. This is likely a combination of experience, certifications, and...
-
What is a type of law that addresses violations harmful to society and that is enforced by prosecution by the state? a. Criminal law b. Private law c. Public law d. Civil law
-
The Boundary Waters Canoe Area Wilderness (BWCA) located in northeastern Minnesota has 1 million acres of wilderness, 1,000 waterways, and 1,500 miles of canoe routes. While some youth, for example...
-
A public recreation area is under planning. The initial cost of the area is \(\$ 1,800,000\), and it will have maintenance costs of \(\$ 200,000 /\) year. It is estimated that 90,000 persons will...
-
Suppose Lincoln Park Zoo decided to charge admission just for the newly renovated area described in Problem 11. Suppose the price is set at the average perceived benefit per visit, reasoning that the...
Study smarter with the SolutionInn App