Question
Assignment Topics The Python programs manipulate: - lists, - dictionaries and - strings. Question 10 This question concerns the development of an automated technical support
Assignment Topics
The Python programs manipulate:
- lists,
- dictionaries and
- strings.
Question 10
This question concerns the development of an automated technical support system. Users can enter technical queries and the system will suggest solutions.
As it stands, the tech support system consists of the program 'noaid.py' which is found at the far bottom of this question series. Running this program produces the following behaviour:
Welcome to the automated technical support system.
Please describe your problem:
My computer keeps crashing
Curious, tell me more.
I don't think it has a driving license
Curious, tell me more.
Really?
Curious, tell me more.
Oh forget it!
Curious, tell me more.
quit
The program just prints out the same response again and again.
---------------------------------------------------------------------------------------------------------------------------------------------
10.1 Some aid
Using noaid.py as the basis, create a new program called someaid.py that randomly selects a response from a list. The list should contain the following responses in the following order:
- Have you tried it on a different operating system?
- Did you reboot it?
- What colour is it?
- You should consider installing anti-virus software.
- Contact Telkom.
- I should get that looked at if I were you.
Here's an example of expected behaviour:
Welcome to the automated technical support system.
Please describe your problem:
My computer keeps crashing
What colour is it?
Blue, why?
You should consider installing anti-virus software.
Oh
You should consider installing anti-virus software.
You said that
Did you reboot it?
No
Contact Telkom.
quit
NOTE: Your program must:
- Use a main() function.
- Use a list containing the given responses in the given order.
- Use the following conditional to ensure it is not run when imported:
if __name__=='__main__':
main()
- Randomly select responses by using the Python random.randint() function. You must import random.
The function randint(a, b) returns a random integer N such that a <= N <= b.
----------------------------------------------------------------------------------------------------------------------------------------------------
10.2 Support
Using someaid.py as the basis, create a new program called support.py.
Modify support.py so that it keeps a dictionary of responses indexed by keywords.
- Assume that the user only ever inputs a single word at a time.
- Given a word entered by the user, the program will look for that entry in the dictionary and will print the associated response.
- If there is no entry for that word the program will output 'Curious, tell me more.'.
The dictionary should contain the following keyword-response pairs:
keyword | response |
crashed | Are the drivers up to date? |
blue | Ah, the blue screen of death. And then what happened? |
hacked | You should consider installing anti-virus software. |
Bluetooth | Have you tried mouthwash? |
windows | Ah, I think I see your problem. What version? |
apple | You do mean the computer kind? |
spam | You should see if your mail client can filter messages. |
connection | Contact Telkom. |
Here's an example of expected behaviour:
Welcome to the automated technical support system.
Please describe your problem:
crashed
Are the drivers up to date?
yes
Curious, tell me more.
blue
Ah, the blue screen of death. And then what happened?
hacked
You should consider installing anti-virus software.
quit
NOTE: Your program must use a main() function and must contain the exact set of keyword and response pairs listed above.
----------------------------------------------------------------------------------------------------------------------------
10.3 Tech Support
Using support.py as the basis, create a new program called techsupport.py. Modify techsupport.py so that it splits a query up into a list of words and then, taking each in turn, searches the dictionary for a match.
- Once it finds a match it should print the associated response.
- It should NOT print more than one response.
- If none of the words can be matched then the program should output 'Curious, tell me more.'.
Here's an example of expected behaviour:
Welcome to the automated technical support system.
Please describe your problem:
My computer crashed
Are the drivers up to date?
No
Curious, tell me more.
I don't have an internet connection
Contact Telkom.
I did
Curious, tell me more.
They told me to use bluetooth
Have you tried mouthwash?
quit
NOTE:
- You may assume that user input is not punctuated.
- To enable automarking, your program must use a main() function and must contain the exact set of keyword and response pairs listed above.
HINT: A string can be split into a list of constituent words by using the split() method. For example:
>>> 'the rain in spain falls mainly on the plain'.split()
['the', 'rain', 'in', 'spain', 'falls', 'mainly', 'on', 'the', 'plain']
>>>
----------------------------------------------------------------------------------------------------------------------------------------
# noaid.py
def welcome(): print('Welcome to the automated technical support system.') print('Please describe your problem.')
def get_input(): return input().lower()
def main():
welcome() query = get_input() while (not query=='quit'): print('Curious, tell me more.')
query = get_input() main()
----------------------------------------------------------------------------------------------------------------------------------------
Please write three different programs to answer questions10.1,10.2 & 10.3 respectively.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
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