wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Quiz 3.1

Total questions: 21

Worksheet time: 13mins

Name
Class
Date
1.

print(math.remainder(9,2))

a)

1

b)

0

c)

1.0

d)

0.0

2.

print(math.factorial(3))

a)

3

b)

6

c)

0

d)

3*2*1

3.

Convert from JSON to Python:

(a)  

4.

Convert from Python to JSON

(a)  

5.

output from json is

a)

str

b)

int

c)

dict

d)

anytype

6.

to handel shape of json use

a)

sparators

b)

indent

c)

loads

d)

dumps

7.

try:

  print(x)

except: 

print("An exception occurred")

a)

Error

b)

An exception occurred

c)

None

d)

Exception

8.

x=5

try:

  print(x)

except: 

print("An exception occurred")

(a)  

9.

try:

  print(x)

except NameError: 

print("Variable x is not defined")

except: 

print("Something else went wrong")

(a)  

10.

x = -1

if x > 0:  raise Exception("Sorry, no numbers below zero")


a)

Sorry, no numbers below zero

b)

-1

c)

0

d)

nothing

11.

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)  

12.

What is the regular expression pattern to match a valid email address?

a)

^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$

b)

^\(?\d{3}\)?[-.\s]?\d{3}[-.\s]?\d{4}$

c)

^[a-z\s]+$

d)

all of the them

13.

What is the regular expression pattern to match a valid phone number in the US?

a)

^[a-z\s]+$

b)

^\(?\d{3}\)?[-.\s]?\d{3}[-.\s]?\d{4}$

c)

^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$

d)

all of them

14.

What is the regular expression pattern to match a string that contains at least one digit?

a)

^\(?\d{3}\)?[-.\s]?\d{3}[-.\s]?\d{4}$

b)

^[a-z\s]+$

c)

^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$

d)

\d+

15.

What is the regular expression pattern to match a string that contains only lowercase letters and spaces?

a)

^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$

b)

^[a-z\s]+$

c)

\d+

d)

all is wrong

16.

What is the regular expression pattern to match a string that contains only lowercase letters and spaces?

a)

^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$

b)

^[a-z\s]+$

c)

\d+

d)

all is wrong

17.

What is the regular expression pattern to match a string that starts with "Hello" and ends with "world"?


a)

^Hello.*

b)

world$

c)

^Hello.*world$

d)

^Hello_world$

18.

What is the regular expression pattern to match a valid URL that starts with "https://"?

a)

^https://[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$

b)

^https://[a-zA-Z]*\d{3}$

c)

^https:///(?<=/)[^/]*(?=/)/$

d)

^https://(?=.*[a-zA-Z])(?=.*\d).+$

19.

txt = "The rain in Spain"

x = re.search(r"\bS\w+", txt)

print(x.....())

output is (12,17)

what is method in space ???

a)

span

b)

group

c)

string

d)

match

20.

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 ???

a)

match

b)

string

c)

group

d)

span

21.

txt = "The rain in Spain"

x = re.search(r"\bS\w+", txt)

output is Spain

what is method in space ???

a)

match

b)

string

c)

group

d)

span