PCPP 32 10x PCPP Certified Professional Python Programmer 1 · Free Practice Question Medium
Question 21
An INI file is a configuration file for computer software that consists of a text-based content with a structure and syntax comprising key-value pairs for properties, and sections that organize the properties. Which of the following parts of INI file are correctly defined? (Select two)
-
A
- [redis]
- port -> 6379
- db -> 0
-
B
- [settings]
- timeout == 30
- retries == 5
-
C
- [mariadb]
- name :-> hello
- user :-> user
- password :-> password
-
D
- [DEFAULT]
- host = localhost
-
E
- [mariadb]
- name = hello
- user = user
- password = password
Reveal correct answers
Correct answers: D, E
A.
The -> symbol is not a valid delimiter for key-value pairs in INI files. The correct delimiter is =.
B.
This option incorrectly uses == instead of = for key-value pairs. INI files use = as the delimiter between keys and values, so == is not valid syntax for key-value pairs.
C.
The :-> symbol is not used for key-value pairs in INI files. The correct format uses = as the delimiter.
D.
This option defines a section [DEFAULT] with a key-value pair host = localhost. This is consistent with the INI file format, where = is used to assign values to keys.
Example of INI file:
- [DEFAULT]
- host = localhost # This is a comment.
- [mariadb]
- name = hello
- user = user
- password = password
- [redis]
- port = 6379
- db = 0
E.
This option correctly defines a section [mariadb] with key-value pairs using = as the delimiter. This is valid syntax for INI files.
Discussion
Think the marked answer is wrong, or have a better explanation? Share it below — comments appear after review.
