This is for my python/sql class 1. Which strings will be matched by the regular
ID: 3733852 • Letter: T
Question
This is for my python/sql class
1. Which strings will be matched by the regular expression "[^A-Z]*" ? (select all that applies)
aaa
Hello
F16
best
2. Which strings will be matched by the regular expression "re-+sign"? (select all that applies)
resign
re-sign
re-*sign
re--sign
3. Complete the code below to create the table users with attributes name (a max of 30 variable length characters), address (a max of 50 variable length characters), and age (an integer) in the database "testdb":
import MySQLdb
con = MySQLdb.connect(db='testdb')
A.aaa
B.Hello
C.F16
D.best
Explanation / Answer
Answer 1: Option A and D
Because regex [^A-Z] means, accept anything except characters mentioned in square brackets. So it will reject all strings having capital letters.
----------------------------------------------------------------------------------------
Answer 2: Option B and D
Because in regex "re-+sign" , + means 1 or more occurences of previous character.
------------------------------------------------------------------------------------
Answer 3:
import MySQLdb
con = MySQLdb.connect(db='testdb')
# prepare cursor object
cursor = con.cursor()
# use execute() method to run SQL query
sql = """CREATE TABLE USERS(
NAME VARCHAR(30),
ADDRESS VARCHAR(50),
AGE INT)"""
cursor.execute(sql)
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.