5. Write a whole program that does the following: The program should create 8-le
ID: 3607375 • Letter: 5
Question
5. Write a whole program that does the following: The program should create 8-letter passwords, made up of 8 random letters, until the user is satisfied Specifically, it should do the following repeatedly: first, it should print out a random password. Then, it should ask the user if the password is satisfactory. If the user enters y, the program ends; if the user enters n, everything repeats. (You may assume the user enters only y or n.) For full credit, you should use a FUNCTION that takes NO arguments, and returns a string (the random password). Hints : to create a random letter, import random and string, and use random.choice (string.letters). To create the full random password, start with an empty string, and += random lowercase letters on to the end, one letter at a time. 6. Two words are called granagrams if they have the same number of g’s AND the same number of r’s in them. For instance, greening and reigning are granagrams, because they each have two g's and one r. ggrrrh and Irxkabgrg are granagrams, while rage and garbage are not. Write a whole program that does the following: first, it asks the user to enter two words. Then, the program will print Granagrams or Not Granagrams depending on whether those two words are granagrams . ASSUME that all letters entered are LOWERCASE, and each word contains no spaces. For full credit, you should use a FUNCTION - or perhaps a couple, your choice - which returns a count of the number of appearances of a certain letter in a string. So your function(s) should have at least one argument which is a string, and should return an int - beyond that is up to you. DO NOT USE .count (O!Explanation / Answer
PGM1:
PGM2:
You can use the following functions:-
for eg.
To check for the presence of capital or small letters you can use this:-
How it Works? Although this code is self-explanatory, there is nothing rocket-science about it, I will explain it since, you seem to be a beginner to me:-
By creating
I am storing a copy of the password which is lowercase. So if the password variable contains some capital letters then the
will return False, and you can find out whether the string contains some capital letters or not. As pointed out by @MartijnPieters, you can use
also instead of
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.