Question

In python, write the following program, high school question, please keep simple. When I submitted the...

In python, write the following program, high school question, please keep simple. When I submitted the solution, I get an error as 'wrong answer'. Please note below the question and then the solution with compiler errors.

7.2 Code Practice: Question 2

Instructions

Write a program to generate passwords. The program should ask the user for a phrase and number, and then create the password based on our special algorithm. The algorithm to create the password is as follows:

  1. If the user’s input word is less than 8 characters, output Password not long enough.
  2. If the user’s input word is greater than or equal to 8 characters, do the following:
    1. Replace e with @
    2. Replace s or S with $
    3. Replace t or T with +
    4. Capitalize the word and add the number to the end.

Ever wonder why strong passwords are important? Read here (Links to an external site.) for more information on strong passwords.

Sample Run 1

Enter your word: zebras

Enter a number: 62

Password not long enough.

Sample Run 2

Enter your word: newyorkcity

Enter a number: 892

Password: N@wyorkci+y892

________________________________________________________________________________________________________

submission no.: #3036328

submitted on: January 24, 2020 07:36

SUBMISSION STATUS: wrong answer

programming language: Python 3.x (python 3.5.3)

memory: 27720kB

execution time: 0.12s

Test cases

Test 0 - Output - Using example value - 1

        Password not long enough

Test 1 - Output - Using example value - 1

        N@wyorkci+y892

Test 2 - Output - Using word with spaces - 1

Test 3 - Output - Using word starting with e - 0

Test 4 - Output - Using word with E - 0

Test 5 - Output - Using word with s - 1

Test 6 - Output - Using word starting with t - 1

Test 7 - Output - Using word with all possible letters/numbers - 0

7.2 Q2 Master Judge - Score: 62

Output (stdout stream)

DATASET NUMBER: 0

Enter your word: Enter your number: Password not long enough

DATASET NUMBER: 1

Enter your word: Enter your number: N@wyorkci+y892

DATASET NUMBER: 2

Enter your word: Enter your number: Word wi+h $pac@11

DATASET NUMBER: 3

Enter your word: Enter your number: Ewok$ar@gr@a+59

DATASET NUMBER: 4

Enter your word: Enter your number: ArEyouh@rE94

DATASET NUMBER: 5

Enter your word: Enter your number: $+opbymyoffic@14023987

DATASET NUMBER: 6

Enter your word: Enter your number: +o+ally$4

DATASET NUMBER: 7

Enter your word: Enter your number: AAbBcCdD@EfFgGhHiIjJkKlLmMnNoOpPqQrR$$++uUvVwWxXyYzZ1234567890

Errors (stderr stream)

DATASET NUMBER: 0

DATASET NUMBER: 1

DATASET NUMBER: 2

DATASET NUMBER: 3

DATASET NUMBER: 4

DATASET NUMBER: 5

DATASET NUMBER: 6

DATASET NUMBER: 7

Source code

s=str(input("Enter your word: "))

n= int(input("Enter your number: "))

if(len(s)<8):

        print("Password not long enough")

else:

        if s[0]<='z' and s[0]>='a':

                 newchar = chr(ord(s[0])-97+65)

                 s = newchar + s[1:]+str(n)

        s=s.replace("e","@")

        s=s.replace("s","$")

        s=s.replace("S","$")

        s=s.replace("t","+")

        s=s.replace("T","+")

        print(s)

Capitalize here is for the first letter. Please refer to the debugging checklist below attached to the problem

Debugging Tips - 7.2 Code Practice: Question 2
On occasion, after a successful run in CodeSkulptor, you may find that your code is marked incorrect in the
Sandbox. This is because the Sandbox checks the accuracy and efficiency of your code based on the program
rubric, whereas CodeSkulptor does not. This means it's time to debug your code!
Test Case Descriptions and Specific Debugging Tips
The Sandbox uses Test Cases, which are checks that test the code and see if it’s correct. You can see if you
passed or failed a test case in the widget.

Test Case 0 Using "zebras" and "62" as inputs, this test case checks if output contains "Password not long enough".
Examine how your program determines the word is not long enough. ⃞


Test Case 1 Using "newyorkcity" and "892" as inputs, this test case checks if output contains "N@wyorkci+y892".
Look at how your program replaces characters. ⃞


Test Case 2 This test case checks if output is correct when the input includes spaces.
Examine how the program deals with spaces. ⃞


Test Case 3 This test case checks if output is correct when the input starts with lowercase “e”
Review how the program replaces e’s before capitalizing the word. ⃞


Test Case 4 This test case checks if output is correct when the input contains a capitalized “E”.
Make sure the “e” replacement is case-sensitive. ⃞

Test Case 5 This test case checks if output is correct when the input contains an “s”
Be sure that “s” is replaced with “$”. ⃞


Test Case 6 This test case checks if output is correct when the input starts with lowercase “t”
Double-check that “t” is replaced with “+”. ⃞


Test Case 7 This test case checks if output is correct when the input has all possible letters/numbers.
Double-check that all rules are followed in the right order. ⃞

0 0
Add a comment Improve this question Transcribed image text
Answer #1

This should work now

Code

s=str(input("Enter your word: "))
n= int(input("Enter your number: "))
if(len(s)<8):
print("Password not long enough")
else:
newchar = s[0]
if s[0]<='z' and s[0]>='a':
newchar = chr(ord(s[0])-97+65)
s = newchar + s[1:]+str(n)
s=s.replace("e","@")
s=s.replace("s","$")
s=s.replace("S","$")
s=s.replace("t","+")
s=s.replace("T","+")
print(s)

It was not working for strings starting with uppercase characters. I've fixed it now and it should work fine.

Add a comment
Know the answer?
Add Answer to:
In python, write the following program, high school question, please keep simple. When I submitted the...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a program that asks the user to enter a password, and then checks it for...

    Write a program that asks the user to enter a password, and then checks it for a few different requirements before approving it as secure and repeating the final password to the user. The program must re-prompt the user until they provide a password that satisfies all of the conditions. It must also tell the user each of the conditions they failed, and how to fix it. If there is more than one thing wrong (e.g., no lowercase, and longer...

  • Can I please get some assistance on this? 1. Write a program to test the correctness...

    Can I please get some assistance on this? 1. Write a program to test the correctness of a password according to some rules. If the password is not valid, print messages showing what's wrong with the password. Partial program output should look like this: Please enter a password. It must be at least 8 characters long and contain at least 2 alpha characters, at least one upper case and one lower case, at least 1 numbers, and at least 1...

  • For this lab you will write a Java program that plays a simple Guess The Word...

    For this lab you will write a Java program that plays a simple Guess The Word game. The program will prompt the user to enter the name of a file containing a list of words. These words mustbe stored in an ArrayList, and the program will not know how many words are in the file before it starts putting them in the list. When all of the words have been read from the file, the program randomly chooses one word...

  • please help me out and input values please .. main cpp.. please follow intructions exactly witj...

    please help me out and input values please .. main cpp.. please follow intructions exactly witj clarity please CSE 110-Intro to Computer Programming Project #3 Requirements-String Class Functions and Test Case Documentation Using the String Class, design and develop a multi-file password validation program and Test case Document (10% of grade) that requests a password, and validates it based on the following criteria. The password must be at least 8 characters long, contain at least one number, and at least...

  • hey please answer in python 3 This is the test for these questions. it has to...

    hey please answer in python 3 This is the test for these questions. it has to be exactly the same as the Expected output. notice my code is very close to getting it but im always off by 0.01 or 0.02. Thank you for the help! In this exercise, you will build a program to process files containing paragraphs. The aim of the program is to simply count the number of words and compute their length. The file, however, may...

  • I have a python project that requires me to make a password saver. The major part...

    I have a python project that requires me to make a password saver. The major part of the code is already giving. I am having trouble executing option 2 and 3. Some guidance will be appreciated. Below is the code giving to me. import csv import sys #The password list - We start with it populated for testing purposes passwords = [["yahoo","XqffoZeo"],["google","CoIushujSetu"]] #The password file name to store the passwords to passwordFileName = "samplePasswordFile" #The encryption key for the caesar...

  • Please make this Python code execute properly. User needs to create a password with at least...

    Please make this Python code execute properly. User needs to create a password with at least one digit, one uppercase, one lowercase, one symbol (see code), and the password has to be atleast 8 characters long. try1me is the example I used, but I couldn't get the program to execute properly. PLEASE INDENT PROPERLY. def policy(password): digit = 0 upper = 0 lower = 0 symbol = 0 length = 0 for i in range(0, len(password)): if password[i].isdigit(): # checks...

  • python Create a program to open a text file for reading, find the maximum number in...

    python Create a program to open a text file for reading, find the maximum number in the file, determine if that maximum number is even, and write to an output text file. You should either write Yes if the number is even, otherwise write the maximum number. You should note the following: • Your input file must be named input.txt • The input file has one integer number per line • Your output file must be named output.txt • Your...

  • In python Please type the code Question 4: Write a program that reads an English word...

    In python Please type the code Question 4: Write a program that reads an English word from the user, and prints how many vowels and how many consonants it contains. Note: You may assume the letter Y is not a vowel. Sample output (2 different executions) Enter a word: test test has 1 vowels and 3 consonants Enter a word: Apple Apple has 2 vowels and 3 consonants.

  • Swapping Values in python Summary In this lab, you complete a Python program that swaps values...

    Swapping Values in python Summary In this lab, you complete a Python program that swaps values stored in three variables and determines maximum and minimum values. The Python file provided for this lab contains the necessary input and output statements. You want to end up with the smallest value stored in the variable named first and the largest value stored in the variable named third. You need to write the statements that compare the values and swap them if appropriate....

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT