1. Which of the following is the correct syntax for defining a function in Python?
A) function name() {}
B) def name():
C) func name[] {}
D) define name() {}
Answer: B) def name()
2. In which programming language is System.out.println() used?
A) Python
B) Java
C) C++
D) JavaScript
Answer: B) Java
3. What is the output of print(“Hello” + ” World”) in Python?
A) Hello World
B) HelloWorld
C) Hello + World
D) Hello World
Answer: B) HelloWorld
4. Which of the following is not a valid data type in Python?
A) int
B) string
C) boolean
D) char
Answer: D) char
5. What does the following Python code do? list(range(5))
A) Creates a list of integers from 1 to 5
B) Creates a list of integers from 0 to 4
C) Creates a list of integers from 1 to 4
D) Creates a list of integers from 0 to 5
Answer: B) Creates a list of integers from 0 to 4
6. What is the output of 23 in Python?**
A) 6
B) 8
C) 9
D) 16
Answer: B) 8
7. How do you declare a variable in JavaScript?
A) var name = value;
B) variable name = value;
C) let name := value;
D) define name = value;
Answer: A) var name = value;
8. What is the correct way to comment a single line in C++?
A) # comment
B) /* comment */
C) — comment
D) // comment
Answer: D) // comment
9. In which language is for loop syntax for (int i = 0; i < 10; i++) used?
A) JavaScript
B) Python
C) C++
D) Java
Answer: C) C++
10. What will be the output of print(0.1 + 0.2 == 0.3) in Python?
A) True
B) False
C) None
D) Error
Answer: B) False