Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

perl to python translation I am translating a couple pieces of code from perl to python and well this one has me guessing my self

perl to python translation I am translating a couple pieces of code from perl to python and well this one has me guessing my self so I need some help here. PERL CODE open(F, $groupsFile) || die "Can't open groups file '$groupsFile' "; my %groups; while() { chomp; my @a = split(/\s/); my $groupId = shift(@a); my @b = sort(@a); my $sortedMembers = join(" ", @b); $groups{$sortedMembers} = $groupId; } foreach my $grp (sort(keys(%groups))) { print "$groups{$grp} $grp " PYTHON TRANSLATION if(len(sys.argv) = 1 groupFile = sys.arg[0] IN = (groupFile -r) groups = { } for line in IN: IN.line.splt arr1 =[] # line splt sort #groupID = aa2 = [] # sort array 1 # "sorted memebers" join lines in array with a space between # array groups[sortedmemebers] == array group D

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

Database Systems A Practical Approach To Design Implementation And Management

Authors: THOMAS CONNOLLY

6th Edition

9353438918, 978-9353438913

More Books

Students also viewed these Databases questions

Question

Find and sketch the domain for each function. f(x, y) = (x 4)(y 9)

Answered: 1 week ago

Question

2. Explain how the role of training is changing.

Answered: 1 week ago

Question

7. General Mills

Answered: 1 week ago