Question

In: Computer Science

An 8-digit password is required to have exactly three 0’s. The other 5 digits can be...

An 8-digit password is required to have exactly three 0’s. The other 5 digits can be any number 1-7, but numbers 1-7 may not be repeated. Write a program that lists all the possible outcomes. Provide your code and first 100 outcomes (Python).

Solutions

Expert Solution

CODE:

#A package to find permutations.
from itertools import permutations
#Getting all the permutations of given list of numbers and of length 6 because
#[0,0,0] will be treated as 1 it's actual length is 3 so rest 5 digit are required
# hence a total of 6.
perm = permutations([[0,0,0],1,2,3,4,5,6,7],6)
#Converting the permutation to list.
perm_list = list(perm)
#A variable that holds our password.
password = ""
#Looping 100 times to print first 100 password.
for i in range(0,100):
#Converting the tuple present at each index in perm_list to list.
ls = list(perm_list[i])
#Looping throught each element of the converted list.
for item in ls:
#Checking for [0,0,0] in the list.
if(isinstance(item,list)):
#Appending each 0 to password.
for element in item:
password += str(element)
#If not [0,0,0]
else:
#Appending directly the digit.
password += str(item)
#Printing the password.
print(password)
#Resetting the password variable to hold next password.
password = ""

CODE SCREENSHOT:

CODE OUTPUT:


Related Solutions

2. An 8-digit password is required to have three 0’s and five 1’s. You will determine...
2. An 8-digit password is required to have three 0’s and five 1’s. You will determine how many unique passwords are possible. First consider how you might notate possible outcomes in the process of listing them. For example, any of the following can represent the same outcome: 01011101 137 (the digits are the locations of the 0’s) 24568 (the digits are the locations of the 1’s) Write a program that lists and counts the unique passwords. Provide your code, all...
In an exactly 8 character long password where capital letters, small letters, and digits (0 to...
In an exactly 8 character long password where capital letters, small letters, and digits (0 to 9) must be used. Regardless of the order, how many passwords will use exactly 5 ones, 4 twos, and one Z?
Using the digits 0 through 8, find the number of different 5-digit numbers such that: a....
Using the digits 0 through 8, find the number of different 5-digit numbers such that: a. Digits can be used more than once. b. Digits cannot be repeated, but can come in any order. c. Digits cannot be repeated and must be written in increasing order. d. Which of the above counting questions is a combination and which is a permutation? Explain why this makes sense.
5. Using only the digits of 1, 4, 5, 8, (a) How many three digit numbers...
5. Using only the digits of 1, 4, 5, 8, (a) How many three digit numbers can be formed? (b) How many odd numbers greater than 10 can be formed? (c) How many even number less than 300 can be formed? Repetition is allowed!
- Determine the number of three-digit area codes that can be made from the digits 0-9,...
- Determine the number of three-digit area codes that can be made from the digits 0-9, assuming the digits can repeat. - Suppose that there are 15 people in a class. How many ways can the instructor randomly pick three students, if the order doesn’t matter? -You are playing a game at a local carnival where you must pick a card from a normal 52-card deck. If you pick a face card (jack, queen or king) you get $2. If...
In a three-digit lottery, each of the three digits is supposed to have the same probability...
In a three-digit lottery, each of the three digits is supposed to have the same probability of occurrence (counting initial blanks as zeros, e.g., 32 is treated as 032). The table shows the frequency of occurrence of each digit for 90 consecutive daily three-digit drawings.      Digit Frequency 0 26 1 18 2 35 3 22 4 16 5 30 6 35 7 32 8 24 9 32 Total 270 (a) Calculate the chi-square test statistic, degrees of freedom, and...
In a three-digit lottery, each of the three digits is supposed to have the same probability...
In a three-digit lottery, each of the three digits is supposed to have the same probability of occurrence (counting initial blanks as zeros, e.g., 32 is treated as 032). The table shows the frequency of occurrence of each digit for 90 consecutive daily three-digit drawings.      Digit Frequency 0 26 1 23 2 29 3 38 4 30 5 26 6 26 7 20 8 27 9 25 Total 270 (a) Calculate the chi-square test statistic, degrees of freedom, and...
Using the digits 2 through 8, find the number of different 5-digit numbers such that: (a)...
Using the digits 2 through 8, find the number of different 5-digit numbers such that: (a) Digits can be used more than once. (b) Digits cannot be repeated, but can come in any order. (c) Digits cannot be repeated and must be written in increasing order. (d) Which of the above counting questions is a combination and which is a permutation? Explain why this makes sense
How many three​-digit numbers can be formed from the digits 0,1, 2, 3, 4, 5, 6,...
How many three​-digit numbers can be formed from the digits 0,1, 2, 3, 4, 5, 6, 7, and 8 if each digit can be used only​ once? I got this: 448 ​How many are greater than 330​? <- I don't understand how to answer this. I have looked up the answer and could probably figure it out, but please explain where the numbers you are multiplying are coming from. I want to learn how to answer this type of question...
A password is a sequence of letters (a–z) and digits (0–9). Findthe number of passwords...
A password is a sequence of letters (a–z) and digits (0–9). Find the number of passwords of length 10 under the constraints in (a), (b) or (c) (three separate problems). Express your answer using factorials and integers, products and ratios of them, and/or sums of such things.(a) There are 3 letters and 7 digits, and at most one ‘9’.(b) There are 6 letters and 4 digits, and no digit occurs twice.(c) No letters are used BUT the first four digits...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT