Python Intro
Variables & Types
Type Conversion
If Statements
Loops
100

Python was created by:

a) Guido van Rossum

b) Bill Gates

c) Mark Zuckerberg

d) Linus Torvalds

a) Guido van Rossum

100

What is a variable in Python?

a) A fixed value that cannot be changed

b) A container for storing data

c) A mathematical operation

d) A keyword used for loops

b) A container for storing data

100

What is the result of the expression "int(3.7)"?

a) 3.7

b) 3

c) "3.7"

d) TypeError

b) 3

100

What is the purpose of the "in" operator in Python if statements?

a) It is used to check if a variable is defined.

b) It is used to check if a value exists in a sequence or container.

c) It is used to compare two values for equality.

d) It is used to concatenate two conditions.

b) It is used to check if a value exists in a sequence or container.

100

Which statement is used to iterate over a sequence of elements in a for loop?

a) if

b) else

c) in

d) or

c) in

200

Which of the following is not a common use case of Python?

a) Web development

b) Data analysis

c) Game development

d) Robotics

c) Game Development
200

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

a) myVar

b) 123Var

c) _var

d) var_123

b) 123Var

200

What is the output of the following code snippet?

x = 10

y = str(x)

print("The value of x is " + y)

a) The value of x is 10

b) The value of x is "10"

c) The value of x is y

d) TypeError

b) "10"

200

What is the purpose of the "elif" statement in an if-elif-else statement?

a) It is used to create nested if statements.

b) It is used to handle multiple conditions within the if statement.

c) It is used to specify an alternative action when the if condition is not met.

d) It is used to perform additional actions after the if statement.

b) It is used to handle multiple conditions within the if statement.

200

What is the potential risk of using a while loop?

a) It may result in an infinite loop if the condition is not properly updated.

b) It is slower and less efficient than a for loop.

c) It can only be used with numeric values.

d) It requires a counter variable to keep track of iterations.

 a) It may result in an infinite loop if the condition is not properly updated.


300

Python 2 and Python 3 are both actively maintained and developed.

a) True

b) False

a) True

300

Which statement correctly assigns a value of 10 to the variable "x"?

a) x = 10

b) 10 = x

c) x == 10

d) x := 10

a) x = 10

300

What is the result of the expression "bool('False')"?

a) True

b) False

c) TypeError

d) "False"

a) True

300

What is the difference between the "is" and "==" operators in Python?

a) "is" compares the values of two variables, while "==" compares their references.

b) "is" compares the references of two variables, while "==" compares their values.

c) There is no difference; "is" and "==" are interchangeable

d) "is" and "==" cannot be used with if statements.

b) "is" compares the references of two variables, while "==" compares their values.

300

What is the syntax for a for loop in Python?

a) for i in range(start, end, step):

b) for i in range(end):

c) for i in iterable:

d) All of the above are valid syntax for a for loop.

d) All of the above are valid syntax for a for loop

400

Python is primarily used for which of the following?

a) Web browser scripting

b) Building mobile apps

c) Data manipulation and analysis

d) None of the above

c) Data manipulation and analysis

400

What is the result of the expression "10 // 3"?

a) 3.33

b) 3

c) 3.0

d) 3.3333

b) 3

400

What is the result of the expression "bool(0)"?

a) True

b) False

c) 0

d) TypeError

b) False

400

What is the output of the following code snippet?

x = 5

y = 3

if x > y:

   print("x is greater than y")

elif x < y:

    print("x is less than y")

else:

   print("x is equal to y")

a) x is greater than y

b) x is less than y

c) x is equal to y

d) 5

a) x is greater than y

400

What is the output of the following code snippet?

i = 0

while i < 5:

    i += 1

    if i == 3:

       continue

    print(i)

a) 1, 2, 3, 4, 5

b) 1, 2, 4, 5

c) 1, 2, 4

d) 1, 2

b) 1, 2, 4, 5

500

What is the main reason for migrating from Python 2 to Python 3?

a) Improved performance

b) Enhanced syntax

c) Better support for Unicode

d) All of the above

d) All of the above

500

What is the output of the following code snippet?

x = 5

y = "10"

print(x + y)

a) 15

b) "510"

c) TypeError

d) "5 + 10"

d) "5 + 10"

500

What is the output of the following code snippet?

x = "3.14"

y = float(x)

print(y + 1)

a) 4.14

b) "3.141"

c) TypeError

d) "3.14 + 1"

a) 4.14

500

What is the purpose of the "not in" operator in Python if statements?

a) It is used to check if a value does not exist in a sequence or container.

b) It is used to check if a variable is not defined.

c) It is used to compare two values for inequality.

d) It is used to concatenate two conditions.

 a) It is used to check if a value does not exist in a sequence or container.

500

When would you typically use a while loop instead of a for loop?

a) When the number of iterations is known in advance.

b) When you need to execute a block of code a fixed number of times.

c) When you need to repeatedly execute a block of code based on a condition.

d) When you want to iterate over a sequence or collection.

c) When you need to repeatedly execute a block of code based on a condition.

M
e
n
u