WorksheetsQuiz 3.1
Total questions: 21
Worksheet time: 13mins
print(math.remainder(9,2))
1
0
1.0
0.0
print(math.factorial(3))
3
6
0
3*2*1
Convert from JSON to Python:
(a)
Convert from Python to JSON
(a)
output from json is
str
int
dict
anytype
to handel shape of json use
sparators
indent
loads
dumps
try:
print(x)
except:
print("An exception occurred")
Error
An exception occurred
None
Exception
x=5
try:
print(x)
except:
print("An exception occurred")
(a)
try:
print(x)
except NameError:
print("Variable x is not defined")
except:
print("Something else went wrong")
(a)
x = -1
if x > 0: raise Exception("Sorry, no numbers below zero")
Sorry, no numbers below zero
-1
0
nothing
try:
f = open("demofile.txt")
try:
f.write("Lorum Ipsum")
except:
print("Something wrong to writing file")
finally:
f.close()
except:
print("Something wrong to opening file")
(a)
What is the regular expression pattern to match a valid email address?
^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$
^\(?\d{3}\)?[-.\s]?\d{3}[-.\s]?\d{4}$
^[a-z\s]+$
all of the them
What is the regular expression pattern to match a valid phone number in the US?
^[a-z\s]+$
^\(?\d{3}\)?[-.\s]?\d{3}[-.\s]?\d{4}$
^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$
all of them
What is the regular expression pattern to match a string that contains at least one digit?
^\(?\d{3}\)?[-.\s]?\d{3}[-.\s]?\d{4}$
^[a-z\s]+$
^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$
\d+
What is the regular expression pattern to match a string that contains only lowercase letters and spaces?
^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$
^[a-z\s]+$
\d+
all is wrong
What is the regular expression pattern to match a string that contains only lowercase letters and spaces?
^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$
^[a-z\s]+$
\d+
all is wrong
What is the regular expression pattern to match a string that starts with "Hello" and ends with "world"?
^Hello.*
world$
^Hello.*world$
^Hello_world$
What is the regular expression pattern to match a valid URL that starts with "https://"?
^https://[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$
^https://[a-zA-Z]*\d{3}$
^https:///(?<=/)[^/]*(?=/)/$
^https://(?=.*[a-zA-Z])(?=.*\d).+$
txt = "The rain in Spain"
x = re.search(r"\bS\w+", txt)
print(x.....())
output is (12,17)
what is method in space ???
span
group
string
match
txt = "The rain in Spain"
x = re.search(r"\bS\w+", txt)
print(x.....)
output is The rain in Spain
what is method in space ???
match
string
group
span
match
string
group
span
