Free PCAP Basic Questions and Answers
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 data type is used to store text in Python?
The str data type is used to store text in Python
How do you start a comment in Python?
In Python, comments are started with the # symbol.
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 is the output of the following code?
The ** operator in Python is used for exponentiation. 2 ** 3 equals 8.
Which of the following is used to define a function in Python?
The def keyword is used to define a function in Python.
Advertisement
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 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.
How do you create a list in Python?
Lists in Python are created using square brackets, with elements separated by commas.
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.