Python Fundamentals

Last Updated :
Discuss
Comments

Question 1

Which of the following is a valid way to comment in Python?

  • A

    // This is a comment

  • B

     # This is a comment

  • C

    <!-- This is a comment -->

  • D

     /* This is a comment */

Question 2

What is the result of the following expression in Python: 5 + 2 * 3

  • A

    21

  • B

    17

  • C

    11

  • D

    1

Question 3

What will be the output of the following code snippet?

Python
a = 5
b = 2
print(a // b)
  • A

    2.5
     

  • B

    2

  • C

    2.0

  • D

    2.00

Question 4

What is the output of the following code?

Python
num1 = "5"
num2 = 3
result = num1 * num2
print(result)
  • A

    15

  • B

    "555"

  • C

    8

  • D

    "333"

Question 5

What is the output of the following code?

Python
value = 2 + 3 * 4 / 2
print(value)
  • A

    4.5

  • B

    10.0

  • C

    8.0

  • D

    12.0

Question 6

What is the output of the following code?

Python
x = "5"
y = "2"
print(x + y)
  • A

    7
     

  • B

    52

  • C

    10

  • D

    3

Question 7

Which of the following statements is true about Python variables?

  • A

    Variables must be declared before they are used.

  • B

    Variables can contain only letters.

  • C

    Python variables are case-sensitive.

  • D

    Python variables cannot be reassigned.

Question 8

Which of the following is the correct way to take user input in Python?

  • A

    input()

  • B

    get_input()

  • C

    user_input()

  • D

    read_input() 

Question 9

Which of the following is the correct type conversion for converting a floating-point number to an integer in Python?

  • A

    int(float_num)

  • B

    integer(float_num)

  • C

    float_to_int(float_num)

  • D

    convert_int(float_num)

Question 10

What is the value of result in the following code?

Python
num = "8"
result = int(num) + 5
print(result)
  • A

    13
     

  • B

    "85"

  • C

    58

  • D

    "13"

There are 15 questions to complete.

Take a part in the ongoing discussion