跳至主要內容

Assignment 6

AI悦创原创Python 一对一教学SCU CSSanta Clara University圣克拉拉大学Python 一对一教学SCU CSSanta Clara University圣克拉拉大学大约 2 分钟...约 465 字

Scripting Problem (5 points)

The goal of this problem is to find the current user’s group with the largest number of members with the exclusion of the group users. That is, considering the groups that the current user belongs to (with the exclusion of the group users), which one is composed of the largest number of members? (Don’t worry about ties)

Start by looking at the file /etc/group, which contains the members belonging to each group in the following format: groupname:x:groupid:comma_separated_list_of_members

For example, the entry corresponding to group OMIS107_ADMIN is as follows:

OMIS107_ADMIN:x:1003:msamorani,samo,labinstructor

Your output should be formatted as follows:

The current user's most numerous group is xxxx, which has yyyy members

Note: no need to explicitly exclude the group users, because that group is not present in /etc/group.

Examples:

Output if fakestudent executes your code:

Output if samo executes your code:

image-20230609142254770
image-20230609142254770
公众号:AI悦创【二维码】

AI悦创·编程一对一

AI悦创·推出辅导班啦,包括「Python 语言辅导班、C++ 辅导班、java 辅导班、算法/数据结构辅导班、少儿编程、pygame 游戏开发、Web、Linux」,全部都是一对一教学:一对一辅导 + 一对一答疑 + 布置作业 + 项目实践等。当然,还有线下线上摄影课程、Photoshop、Premiere 一对一教学、QQ、微信在线,随时响应!微信:Jiabcdefh

C++ 信息奥赛题解,长期更新!长期招收一对一中小学信息奥赛集训,莆田、厦门地区有机会线下上门,其他地区线上。微信:Jiabcdefh

方法一:QQopen in new window

方法二:微信:Jiabcdefh

上次编辑于:
贡献者: AndersonHJB
你认为这篇文章怎么样?
  • 0
  • 0
  • 0
  • 0
  • 0
  • 0
评论
  • 按正序
  • 按倒序
  • 按热度