a) Create a file userFunctions.py:
2. Modify nameFormat() to accept only two parameters first and last. Change last to an optional parameter.
This
function should now return either first or last. first.
3. Define a function printUsers() which accepts a list parameter users. This function calls the printUser() function
to print all user data.
b) Create a separate file, functionModule.py:
Import all functions from userFunctions.py.
2. In this file create a list users.
• Use nameFormat() and createUser() to add dictionaries to the list users:
John smith, age 42, job Programmer, hobby Biking
tom cat, age 24, job Security Analyst
jerry mouse, age 25, job DevOps Engineer, hobby Running
sara, age 20, school QCC, major CSIS
4. Use the print Users) function to print all list users.
In Python, please and thank you
Problem 1 - Implementing Modules (4 pts) a) Create a file user Functions.py: 1. Copy nameFormat(), createUsero, and printUser from PE 10 into the userFunctions.py file. 2. Modify nameFormat) to accept only two parameters first and last. Change last to an optional parameter. This function should now return either first or last, first. 3. Define a function printUsers() which accepts a list parameter users. This function calls the printUser() function to print all user data. b) Create a separate file, function Module.py: 1. Import all functions from userFunctions.py. 2. In this file create a list users. 3. Use name Format() and createUser() to add dictionaries to the list users: John smith, age 42, job Programmer, hobby Biking tom cat, age 24.job Security Analyst jerry mouse, age 25. job DevOps Engineer, hobby Running sara, age 20, school QCC, major CSIS 4. Use the printUsers() function to print all list users. Example Output name: Smith, John age: 42 job: Programmer hobby: Biking name: Cat, Tom age: 24 job: Security Analyst name: Mouse, Jerry age: 25 job: DevOps Engineer hobby: Running name: Sara age: 20 school: QCC major: CSIS
Data Management Functions 2. Name format a) Define a function nameFormar() with parameters first, middle, and last. 1) This function prints the first name, the middle initial and the last name using proper title format. b) Define a main() function to do the following: 1) Call the function nameFormat with these positional arguments: john stu smith 2) Call the function name Format with these keyword arguments: last = 'kennedy, first = "john', middle = 'fitzgerald c) Call main() function to initiate the tasks to be performed. Example Output John s. Smith John F. Kennedy 3. Name format a) Define a function name Format() with parameter first, last and middle where middle is an optional parameter. If all three names are provided return: Last, First, M. If only first and last are provided return: Last, First b) Define a main() function to do the following: 1) Call the function with keyword arguments for the name: james bond 2) Call the function with keyword arguments for the name: henry indiana jones 3) Print the results of the function calls. c) Call main() function to initiate the tasks to be performed. Example Output Bond, James Jones, Henry, I.
Data Management Functions 2. Name format a) Define a function nameFormar() with parameters first, middle, and last. 1) This function prints the first name, the middle initial and the last name using proper title format. b) Define a main() function to do the following: 1) Call the function nameFormat with these positional arguments: john stu smith 2) Call the function name Format with these keyword arguments: last = 'kennedy', first = "john', middle = 'fitzgerald c) Call main() function to initiate the tasks to be performed. Example Output John s. Smith John F. Kennedy 3. Name format a) Define a function name Format() with parameter first, last and middle where middle is an optional parameter, If all three names are provided return: Last, First, M. If only first and last are provided return: Last, First b) Define a main() function to do the following: 1) Call the function with keyword arguments for the name: james bond 2) Call the function with keyword arguments for the name: henry indiana Jones 3) Print the results of the function calls. c) Call main() function to initiate the tasks to be performed. Example Output Bond, James Jones, Henry, I.
a) Create a file userFunctions.py: 2. Modify nameFormat() to accept only two parameters first and last. Change last to a
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am