FREE PCEP Fundamentals of Python Programming Questions and Answers

0%

Which of the following is used to start a comment in Python?

Correct! Wrong!

In Python, comments are started with the # symbol. Everything following # on the same line is considered a comment.

Which of the following statements correctly initializes a dictionary in Python?

Correct! Wrong!

In Python, dictionaries are initialized using curly braces {} with key-value pairs separated by colons. The correct syntax for initializing a dictionary is dict = { 'name': 'Alice', 'age': 25 }.

Which of the following Python expressions correctly calculates the length of a string?

Correct! Wrong!

In Python, the built-in function len() is used to determine the length of a string (or other iterable objects). The correct syntax is len(string).

Which of the following is the correct syntax to output "Hello, World!" in Python?

Correct! Wrong!

In Python, the print() function is used to output text to the console.

Which data type is used to store textual data in Python?

Correct! Wrong!

The str data type is used to store textual data (strings) in Python.

Premium Tests $49/mo
FREE September-2024