Answered step by step
Verified Expert Solution
Link Copied!
Question
1 Approved Answer

a moment to download the script and note the contents. You will find a test string and a list. Both contain entries from the file

a moment to download the script and note the contents. You will find a test string and a list. Both contain entries from the file /etc/passwd:
arthur:x:1001:1001:Arthur Smith:/home/arthur:/bin/bash
where:
arthur - username
x - indicates encrypted password
1001- UID
1001- GID
Arthur Smith - Comment
/home/arthur - home directory
/bin/bash - shell
Add the following to q2-passwd.py:
1. A Docstring with your name and student ID.
2. A new function. Your function should:
a. Take a string as an argument (such as test_strn).
b. Split the string by the appropriate character
c. If the userid is the same as groupid, return True.
d. Otherwise, return False.
3. Inside the main block delete the ...
4. Call your function with test_strn as an argument. Print the result, and verify that it is correct.
5. Next, use a loop to iterate through each line of from_passwd.
6. For each iteration of the loop print either:
a. "arthur is a regular user" (for example, for the user arthur) if your function returns True. Or:
b. "arthur is not a regular user" if your function returns False.
c. Finally, as a comment answer the following:What happens if the number of fields in a string changes? For example, if the first line has 7 fields but the next line has 6. What error will you get? How can you prevent this from causing an error?
Save your changes to the file and attach it below for evaluation.

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_2

Step: 3

blur-text-image_3

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

Computer Aided Database Design

Authors: Antonio Albano, Valeria De Antonellis, A. Di Leva

1st Edition

0444877355, 978-0444877352

More Books

Students explore these related Databases questions