The Joy Of Computing Using Python IIT Ropar
The Joy of Computing Using Python
IMP QUESTIONS PART 2
Question 1:
What is Python?
A) A high-level programming language
B) A type of snake
AM
C) A mathematical equation
D) A type of database management system
Accepted Answer: A) A high-level programming language
Question 2:
AY
Which of the following is the correct way to start a comment in Python?
SW
A) //
B) --
C) /*
D) #
Y
Accepted Answer: D) #
M
Question 3:
@
What is the output of `print(3 * 2 3)` in Python?
A) 48
B) 64
C) 6
D) 192
Accepted Answer: A) 48
Question 4:
Page 1 MY SWAYAM
The Joy Of Computing Using Python IIT Ropar
What does the '!= 'operator signify in Python?
A) Equal to
B) Not equal to
C) Less than
D) Greater than
Accepted Answer: B) Not equal to
Question 5:
AM
In Python, how do you denote a tuple?
A) ( )
B) [ ]
C) { }
D) < > AY
Accepted Answer: A) ( )
SW
Question 6:
What is the purpose of the 'elif' keyword in Python?
A) It is used for exception handling
Y
B) It is used for defining a function
C) It is used for writing else-if conditions
M
D) It is used for file input/output operations
@
Accepted Answer: C) It is used for writing else-if conditions
Question 7:
What does the 'len()' function do in Python?
A) Returns the length of a list, string, or any iterable object
B) Converts a string to lowercase
C) Finds the largest element in a list
D) Returns the square root of a number
Page 2 MY SWAYAM
The Joy Of Computing Using Python IIT Ropar
Accepted Answer: A) Returns the length of a list, string, or any iterable object
Question 8:
Which of the following is a mutable data type in Python?
A) Strings
B) Tuples
C) Lists
D) Sets
AM
Accepted Answer: C) Lists
Question 9:
AY
What is the correct way to open a file in Python for reading?
A) file = open("file.txt", "r")
B) file = open("file.txt", "w")
C) file = open("file.txt", "a")
SW
D) file = open("file.txt", "x")
Accepted Answer: A) file = open("file.txt", "r")
Y
Question 10:
What is the purpose of the 'strip()' function in Python?
M
A) Removes whitespaces from both ends of a string
B) Adds whitespaces to a string
@
C) Converts a string to uppercase
D) Converts a string to lowercase
Accepted Answer: A) Removes whitespaces from both ends of a string
Question 11:
What does the 'range()' function generate in Python?
A) A list of numbers
B) A range object representing a sequence of numbers
Page 3 MY SWAYAM
The Joy Of Computing Using Python IIT Ropar
C) A random number
D) A tuple of numbers
Accepted Answer: B) A range object representing a sequence of numbers
Question 12:
What does the 'break' statement do in a loop in Python?
A) Terminates the loop and transfers control to the next iteration
B) Ends the program
AM
C) Breaks the syntax of the loop
D) Restarts the loop
iteration
Question 13:
AY
Accepted Answer: A) Terminates the loop and transfers control to the next
SW
Which of the following is used to define a function in Python?
A) func()
B) function{}
C) def function_name():
D) function[]
Y
M
Accepted Answer: C) def function_name():
Question 14:
@
What is the output of `print("Hello" + 3 * " World")` in Python?
A) HelloWorld
B) Hello World Hello World Hello World
C) HelloWorldHelloWorldHelloWorld
D) Hello WorldHello WorldHello World
Accepted Answer: B) Hello World Hello World Hello World
Page 4 MY SWAYAM
The Joy Of Computing Using Python IIT Ropar
Question 15:
What is the purpose of the 'split()' function in Python?
A) Combines strings
B) Splits a string into a list of substrings based on a delimiter
C) Removes whitespace characters from a string
D) Converts a string to uppercase
Accepted Answer: B) Splits a string into a list of substrings based on a
delimiter
AM
Question 16:
What is the correct way to check if a key exists in a Python dictionary?
A) `if key in dictionary:`
B) `if key == dictionary:`
AY
C) `if key.contains(dictionary):`
D) `if dictionary.hasKey(key):`
SW
Accepted Answer: A) `if key in dictionary:`
Y
Subscribe for
M
PART 3 AND 4
@
MY SWAYAM
PDF LINK OF THIS QUESTIONS IS AVAILABLE IN THE
DESCRIPTION BOX OF THIS VIDEO.
FOR NEXT PART COMMENT BELOW AND KEEP SUBSCRIBE
TO MY SWAYAM.
THANK YOU. HAPPY LEARNING.
Page 5 MY SWAYAM