Introduction to Programming Concepts # MCQs Practice set

Q.1 Which of the following is a valid variable name in most programming languages?

2value
value_2
value-2
value 2
Explanation - Variable names cannot start with digits, cannot contain spaces, and usually cannot have special characters like '-'. Underscores are valid.
Correct answer is: value_2

Q.2 Which of the following is NOT a programming language?

Python
C++
HTML
Java
Explanation - HTML is a markup language, not a programming language.
Correct answer is: HTML

Q.3 What does ‘print’ do in most programming languages like Python?

Reads input
Displays output
Declares a variable
Terminates a program
Explanation - The 'print' function is used to display information on the screen.
Correct answer is: Displays output

Q.4 In programming, what is a loop used for?

Storing data
Repeating tasks
Stopping execution
Declaring functions
Explanation - Loops allow a block of code to be executed multiple times until a condition is met.
Correct answer is: Repeating tasks

Q.5 Which symbol is commonly used for single-line comments in Python?

//
/*
#
--
Explanation - Python uses '#' for single-line comments.
Correct answer is: #

Q.6 What is the default data type of numbers with decimals in Python?

int
float
double
char
Explanation - Python represents decimal numbers as float by default.
Correct answer is: float

Q.7 What does IDE stand for?

Integrated Development Environment
Internet Data Exchange
Internal Development Engine
Indexed Data Execution
Explanation - An IDE is software that provides tools for coding, debugging, and compiling.
Correct answer is: Integrated Development Environment

Q.8 Which operator is used for exponentiation in Python?

^
**
exp()
^^
Explanation - Python uses '**' for exponentiation (e.g., 2**3 = 8).
Correct answer is: **

Q.9 Which of the following data structures stores key-value pairs?

List
Tuple
Dictionary
Array
Explanation - A dictionary maps keys to values in Python and similar languages.
Correct answer is: Dictionary

Q.10 Which function is used to get user input in Python?

scanf()
cin
read()
input()
Explanation - The 'input()' function allows users to type data into the program.
Correct answer is: input()

Q.11 In programming, what does 'syntax error' mean?

Wrong logic
Wrong grammar of code
Wrong output
Wrong algorithm
Explanation - A syntax error occurs when code does not follow the correct language rules.
Correct answer is: Wrong grammar of code

Q.12 Which keyword is used to define a function in Python?

define
func
def
function
Explanation - Python uses the 'def' keyword to declare functions.
Correct answer is: def

Q.13 Which of the following is an immutable data type in Python?

List
Dictionary
Tuple
Set
Explanation - Tuples cannot be modified after creation, unlike lists or sets.
Correct answer is: Tuple

Q.14 Which language is often referred to as the 'mother of all languages'?

C
Java
Python
Pascal
Explanation - C is considered the foundation for many modern programming languages.
Correct answer is: C

Q.15 What will be the result of 10 % 3 in most languages?

3
1
0
10
Explanation - The modulo operator (%) gives the remainder of division. 10 divided by 3 leaves remainder 1.
Correct answer is: 1

Q.16 Which keyword is used to exit a loop prematurely in Python?

exit
break
stop
return
Explanation - The 'break' statement terminates a loop before its condition fails.
Correct answer is: break

Q.17 Which of the following is a Boolean data type value?

yes
no
True
1.0
Explanation - Booleans in programming are represented as 'True' and 'False'.
Correct answer is: True

Q.18 Which of the following is the correct file extension for Python files?

.java
.py
.c
.exe
Explanation - Python source code files use the '.py' extension.
Correct answer is: .py

Q.19 Which symbol is used for 'AND' logical operation in Python?

&
and
&&
||
Explanation - Python uses the keyword 'and' for logical conjunction, not symbols.
Correct answer is: and

Q.20 Which loop is guaranteed to run at least once?

for
while
do-while
foreach
Explanation - The 'do-while' loop executes first, then checks the condition.
Correct answer is: do-while

Q.21 Which of these is an example of a high-level language?

Assembly
Machine code
C++
Binary
Explanation - High-level languages like C++, Python, and Java are closer to human language.
Correct answer is: C++

Q.22 Which data type is used to store text in Python?

char
int
str
float
Explanation - Python uses the 'str' type for string data.
Correct answer is: str

Q.23 What will be the output of: print(2 == 3)?

2
3
True
False
Explanation - Since 2 is not equal to 3, the result is False.
Correct answer is: False

Q.24 Which of these is used to combine strings in Python?

+
&
*
#
Explanation - The '+' operator concatenates (joins) strings in Python.
Correct answer is: +

Q.25 Which of the following is a type of loop in Python?

for
repeat-until
switch
case
Explanation - Python supports 'for' and 'while' loops, but not 'repeat-until'.
Correct answer is: for