Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
expand_more
expand_more
format_list_bulleted
Topic Video
Question
My code keeps outputting: File "c:\Users\####\Downloads\SSN.py", line 19
return False
^^^^^^^^^^^^
SyntaxError: 'return' outside function. Any idea on what's wrong?
import re
class SSN:
debug = False
pattern = r"^(?!666|000)(?P<area>[0-8][0-9]{2})[- ]?(?!00)(?P<group>\d{2})[- ]?(?!0000)(?P<serial>\d{4})$"
ssn_regex = re.compile(pattern)
@staticmethod
def is_valid(number):
match = SSN.ssn_regex.match(number)
if match == None:
return False
return match.group() == number
SAVE
AI-Generated Solution
info
AI-generated content may present inaccurate or offensive content that does not represent bartleby’s views.
Unlock instant AI solutions
Tap the button
to generate a solution
to generate a solution
Click the button to generate
a solution
a solution
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- Suppose you are given a function in module foo named `function loop_string_reverse_all that accepts a list of user entries and applies the method loop_string_reverse`` in modulefooto each of them, and returns a new list of reverse strings that doesn't include numbers. For eg, if function accepts the list input['ab2ji89','6hel', 'ol5f']then the function call returns the list['ijba', 'leh ', 'flo']``` Now ask the user to accept strings until user enters quit and display a list of reversed strings. If user enters ab2ji89 6hel ol5f quit output is ['ijba', 'leh', 'flo'] You can use the function loop_string_reverse_all in module foo to solve this. 376584.2127280.qx3zqy7arrow_forwardWrite a function named “HasDashDashOnBothEnds” that accepts 2parameters of the same as command line arguments (argc and argv). Itwill return true if one of the command line arguments that has “—” on boththe beginning and ending and false otherwise.Requirement: This function should not use cin, cout, string class or stringfunctions such as strlen, either. It should only use pointers.- 3 -Write a complete C++ program that accepts command line arguments andcall the above function. It will print out “Yes” if the function returns true and“No” if it returns false.For example, the following runs will print Yes, Yes, Yes, Yes, No, No, Noand No.HasDashDashOnBothEnds --HasDashDashOnBothEnds --One--HasDashDashOnBothEnds One –Three--HasDashDashOnBothEnds One Three --Nine--HasDashDashOnBothEnds -HasDashDashOnBothEnds –One- Three TwoHasDashDashOnBothEnds One -Two-- ThreeHasDashDashOnBothEnds One --Three Nine Ten-- Important requirements for all questions:•All data members must be declared as…arrow_forwardDefine a function named check_game_finished (encrypted_list) which takes a list of characters as a parameter. The function returns True if the game is over, and False otherwise. The game is over when there is no longer any "*" characters in the parameter list. For example: Test Result False True data = ['h', '*', ¹*¹, ¹*¹, ¹*'] print(check_game_finished (data)) data = ['h', 'e', '1', '1', 'o'] print(check_game_finished(data)) data = ['s', ¹*¹ 'd'] False print(check_game_finished (data))arrow_forward
- Define a function named display_word (encrypted_list) which takes a list of characters as a parameter. The function prints the parameter list as shown in the examples below. Note: you can assume that the parameter list is not empty. For example: Test Result **¹, ¹*¹'] GUESS THE WORD: h**** data = ['h', '*', '*', display_word (data) ''*', '*', '*'] GUESS THE WORD: s****** data = ['s', '*', display_word (data)arrow_forwardvoid change_current_directory(char *directory) {} This is to be done in Carrow_forwardDefine a function named get_encrypted_list (word) which takes a word as a parameter. The function returns a list of characters. The first element is the first letter from the parameter word and the rest is as a sequence of '*', each '*' representing a letter in the parameter word. Note: you can assume that the parameter word is not empty. For example: Test Result ['h', '*', **1 guess = get_encrypted_list('hello') print(guess) print (type (guess)) guess = get_encrypted_list('succeed') ['s', '*', print (guess) **¹, ¹*¹] **']arrow_forward
- please code in python Write a function called weighted_avg that takes a list of grades and a corresponding list of weights and returns the weighted average of the grades rounded to 1 decimal place. Your function should raise an exception with the message exactly as shown: a weight is less than 0 or greater than 100 (message: "A weight is less than 0 or greater than 100") the weights do not add to 100 (message: "Weights do not add to 100") the number of weights and grades are not equal (message: "The number of weight and grades are not equal") a grade is below 0 (grades above 100 would be considered extra credit and are acceptable) (message: "A grade is below 0") Do not print the exception just 'raise' it. Run your function on grades1 with weights1 and grades2 with weights2 and grades3 with weights3 and grades4 with weights4, defined below. Catch the errors generated in each case as an exception with the useful message for the user as defined above. Hint: The first 3 test cases should…arrow_forwardDefine a function named get_encrypted_list (word) which takes a word as a parameter. The function returns a list of characters. The first element is the first letter from the parameter word and the rest is as a sequence of '*', each '*' representing a letter in the parameter word. Note: you can assume that the parameter word is not empty. For example: Test Result ['h', ¹*¹ **', '*'] *** guess = get_encrypted_list('hello') print (guess) print (type (guess)) guess = get_encrypted_list('succeed') ['s', '*', print (guess) **']arrow_forwardI am trying to run a Bison code where I have implemented a parser. But after running the code in Git Bash, it is generating some errors. Please help me fix the errors. These are the errors I am getting: 20141009.y:272:56: error: invalid operands of types 'const char [3]' and 'const char [2]' to binary 'operator+' 272 | $$ = new symbol_info("if" + " " + "(" + $3->getname() + ")" + $5->getname(), "stmnt"); | ~~~~ ^ ~~~ | | | | | const char [2] | const char [3]20141009.y:281:56: error: invalid operands of types 'const char [3]' and 'const char [2]' to binary 'operator+' 281 | $$ = new symbol_info("if" + " " + "(" + $3->getname() + ")" + " " + $5->getname() + "\n" + "else" + "\n" +…arrow_forward
- Write a Python function, namely PasswordVerfication(pwdList), which takes a list of passwords. The function verifies the validity of passwords and returns lists of verified passwords and bad passwords. Password must contain characters in accordance with the following criteria: • at least 2 lowercase letters at least 2 uppercase letters at least 1 digit at least 1 letter from “!@#$%" • password's length must be at least 8 characters #Sample Run 1 Enter password list: abc123;±MB1977 # ; ABCde123$; america123AB! ================== ======== Entered passwords include: abc123 tMb1977# ABCde123$ america123AB! ============ ====-===== Verified passwords include: 1. ABCde123$ 2. america123AB! ====== =========== ========= Bad passwords include: 1. abc123 2. tMb1977# #Sample Run 2 Enter password list: 9ddADBKKVks;test123ABC@;CKMO347989!;abtest123AB ===== === Entered passwords include: 9ddADBKKVks test123ABC@ CKMO347989! abtest123AB ==== ==== ===== == Verified passwords include: 1. test123ABC@ 2.…arrow_forwardTeacher ask different version of this code please provide that '''Problem A DNA: CG PairsPurpose:This function will take as an argument a string containing a dna strand Parameter(s):dnaReturn Value: fraction of dinucleotides ''' def cg_pairs(dna): dna_simple = 'AGCTTTCATTCTGAC' dna= dna.lower() for i in range (0,len(dna)): if(dna[i]=='a'or dna[i]=='c'or dna[i]=='g' or dna[i]=='t' ): continue else: print("Error in DNA strand ") return 0.0 count = 0 for i in range(0,len(dna)-1): var = dna[i:i + 2] if(var=="cg"): count+=1 else: continue return (float(count/(len(dna)-1)arrow_forwardHello, How can I store a whole book in a file in c language? I had some issues because the string is too long. here is the question: For this assignment I have uploaded a large text file that contains the entire book “Robinson Crusoe” byWilliam Defoe as file defoe-robinson-103.txt Consider the code shown below. It uses the fgets function.fgets is used to read (“get”) strings (“s”) from a file (“f”), hence the name “fgets”. It takes the following arguments:1. A pointer to an array large enough to store the string. In our case that is the char array calledbuffer of size MAX.2. The size of the array, in our case the symbolic constant MAX, set equal to 4000 in line 4.3. The file pointer of the file to read from, in our case bkPtr. Each call to fgets returns a string until the newline (“\n”) character or EOF is encountered. The codereads strings from the file defoe-robinson-103.txt in the while loop and prints them to screen.Implement this program and run it.arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education