Programming Basics # MCQs Practice set

Q.1 Which of the following is a programming language?

Microsoft Word
Python
Excel
PowerPoint
Explanation - Python is a high-level programming language, while Word, Excel, and PowerPoint are applications.
Correct answer is: Python

Q.2 What does 'print' do in Python?

Takes input from user
Displays output
Stops the program
Saves a file
Explanation - The 'print()' function is used to display text or values on the screen.
Correct answer is: Displays output

Q.3 Which symbol is used for comments in Python?

#
//
/* */
<!-- -->
Explanation - In Python, the '#' symbol is used to write comments.
Correct answer is: #

Q.4 Which data type is used to store True or False values?

String
Integer
Boolean
Float
Explanation - Boolean data type is used to represent logical values: True or False.
Correct answer is: Boolean

Q.5 Which operator is used for addition in programming?

*
+
-
/
Explanation - The '+' operator is used for adding numbers in most programming languages.
Correct answer is: +

Q.6 What is the extension of a Python file?

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

Q.7 Which function is used to take input from a user in Python?

scan()
input()
get()
cin>>
Explanation - The 'input()' function in Python is used to read user input as a string.
Correct answer is: input()

Q.8 What does IDE stand for?

Integrated Development Environment
Internal Data Execution
Input Data Editor
Integrated Debugging Engine
Explanation - An IDE provides tools for writing, debugging, and running programs.
Correct answer is: Integrated Development Environment

Q.9 Which of the following is NOT a loop structure?

for
while
do-while
print
Explanation - The 'print' statement displays data but is not a looping structure.
Correct answer is: print

Q.10 In C, which header file is required to use 'printf'?

math.h
stdio.h
conio.h
string.h
Explanation - The 'stdio.h' header provides input/output functions like printf and scanf.
Correct answer is: stdio.h

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

define
func
def
function
Explanation - Functions in Python are declared using the 'def' keyword.
Correct answer is: def

Q.12 What will 5 % 2 return in Python?

2
1
2.5
0
Explanation - The '%' operator returns the remainder, so 5 % 2 = 1.
Correct answer is: 1

Q.13 Which of these is an example of a variable name?

123name
name_1
name-1
1name
Explanation - Variable names cannot start with numbers or contain hyphens, but 'name_1' is valid.
Correct answer is: name_1

Q.14 Which of these is NOT a programming language?

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

Q.15 In Python, which data type is 3.14?

Integer
Float
String
Boolean
Explanation - Numbers with decimals in Python are stored as floats.
Correct answer is: Float

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

end
stop
break
exit
Explanation - The 'break' keyword immediately terminates a loop in Python.
Correct answer is: break

Q.17 Which of the following is used to repeat a block of code?

if
loop
while
def
Explanation - The 'while' loop executes code repeatedly while the condition is true.
Correct answer is: while

Q.18 Which symbol is used for multiplication in most programming languages?

×
*
x
#
Explanation - The '*' symbol is used to represent multiplication in programming.
Correct answer is: *

Q.19 Which of these is an example of a conditional statement?

if
for
print
def
Explanation - The 'if' statement is used for decision-making based on conditions.
Correct answer is: if

Q.20 In C, which symbol ends a statement?

.
,
;
:
Explanation - In C, each statement must end with a semicolon (;).
Correct answer is: ;

Q.21 Which function in Python converts a string into an integer?

toInt()
convert()
int()
str()
Explanation - The int() function converts a string to an integer if possible.
Correct answer is: int()

Q.22 Which of the following is used to store multiple values in a single variable in Python?

list
int
bool
char
Explanation - Lists in Python can hold multiple values in a single variable.
Correct answer is: list

Q.23 Which operator is used for equality check in programming?

=
==
!=
=>
Explanation - The '==' operator checks if two values are equal.
Correct answer is: ==

Q.24 Which language is primarily used for web page structure?

Python
JavaScript
HTML
C++
Explanation - HTML (HyperText Markup Language) defines the structure of web pages.
Correct answer is: HTML

Q.25 Which data type is used for whole numbers in most languages?

Float
Integer
String
Boolean
Explanation - The Integer data type is used to store whole numbers.
Correct answer is: Integer