The Joy of Computing Using Python PART 2
The Joy of Computing Using Python 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
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:
@
Accepted Answer: A) 48
Question 4:
Page 1 MY SWAYAM
The Joy Of Computing Using Python IIT Ropar
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
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")
Question 10:
What is the purpose of the 'strip()' function in Python?
M
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
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
Question 14:
@
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
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
Subscribe for
M
PART 3 AND 4
@
MY SWAYAM
Page 5 MY SWAYAM