Need help with lab 4.10.1 all permutations of names in python   Input: Julia Lucas Mia

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Need help with lab 4.10.1 all permutations of names in python

 

Input:

Julia Lucas Mia

0
19
RI
A learn.zybooks.com/zybook/CYB_135_55317605/chapter/4/section/10
= zyBooks My library > CYB/135: Object-Oriented Security Scripting home > 4.10: LAB: All permutations of names
E zyBooks catalog e Help/FAQ 8 Ricky Ortiz -
Due 07/08/2022, 7.59 PM EDT
4.10 LAB: All permutations of names
Write a program that lists all ways people can line up for a photo (all permutations of a list of strings). The program will read a list of one
word names, then use a recursive method to create and output all possible orderings of those names, one ordering per line.
When the input is:
Julia Lucas Mia
then the output is (must match the below ordering):
Julia Lucas Mia
Julia Mia Lucas
Lucas Julia Mia
Lucas Mia Julia
Mia Julia Lucas
Mia Lucas Julia
LAB
4.10.1: LAB: All permutations of names
ACTIVITY
OL/O
main.py
Load default template...
[) - səs
if len(namelist) =- 0:
4.
return []
if len namelist) 1.
8.
d.
enter
7.
shih &
B.
alt
ctrl
Transcribed Image Text:0 19 RI A learn.zybooks.com/zybook/CYB_135_55317605/chapter/4/section/10 = zyBooks My library > CYB/135: Object-Oriented Security Scripting home > 4.10: LAB: All permutations of names E zyBooks catalog e Help/FAQ 8 Ricky Ortiz - Due 07/08/2022, 7.59 PM EDT 4.10 LAB: All permutations of names Write a program that lists all ways people can line up for a photo (all permutations of a list of strings). The program will read a list of one word names, then use a recursive method to create and output all possible orderings of those names, one ordering per line. When the input is: Julia Lucas Mia then the output is (must match the below ordering): Julia Lucas Mia Julia Mia Lucas Lucas Julia Mia Lucas Mia Julia Mia Julia Lucas Mia Lucas Julia LAB 4.10.1: LAB: All permutations of names ACTIVITY OL/O main.py Load default template... [) - səs if len(namelist) =- 0: 4. return [] if len namelist) 1. 8. d. enter 7. shih & B. alt ctrl
0
1o
B
E Home
Section 5.15-CYB/135: Object-C X
Content
zy Section 4.10- CYB/135: Object-C X
A learn.zybooks.com/zybook/CYB_135 55317605/chapter/4/section/10
它 ☆
= zyBooks My library > CYB/135: Object-Oriented Security Scripting home > 4.10: LAB: All permutations of names
E zyBooks catalog e Help/FAQ 8 Ricky Ortiz -
Latest submission - 11:14 PM EST on 02/07/22
Total score: 0/10
Only show failing tests
Download this submission
1: Compare outputa
0/1
Output is nearly correct, but whitespace differs. See highlights below. Special character legend
Input
Julia Lucas Mia
Julia Lucas Mia
Julia Mia Lucas
Lucas Julia Mia
Your output
Lucas Mia Julia
Mia Julia Lucas
Mia Lucas Julia
Julia Lucas Mia
Julia Mia Lucas
Lucas Julia Mia
Expected output
Lucas Mia Julia
Mia Julia Lucas
Mia Lucas Julia
2 Compare output a
Output is nearly correct. but whitespace differs See highlights below
Special character legend
134
SAZE
SI
11
CO
e06
Mun
8.
enter
K.
shift &
alt
ctrl
Transcribed Image Text:0 1o B E Home Section 5.15-CYB/135: Object-C X Content zy Section 4.10- CYB/135: Object-C X A learn.zybooks.com/zybook/CYB_135 55317605/chapter/4/section/10 它 ☆ = zyBooks My library > CYB/135: Object-Oriented Security Scripting home > 4.10: LAB: All permutations of names E zyBooks catalog e Help/FAQ 8 Ricky Ortiz - Latest submission - 11:14 PM EST on 02/07/22 Total score: 0/10 Only show failing tests Download this submission 1: Compare outputa 0/1 Output is nearly correct, but whitespace differs. See highlights below. Special character legend Input Julia Lucas Mia Julia Lucas Mia Julia Mia Lucas Lucas Julia Mia Your output Lucas Mia Julia Mia Julia Lucas Mia Lucas Julia Julia Lucas Mia Julia Mia Lucas Lucas Julia Mia Expected output Lucas Mia Julia Mia Julia Lucas Mia Lucas Julia 2 Compare output a Output is nearly correct. but whitespace differs See highlights below Special character legend 134 SAZE SI 11 CO e06 Mun 8. enter K. shift & alt ctrl
Expert Solution
Explanation

Here I have taken input from the user and then used split() to separate the words and then converted it into a list.

Then, I have the permutations() function from the itertools to get the list of all the possible combinations of the list of words.

The permutations() function returns the list of tuples, where each tuple has different indexing of the words that were passed to the function permutations().

Next, I have iterated over the list of tuples using a for loop.

Inside the loop, I have used another loop to access the values inside each tuple.

In the inner loop, I have printed the values to the console by seprating them using space.

Next, I have used an empty print() statement to get a new line space.

trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Top down approach design
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education