Free PCAP Basic Questions and Answers

0%

What is the output of the following code?

Correct! Wrong!

The ** operator in Python is used for exponentiation. 2 ** 3 equals 8.

What is the correct file extension for Python files?

Correct! Wrong!

Python files have the extension .py

How do you start a comment in Python?

Correct! Wrong!

In Python, comments are started with the # symbol.

What will be the output of the following code?

Correct! Wrong!

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?

Correct! Wrong!

The def keyword is used to define a function in Python.

Which of the following is a 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 text in Python?

Correct! Wrong!

The str data type is used to store text in Python

What does the following code print?

Correct! Wrong!

The range(3) function generates numbers from 0 to 2, and the for loop prints each number in this range.

Which of the following statements will correctly check if a variable a is equal to 10?

Correct! Wrong!

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?

Correct! Wrong!

Lists in Python are created using square brackets, with elements separated by commas.

Which of the following is a valid variable name in Python?

Correct! Wrong!

Variable names in Python must start with a letter or underscore and cannot contain spaces or hyphens.

Premium Tests $49/mo
FREE June-2024