Using Python 3.6.0 A consider a password valid if it contain only alphabets and
ID: 3819712 • Letter: U
Question
Using Python 3.6.0A consider a password valid if it contain only alphabets and numbers. Additionally it must contain at least one uppercase letter and at least one number and must be 7 characters or longer. Write a function, called isValid, which takes a string as a parameter and returns the Boolean value True if it is a valid password and the Boolean value False if it is not. Depending on what the function returns for an inputted password output if it is valid or not.
Note: you will get the return value from the function isValid and depending on the returned value you will print one line or the other.
Sample output 1: Enter the password: Abc123A The password is valid
Sample output 2: Enter the password: hello6 The password is not valid
Sample output 3: Enter the password: xy_abc The password is not valid Using Python 3.6.0
A consider a password valid if it contain only alphabets and numbers. Additionally it must contain at least one uppercase letter and at least one number and must be 7 characters or longer. Write a function, called isValid, which takes a string as a parameter and returns the Boolean value True if it is a valid password and the Boolean value False if it is not. Depending on what the function returns for an inputted password output if it is valid or not.
Note: you will get the return value from the function isValid and depending on the returned value you will print one line or the other.
Sample output 1: Enter the password: Abc123A The password is valid
Sample output 2: Enter the password: hello6 The password is not valid
Sample output 3: Enter the password: xy_abc The password is not valid
A consider a password valid if it contain only alphabets and numbers. Additionally it must contain at least one uppercase letter and at least one number and must be 7 characters or longer. Write a function, called isValid, which takes a string as a parameter and returns the Boolean value True if it is a valid password and the Boolean value False if it is not. Depending on what the function returns for an inputted password output if it is valid or not.
Note: you will get the return value from the function isValid and depending on the returned value you will print one line or the other.
Sample output 1: Enter the password: Abc123A The password is valid
Sample output 2: Enter the password: hello6 The password is not valid
Sample output 3: Enter the password: xy_abc The password is not valid A consider a password valid if it contain only alphabets and numbers. Additionally it must contain at least one uppercase letter and at least one number and must be 7 characters or longer. Write a function, called isValid, which takes a string as a parameter and returns the Boolean value True if it is a valid password and the Boolean value False if it is not. Depending on what the function returns for an inputted password output if it is valid or not.
Note: you will get the return value from the function isValid and depending on the returned value you will print one line or the other.
Sample output 1: Enter the password: Abc123A The password is valid
Sample output 2: Enter the password: hello6 The password is not valid
Sample output 3: Enter the password: xy_abc The password is not valid
Explanation / Answer
def isValid(s):
if(len(s)<7):
return False
up = 0
for i in s:
if not (i.isalpha() or i.isdigit()):
return False
if i.isupper():
up = 1
if up == 0:
return False
return True
d = isValid("abc7")
print(d)
d = isValid("a_bc7efg")
print(d)
d = isValid("Abc7efg")
print(d)
d = isValid("A_bc7efg")
print(d)
d = isValid("abCefgh")
print(d)
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.