Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

PYTHON PROGRAMMING QUESTION 1. Create a module named inventory.py. In this module: a. Create a function named printHeader() that prints out a header that looks

PYTHON PROGRAMMING QUESTION

image text in transcribedimage text in transcribedimage text in transcribed

1. Create a module named inventory.py. In this module: a. Create a function named printHeader() that prints out a header that looks like this when called from the main() method. Computer Inventory Hostname Username WindowsVer RAM Asset Tag b. Create a main() method that does this: i. For each computer, prompt the user for this information: 1. Hostname is the name of the computer. (must be 8 characters or shorter, and must be printed out in all capitals). a. If the user uses LESS than 8 characters: i. While the length of the hostname is less than 8, you should loop and add the number 1 as a suffix until the length is 8 characters. Example: hostname is art. Printout should be ART11111. b. If the user uses more than 8 characters, then you must truncate the hostname to just the first 8 characters entered. For example: user enters accountingpc. It should print out as ACCOUNTP. Hint: We haven't covered this in class, so here is the code for accomplishing of grabbing the first 8 letters of the name: hostname = hostname [0:3] 2. Username is the computer username of the person that logs on to the pc. Usernames should be formatted identically as hostnames: Truncate to 8 if more than 8 characters, Pad to 8 if less than 8 characters. Convert usernames to uppercase. 3. Windows Version relates to the version of Windows. Prompt the user to enter the NUMBER of Windows. Acceptable values are 7, 8, or 10. If the user doesn't enter 7, 8, or 10, then just assume that the value of Windows is 10. Pre-pend the user's entry with the string "Windows". Example: The user enters 8, so the string should be stored as "Windows 8. The user enters 22, so the string should be stored as Windows 10. 4. Enter the GB of RAM that the computer holds. Note that the value must be an integer between 16 and 64. Keep prompting the user to enter a valid number between 16 and 64 in case they don't do so. 2. Create a new module named generatetag.py. i. Define a function named genTag that accepts 3 parameters: host, username, and ram). 1. The function should create an 8-digit asset tag composed of the first 2 letters of the hostname, first 2 letters of the username, the value of the ram, and a random integer between 10 and 99. Asset tags must all be uppercase. a. Example: you pass hostname = ACCOUNTI, username = jsmith11, and ram = 32. Say you generate 34 as a random number. Then the asset tag is ACJS3234. b. Return the value of the asset tag back to the calling method when called. 3. Back in Inventory.py: a. Call gentag() and return the asset tag back to the appropriate asset variable. b. Gather the information for the other 3 computers using the same code you just used, but use different variable names so as not to overwrite your variable values. The information gathering should look something like this: Computer 1 Input: What is the computer's hostname? hen-as-220 The hostname is: HEN-AS-2 What is the computer's primary username? omillez The username WHILLER What version of Windows ? 17, , or 10) 10 The version 13: Windows 10 How much RAM is in the machine (16-64) 16 There are 16 GB of RAM in the machine. The asset tag is: HESM1617 Computer 2 input: What is the computer's hostname ? | C. Call printHeader() d. Print out to the console the value of the each computer's hostname, username, windows version, RAM, and Asset tag (which you generate by passing the values that you just collected on to the genTag() function). e. Don't forget to import the genTag() function from the generate Tag.py file. The final printout should look something like this: Computer Inventory Hostname Username WindowsVer RAM Asset Tag 16 HEN-AS-2 HEN-ADM- HEN-STCI HEN-LIB3 SMILLER BMCMURTR CCONLEYI MSULLIVA Windows 10 Windows 8 Windows 7 Windows 8 32 HESM1617 HEBM6450 HECC3232 HEMS4881 48 1. Create a module named inventory.py. In this module: a. Create a function named printHeader() that prints out a header that looks like this when called from the main() method. Computer Inventory Hostname Username WindowsVer RAM Asset Tag b. Create a main() method that does this: i. For each computer, prompt the user for this information: 1. Hostname is the name of the computer. (must be 8 characters or shorter, and must be printed out in all capitals). a. If the user uses LESS than 8 characters: i. While the length of the hostname is less than 8, you should loop and add the number 1 as a suffix until the length is 8 characters. Example: hostname is art. Printout should be ART11111. b. If the user uses more than 8 characters, then you must truncate the hostname to just the first 8 characters entered. For example: user enters accountingpc. It should print out as ACCOUNTP. Hint: We haven't covered this in class, so here is the code for accomplishing of grabbing the first 8 letters of the name: hostname = hostname [0:3] 2. Username is the computer username of the person that logs on to the pc. Usernames should be formatted identically as hostnames: Truncate to 8 if more than 8 characters, Pad to 8 if less than 8 characters. Convert usernames to uppercase. 3. Windows Version relates to the version of Windows. Prompt the user to enter the NUMBER of Windows. Acceptable values are 7, 8, or 10. If the user doesn't enter 7, 8, or 10, then just assume that the value of Windows is 10. Pre-pend the user's entry with the string "Windows". Example: The user enters 8, so the string should be stored as "Windows 8. The user enters 22, so the string should be stored as Windows 10. 4. Enter the GB of RAM that the computer holds. Note that the value must be an integer between 16 and 64. Keep prompting the user to enter a valid number between 16 and 64 in case they don't do so. 2. Create a new module named generatetag.py. i. Define a function named genTag that accepts 3 parameters: host, username, and ram). 1. The function should create an 8-digit asset tag composed of the first 2 letters of the hostname, first 2 letters of the username, the value of the ram, and a random integer between 10 and 99. Asset tags must all be uppercase. a. Example: you pass hostname = ACCOUNTI, username = jsmith11, and ram = 32. Say you generate 34 as a random number. Then the asset tag is ACJS3234. b. Return the value of the asset tag back to the calling method when called. 3. Back in Inventory.py: a. Call gentag() and return the asset tag back to the appropriate asset variable. b. Gather the information for the other 3 computers using the same code you just used, but use different variable names so as not to overwrite your variable values. The information gathering should look something like this: Computer 1 Input: What is the computer's hostname? hen-as-220 The hostname is: HEN-AS-2 What is the computer's primary username? omillez The username WHILLER What version of Windows ? 17, , or 10) 10 The version 13: Windows 10 How much RAM is in the machine (16-64) 16 There are 16 GB of RAM in the machine. The asset tag is: HESM1617 Computer 2 input: What is the computer's hostname ? | C. Call printHeader() d. Print out to the console the value of the each computer's hostname, username, windows version, RAM, and Asset tag (which you generate by passing the values that you just collected on to the genTag() function). e. Don't forget to import the genTag() function from the generate Tag.py file. The final printout should look something like this: Computer Inventory Hostname Username WindowsVer RAM Asset Tag 16 HEN-AS-2 HEN-ADM- HEN-STCI HEN-LIB3 SMILLER BMCMURTR CCONLEYI MSULLIVA Windows 10 Windows 8 Windows 7 Windows 8 32 HESM1617 HEBM6450 HECC3232 HEMS4881 48

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advances In Databases 11th British National Conference On Databases Bncod 11 Keele Uk July 7 9 1993 Proceedings Lncs 696

Authors: Michael F. Worboys ,Anna F. Grundy

1993rd Edition

3540569219, 978-3540569213

More Books

Students also viewed these Databases questions

Question

6. Explain the strengths of a dialectical approach.

Answered: 1 week ago

Question

2. Discuss the types of messages that are communicated nonverbally.

Answered: 1 week ago