Free PCAP Basic Questions and Answers
How do you create a list in Python?
Lists in Python are created using square brackets, with elements separated by commas.
What is the correct file extension for Python files?
Python files have the extension .py
Which of the following is a correct syntax to output "Hello World" in Python?
In Python, the print function is used to output text to the console.
Which of the following is a valid variable name in Python?
Variable names in Python must start with a letter or underscore and cannot contain spaces or hyphens.
What does the following code print?
The range(3) function generates numbers from 0 to 2, and the for loop prints each number in this range.
How do you start a comment in Python?
In Python, comments are started with the # symbol.
What will be the output of the following code?
The + operator concatenates strings in Python, and adding " " between x and y results in "Hello World".
Which of the following is used to define a function in Python?
The def keyword is used to define a function in Python.
What is the output of the following code?
The ** operator in Python is used for exponentiation. 2 ** 3 equals 8.
Which data type is used to store text in Python?
The str data type is used to store text in Python
Which of the following statements will correctly check if a variable a is equal to 10?
The == operator is used to check equality, and the correct syntax for an if statement in Python ends with a colon.