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
Why would businesses apply cell protection to spreadsheet entries? Provide one specific example.
docker41 [41]

Answer:

To protect a formula

Explanation:

One common example to apply cell protection to spreadsheet entries is to protect a formula used in the sheet to calculate payouts or rankings for example.   A manager might want to share the results of the team to all its team and provides some ranking or other form of calculations in the sheet.  He then needs to protect the formula so it's not altered by the team members or anyone else reviewing the file.

6 0
3 years ago
Write a full class definition for a class named Counter, and containing the following members: A data member counter of type int
vfiekz [6]

// making the class

class Counter {

int counter;

int limit;

// Constructor

Counter(int a, int b){

counter = a;

limit = b;

}

// static function to increment

static increment(){

if(counter<limit)

nCounter+=1;

}

// Decrement function

void decrement(){

if(counter>0)

nCounter-=1;

}

int getValue(){

return counter;

}

static int nCounter;

int getNCounters(){

return nCounter;

}

};

// Initializa the static

int Counter::nCounter = 0;

4 0
3 years ago
Is the core of an operating system that controls its basic functions.
WINSTONCH [101]

Answer:

Explanation:

Tweaker

5 0
3 years ago
Elliott is trying to normalize a database that he has designed. Which is not one of the elements of 1NF or 2NF?
muminat

Answer: I think it’s D

Explanation: the rest apply to the the rules of 1NF and 2NF

5 0
3 years ago
The general syntax to overload the stream extraction operator &gt;&gt; for a class is ____.
Aloiza [94]
Istream& operator>> (istream& input, Example& example)
{
// Extract your data from input stream here
return input;
}
5 0
3 years ago
Other questions:
  • You can use automatic link-checking software to identify invalid hyperlinks. if you find invalid links, what should you do next?
    13·1 answer
  • What is the easiest way to be sure you have selected all of the content related to a specific tag?
    11·1 answer
  • How to select the entire table in microsoft excel
    11·1 answer
  • A token is combination of hardware and software that acts as a gatekeeper and prevents unauthorized users from accessing private
    11·1 answer
  • Exactly how thin is the air in outer space?
    10·1 answer
  • An organization is assigned a Class-C network 200.120.80.0 and wants to form subnets for its threedepartments: D1 (60hosts), D2
    7·1 answer
  • Express 0.0005 x 10-4 farads as picofarads
    5·2 answers
  • In java please
    13·1 answer
  • D State Six Impact of ICT the society​
    7·1 answer
  • Which of these is most likely to contribute to the long term of a local ecosystem?
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!