← 2023 questions

2023 / INSTAGRAM / QUESTION 3

Password generator

Try the question in your own editor, then check your output below.

THE QUESTION

Finnick has recently set up an Instagram account and needs to create a secure password for it. He has chosen to use an array of words and subroutines to do this for him. Do the following tasks:

Task 1: Create an array of 10 words with at least 6 characters in each word.

Task 2: Create a subroutine to randomly select one of the words from the array.

Task 3: Create a subroutine to reverse the selected word.

(Hint: For string reversal, explore a concept called "slicing")

Question by Eleonora. Source: Girls In Code SEA — Behind the Screens, 2023, slide 17.

PRACTICE CHECK

Try your answer.

New practice word list. A submitted output cannot demonstrate that selection was random or that subroutines were used.

Run your program in your own editor, then paste its output below. This checks the stated output or checkpoint; it does not assess your full program. Practice attempts do not affect competition scores.

Use this practice word list: coding, planet, rocket, galaxy, python, school, garden, friend, future, puzzle. Submit one randomly selected word reversed.

Reveal worked answer

Generated password · one valid answer

gnidoc

Select any index from 0 through 9, then reverse that word with word[::-1]. Any of the ten valid reversals is accepted.