1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Svetlanka [38]
3 years ago
12

Some Web sites impose certain rules for passwords. Write a function that checkswhether a string is a valid password. Suppose the

password rules are as follows:A password must have at least eight characters.A password must consist of only letters and digits.A password must contain at least two digits.Write a program that prompts the user to enter a password and displays validpassword if the rules are followed or invalid password otherwise.
Computers and Technology
1 answer:
Levart [38]3 years ago
6 0

Answer:

def check_password(pwd):

   c=0

   d=0

   for i in pwd:

       if (i>='a' and i<='z') or (i>='A' and i<='Z'):

           c+=1

       elif i>='0' and i<='9':

           d+=1

           c+=1

   if len(pwd)==c and d>=2 and len(pwd)>=8:

       print("valid password")

   else:

       print("Invalid password")

 

ps=input("Enter password for checking : ")

check_password(ps)

Explanation:

  • Loop through the password and check if it contains any alphabet.
  • Increment the counter if it contains any alphabet.
  • If it contains a number, increment both c and d variables.
  • Finally display the relevant message.
You might be interested in
What is the relation between Information and Data?
Rudiy27

Answer:

In a sentence: data is raw numbers, while information is organized data.

Explanation:

Data is a series of numbers or facts.  A data set is a collection of data that are related (for examples all the students result in your last math exam).  But it's not organized by itself... and rarely mean anything when looked at it in a raw manner.

To make sense of a data collection, you have to analyze it, calculate the mean or median of the data set for example... this is a treatment that has to be done to a data set to give it significance.. after such analysis, the result you have (mean, median, etc..) is a piece of information devired from the data.

3 0
3 years ago
People often delete or read email based upon the subject line alone select one:
erica [24]
The statement people often delete or read email based upon the subject line alone select one is TRUE. Based on the subject or topic of the email, they will judge if it is worthy to be read or deleted.
5 0
3 years ago
Read 2 more answers
Write a Python class that inputs a polynomial in standard algebraic notation and outputs the first derivative of that polynomial
Ivahew [28]

Answer:Python code: This will work for equations that have "+" symbol .If you want to change the code to work for "-" also then change the code accordingly. import re def readEquation(eq): terms = eq.s

Explanation:

3 0
3 years ago
Opinion on sandshrew​
Alex

Answer:Sandshrew is cute

Explanation:

3 0
3 years ago
Please help ASAP!
makkiz [27]
B. training is the correct answer
8 0
2 years ago
Other questions:
  • How can investors receive compounding returns
    13·1 answer
  • What are the only things that can be declared in an interface?
    11·1 answer
  • What may happen if there is too much harmony in a design?
    14·1 answer
  • In C++ please.
    8·1 answer
  • Write a function in Java to implement the following logic:
    13·1 answer
  • Which statistical measurement tools should be
    8·1 answer
  • Match the feature to its function.
    7·1 answer
  • Direction: Read each item carefully and choose the letter of the correct answer. Write your answers on a separate sheet of paper
    12·1 answer
  • List one unprofessional AND one professional example of internet/social media
    15·1 answer
  • If a password is entered wrongly three times the computer will
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!