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
VARVARA [1.3K]
3 years ago
6

Write a function named enterNewPassword. This function takes no parameters. It prompts the user to enter a password until the en

tered password has between 8 and 15 characters, including at least one digit. Tell the user whenever a password fails one or both of these tests. The function enterNewPasswordshould return the new password.
Computers and Technology
1 answer:
zloy xaker [14]3 years ago
4 0

Answer:

def enterNewPassword():

 while True:

   password = input("Enter password: ")

   has_digit = False

   for i in password:

     if i.isdigit():

       has_digit = True

       break

   

   if not has_digit or (len(password) < 8 or len(password) > 15):

     if len(password) < 8 or len(password) > 15:

       print("The password length must be between 8 and 15!")

     if not has_digit:

       print("The password must include at least one digit!")

   else:

     return password

print(enterNewPassword())

Explanation:

*The code is in Python.

Create a function named enterNewPassword that takes no parameter

Create an indefinite while loop. Inside the loop, ask the user to enter the password. Initialize the has_digit as False, this will be used to check if password contains a digit or not. Create a for loop, that that iterates through the password, if one character is digit, set the has_digit as True and stop the loop (Use isdigit() to check if the character is digit or not).

After the for loop, check if has_digit is false or the length of the password is not between 8 and 15. If the length of the password is not between 8 and 15, print the error. If has_digit is false, again print the error.

Otherwise, password met the requirements and return the password

Call the enterNewPassword() function and print the result

You might be interested in
Give the type and value of each result of the following Java expressions.
atroni [7]
Give the type and value of each result of the following Java expressions. a. (5 / 2) * 2.0  type is float value is 4.0 b. (5/2.0) * 2 type is integer value is 5c. "1.3" + "5.2" type is string value is 1.35.2d. 1 + 7.0 + "2" + "x"  this will produce an error because we cannot add variables of different type
3 0
3 years ago
Define the following:-<br><br>1) cryptography<br><br>2) Quantum Cryptography​
Readme [11.4K]
1.) the art of writing or solving codes.
2.) the science of exploiting quantum mechanical properties to perform cryptographic tasks.

hope this helps :)
8 0
3 years ago
Read 2 more answers
Name the six parts of the product development life cycle.
Nuetrik [128]

Answer:

Development, Introduction, Growth, Maturity and Decline.

Explanation:

5 0
3 years ago
Read 2 more answers
Jeff’s father is installing a do-it-yourself security system at his house. He needs to get a device from his workshop that conve
Alenkasestr [34]

Answer:

Beeper

Explanation:

A buzzer pr beeper, as security device, converts electrical energy to sound energy.

3 0
4 years ago
Which of the following indicates the main benefit of having a larger hard drive on a computer
dem82 [27]
I would say the primary Beni fit is more space for storage , but also it does effect the speed eventually. If your hard drive is almost full, everything will be slower
8 0
4 years ago
Other questions:
  • Stan is looking at cloud computing options for his business needs. He wants a model that helps his business customers and client
    12·2 answers
  • Read each scenario, and then select the best wireless device for the worker’s needs. A trucker is constantly on the road. He fre
    8·2 answers
  • Select the correct answer. Which sentence best describe an effective management strategy? A. Conceal game-related clippings prio
    12·2 answers
  • FINISH THE SENTENCE <br><br> buzzfeed____reddit_____
    5·1 answer
  • 2 A_______<br> uses graphics or pictures to help the user navigate and<br> access programs
    14·1 answer
  • Write a function that receives three StaticArrays where the elements are already i n sorted order and returns a new Static Array
    11·1 answer
  • Why do we use the internet so much?​
    6·1 answer
  • Click print to publish your post in a blog true or false.​
    5·2 answers
  • PLEASE HELP<br><br><br> Write a pseudo code for an algorithm to wrap a gift.
    9·1 answer
  • What are the answers to these Python programs
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!