Python From Beginner to Advanced

0% completed

Previous
Next
Quiz
How do you obtain the current date and time in Python using the datetime module?
A
datetime.current()
B
datetime.now()
C
datetime.datetime.now()
D
datetime.date.today()
What is the output of the following code?
from datetime import datetime
print(datetime.strptime('2023-03-01', '%Y-%m-%d').strftime('%B %d, %Y'))
A
March 01, 2023
B
03-01-2023
C
2023-03-01
D
March 1, 2023
Which function in the Python math module is used to calculate the factorial of a number?
A
math.factor()
B
math.factorial()
C
math.fact()
D
math.calc_factorial()
What will the following Python code output?
import math
print(math.ceil(3.4))
A
3
B
4
C
3.0
D
4.0
What does the following function demonstrate?
def outer_func(x):
    def inner_func(y):
        return x + y
    return inner_func

test = outer_func(10)
print(test(5))
A
A Python decorator
B
An example of a closure
C
Incorrect function nesting
D
A syntax error
What is the primary use of templating engines like Jinja2 in Python?
A
Data analysis and manipulation
B
Web scraping
C
Generating dynamic content from templates
D
Network programming
Which json module function converts a Python dictionary to a JSON formatted string?
A
json.load()
B
json.loads()
C
json.dump()
D
json.dumps()

.....

.....

.....

Like the course? Get enrolled and start learning!
Previous
Next