Use python to calculate how many different passwords can be formed with 6 lower case English letters. for a 1 letter password there would be 26 possibilities. for a 2 letter password each letter is independent of the other so there would be 26 times 26 possibilities. using this information print the amount of possible passwords that can be formed with 6 letters

Use python to calculate how many different passwords can be formed with 6 lower case English letters. for a 1 letter password, there would be 26 possibilities. for a 2 letter password, each letter is independent of the other, so there would be 26 times 26 possibilities. using this information, print the amount of possible passwords that can be formed with 6 letters

 

Use python to calculate how many different passwords can be formed with 6 lower case English letters

 

 

If we try to interpret the  above problem statement,  we come to the below conclusion.

Total number of alphabets is 26  password  length is one = 26 ^ 1 = 26

Total number of alphabet in 26 password  length is two = 26 ^ 2 = 676
Total Number of alphabets is 26 password  length is six = 26 ^ 6 = 308915776

Whenever the password  length changes  we have to race 26 raised to the power of password length.


Python program
=======================
Let's ask a user to enter the total number of English alphabets  using the input function to  store it into a variable.  using another input function asks the user to enter the password length and convert it into an integer.


letters = int(input("Enter Number of English Letters : "))
password_length = int(input("Enter Password Length : "))


Once we get the both the parameters raise letters to the the password length  using double star operator (**) in Python.  using printf function print the number.

print("Number of Possible Passwords are : ", letters ** password_length)


Final Program
=============================
letters = int(input("Enter Number of English Letters : "))
password_length = int(input("Enter Password Length : "))

print("Number of Possible Passwords are : ", letters ** password_length)

OUTPUT:
=============================
Enter Number of English Letters : 26
Enter Password Length : 6
Number of Possible Passwords are :  308915776

OUTPUT:
===============================
Enter Number of English Letters : 26
Enter Password Length : 2
Number of Possible Passwords are :  676

OUTPUT:
===============================
Enter Number of English Letters : 26
Enter Password Length : 7
Number of Possible Passwords are :  8031810176


Conclusion: Run the program by providing different password lengths. Comment down below if you have any suggestions.

Post a Comment

0 Comments