
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
Question
Write a Python program to match a string that contains only upper and lowercase letters, numbers, and underscores.
import re
def text_match(text):
patterns = '^[a-zA-Z0-9_]*$'
#TO DO -- Complete the Code
print("text#1: " + text_match("The quick brown fox jumps over the lazy dog."))
print("text#2: " + text_match("Python_Exercises_1"))
Expected output:
text1: No match found!
text2: Found a match!
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution
Trending nowThis is a popular solution!
Step by stepSolved in 2 steps with 1 images

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
- %matplotlib inlineimport numpy as npfrom matplotlib import pyplot as pltfrom math import sin, cos, exp, pi, sqrtimport math def sawtooth(x): return x%2 #only works in python. other languages will scream. x = np.linspace(0,5,100)y = [sawtooth(xx) for xx in x]plt.plot(x,y,label='sawtooth')plt.grid() def magic(x): s = 0 s += 1 s += -2/pi*sin(pi*x) - 2/2./pi*sin(2*pi*x) - 2/3./pi*sin(3*pi*x) return smagical_y = [magic(xx) for xx in x]plt.plot(x, magical_y,'r-',label='magic')plt.legend(loc='upper left') 5.1def step(x): return 0.0 if x%3>(3./2) else 1.0x = np.linspace(0,5,1000)y = [step(xx) for xx in x]plt.plot(x,y,label='step')plt.grid()plt.ylim(-0.1,1.1)5.3def circ(x): r = 1 xx = (x%(2*r)) return sqrt(r**2-(xx-r)**2)x = np.linspace(0,5,1000)y = [circ(xx) for xx in x]plt.plot(x,y,label='step')plt.grid()plt.ylim(-0.1,1.1)arrow_forwardHelp and show me fix an error?arrow_forward%matplotlib inline import math import numpy as np from matplotlib import pyplot as plt def f(x): return math.sqrt(-x/(x+1)) def g(x): return math.tan(math.sqrt(2*(x + 1))) xs = np.linspace(-0.999,-0.1, 100) fx = [f(x) for x in xs] gx = [g(x) for x in xs] plt.plot(xs,fx) plt.plot(xs,gx) plt.gridarrow_forward
- Write a Python program to count the number of times a specific element appears in a deque object.Sample Output:Number of 2 in the sequence5Number of 4 in the sequence4.arrow_forwardclass Output{public static void main(String args[]){byte a[] = { 65, 66, 67, 68, 69, 70 };byte b[] = { 71, 72, 73, 74, 75, 76 };System.arraycopy(a , 0, b, 0, a.length);System.out.print(new String(a) + " " + new String(b));}} The output of the above Java code is ?arrow_forwardSuppose dna is a string variable that contains only 'a','c','g' or 't' characters. What Python code below can we use to find the frequency (max_freq) of the most frequent character in string dna? A dna_counts= {'t':dna.count('t'),'c':dna.count('c'),'g':dna.count('g'),'a':dna.count('a')} max_freq=sorted(dna_counts.keys())[0] B dna_counts= {'t':dna.count('t'),'c':dna.count('c'),'g':dna.count('g'),'a':dna.count('a')} max_freq=sorted(dna_counts.values())[-1] C dna_counts= {'t':dna.count('t'),'c':dna.count('c'),'g':dna.count('g'),'a':dna.count('a')} max_freq=sorted(dna_counts.keys())[-1]arrow_forward
- Revorse the vewels def reverse_vowels(text): Given a text string, create and return a new string constructed by finding all its vowels (for simplicity, in this problem vowels are the letters found in the string 'aeiouAEIOU') and reversing their order, while keeping all other characters exactly as they were in their original positions. However, to make the result look prettier, the capitalization of each moved vowel must be the same as that of the vowel that was originally in the target position. For example, reversing the vowels of 'Ilkka' should produce 'Alkki' instead of 'alkkI'. Applying this operation to random English sentences seems to occasionally give them a curious pseudo-Mediterranean vibe.Along with many possible other ways to perform this square dance, one straightforward way to reverse the vowels starts with collecting all vowels of text into a separate list, and initializing the result to an empty string. After that, iterate through all positions of the original text.…arrow_forwardThis is the code: String name = Doe, John"; int index =name.indexOf(" , "); String firstName= name.substring(index + 2, name.length()); System.out.println(firstName);arrow_forwardIn java, without Arrays and using only String methods ( don't use String builder) // Question 17: In MS-DOS, a file name consists of up // to 8 characters (excluding '.', ':', backslask, '?', // and '*'), followed by an optional dot ('.' character) // and extension. The extension may contain zero to three // characters. For example, 1STFILE.TXT is a valid filename. // Filenames are case-blind. // // Write and test a method that takes // in a String, validates it as a valid MS-DOS file // name, appends the extensions ".TXT" if no extension // is given (that is, no '.' appears in FILENAME), converts // the name to uppercase, and returns the resulting string // to the calling method // If fileName ends with a dot, remove that dot and do not // append the default extension. If the name is invalid, // validFileName should return null. public String validFileName(String n) { }arrow_forward
arrow_back_ios
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