Question

In: Computer Science

Please add a statement that requires a number in the password to the following code: #Lab...

Please add a statement that requires a number in the password to the following code:

#Lab on functions
#By Abi Santo
#10/25/20

def get_first_and_last_names():
first = input("Enter your first name: ")
last = input("Enter your last name: ")
return (first.lower(), last.lower())

def create_username(name_list):
uname = name_list[0] +"." + name_list[1]
return uname

def create_password():
passwd = input("Create a new password: ")

#make sure the password has atleast 8 characters
while len(passwd)<8:
print("Fool of a Took! That password is feeble!")
passwd = input("Create a new password: ")

while passwd.lower() == passwd:
print("The password must contain at least one uppercase character")
passwd = input("Create a new password: ")


print("The force is strong in this one...")
print("Your password has been accepted.")
return passwd


def main():
#Get user's first and last name
first_last_name_list = get_first_and_last_names()

#create a username using the first and last name
username = create_username(first_last_name_list)

#ask the user to create a new password
password = create_password()

print("Account configured. Your new email address is: ", username + "@marist.edu")
  
  
main()


please use python

Solutions

Expert Solution

code analysis:

After giving first name and last name.....

If we give "pavan" as passwd. It did not accept since it has less than 8 characters.

Then we give...."pavankumar" as passwd. Since it has atleast 8 characters..it moved on to check whether it has an uppercase character. since it does not..program asked for passwd again.

At this stage I gave "Pavan". The program accepted.though there are less than 8 characters. It's actually worng.

Code:

def get_first_and_last_names():

first = input("Enter your first name: ")

last = input("Enter your last name: ")

return (first.lower(), last.lower())

def create_username(name_list):

uname = name_list[0] +"." + name_list[1]

return uname

def create_password():

passwd = input("Create a new password: ")

while(True):

flag_digit = False

length = len(passwd)

upper_check = (passwd.lower() == passwd)

for symbol in passwd:

if symbol.isdigit():

flag_digit = True

#make sure the password has atleast 8 characters. Otherwise read passwd again from user and check from initial condition

if length < 8:

print("Fool of a Took! That password is feeble!")

passwd = input("Create a new password: ")

continue

#If the passwd has 8 characters. Make sure the passwd also has an upper case character: Otherwise read passwd again from user and check from initial condition

elif upper_check == True:

print("The password must contain at least one uppercase character")

passwd = input("Create a new password: ")

continue

#If the passwd has 8 characters and an uppercase character make sure it also has digit. Otherwise read passwd again from user and check from initial condition

elif flag_digit == False:

print("Password should contain atleast one digit")

passwd = input("Create a new password: ")

continue

#If it satisifies all the conditions...BREAK

else:

print("The force is strong in this one...")

break

print("Your password has been accepted.")

return passwd


def main():

#Get user's first and last name

first_last_name_list = get_first_and_last_names()

#create a username using the first and last name

username = create_username(first_last_name_list)

#ask the user to create a new password

password = create_password()

print("Account configured. Your new email address is: ", username + "@marist.edu")

main()

PLEASE....Rate....If you like the answer......


Related Solutions

Please add to this Python, Guess My Number Program. Add code to the program to make...
Please add to this Python, Guess My Number Program. Add code to the program to make it ask the user for his/her name and then greet that user by their name. Please add code comments throughout the rest of the program If possible or where you add in the code to make it ask the name and greet them before the program begins. import random def menu(): print("\n\n1. You guess the number\n2. You type a number and see if the...
(Python Code please) Guess the number! You will add to the program you created last week....
(Python Code please) Guess the number! You will add to the program you created last week. This week you will add quite a bit of code to your project. You will add an option for the computer to guess as well as the user to guess a number. In addition, you will add a menu system. Be sure to import random at the beginning of your code and use a comment block explaining what your program does #Guess the number...
This code needs to be in C++, please. Step 1: Add code to prompt the user...
This code needs to be in C++, please. Step 1: Add code to prompt the user to enter the name of the room that they are entering information for. Validate the input of the name of the room so that an error is shown if the user does not enter a name for the room. The user must be given an unlimited amount of attempts to enter a name for the room. Step 2: Add Input Validation to the code...
VISUAL STUDIO CODE Use a for loop for to create "password". Request the password at least...
VISUAL STUDIO CODE Use a for loop for to create "password". Request the password at least 3 times. If the password is 12345, the procedure ends, if the correct password entered, close excel saving changes. THANKS
IN C ++ PLEASE CODE FOR BUBBLE SORT---Add code to sort the bowlers. You have to...
IN C ++ PLEASE CODE FOR BUBBLE SORT---Add code to sort the bowlers. You have to sort their parallel data also. Print the sorted bowlers and all their info . You can use a bubble sort or a shell sort. Make sure to adjust your code depending on whether or not you put data starting in row zero or row one. Sort by Average across, lowest to highest.  The highest average should then be on the last row.. When you sort...
Password Checking Software to reset passwords often requires the user to enter the password twice, checking...
Password Checking Software to reset passwords often requires the user to enter the password twice, checking to make sure it was entered the same way both times. Write a program in Python that contains functions/methods in it that can verify that the two passwords entered are correct. Your project should contain a method that asks the user to enter a password twice, then either tell the user that the two entries were not the same and then start the process...
Please take the code below and add some javascript to it. Please use javascript inline. Please...
Please take the code below and add some javascript to it. Please use javascript inline. Please be sure to specify within the webpage with something like 'Click here' too show what was done and how to activate it. Please post in a format that can be directly copied. Thank you in advance HINT: add some fun widgets to the page index-css.html: <!DOCTYPE html> <html lang="en"> <head> <!-- title for web page --> <title>Index-CSS Page</title> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1">...
JAVA PLEASE Write a recursive function that does the following: Given a number, add all the...
JAVA PLEASE Write a recursive function that does the following: Given a number, add all the digits and display the sum. Example: ​​The sum of the number 5432 would be 14. o Do not use the static modifier. No global variables. Your program should implement a non-tail recursive algorithm. In other words, it should do something as it moves towards the base case, the tail, and also do something as it comes back from the tail to the beginning. o...
Also please add comments on the code and complete in C and also please use your...
Also please add comments on the code and complete in C and also please use your last name as key. The primary objective of this project is to increase your understanding of the fundamental implementation of Vigenere Cipher based program to encrypt any given message based on the Vignere algorithm. Your last name must be used as the cipher key. You also have to skip the space between the words, while replicating the key to cover the entire message. Test...
Please add comments to this code! JAVA Code: import java.text.NumberFormat; public class Item {    private...
Please add comments to this code! JAVA Code: import java.text.NumberFormat; public class Item {    private String name;    private double price;    private int bulkQuantity;    private double bulkPrice;    /***    *    * @param name    * @param price    * @param bulkQuantity    * @param bulkPrice    */    public Item(String name, double price, int bulkQuantity, double bulkPrice) {        this.name = name;        this.price = price;        this.bulkQuantity = bulkQuantity;        this.bulkPrice = bulkPrice;   ...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT