Question
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
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:
- If the users input word is less than 8 characters, output Password not long enough.
- If the users input word is greater than or equal to 8 characters, do the following:
- Replace e with @
- Replace s or S with $
- Replace t or T with +
- 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 its 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 es 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.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started