Thursday, July 4, 2024

PGDDS Sem 2 - Python Programming

 

POST GRADUATE DIPLOMA IN DATA SCIENCE

Please verify the answers as they might be incorrect also.


1. MCQ: What is Python primarily known for?

A. Web Development

B. Data Science

C. Easy syntax

D. Mobile Development

Answer: C. Easy syntax



2. Fill in the Blanks: Python was created by _______.

Answer: Guido van Rossum


3. Match the Following:


a. Python 2 - iii. Released in 2000

b. Python 3 - i. Released in 2008

c. PEP 8 - ii. Style Guide

Answers:

a - iii

b - i

c - ii

Variables, Expressions, and Statements

4. MCQ: What is the correct syntax to assign a value to a variable in Python?


A. x == 10

B. x = 10

C. 10 = x

D. 10 == x

Answer: B. x = 10

5. Fill in the Blanks: The expression 5 + 3 * 2 evaluates to ______.


Answer: 11

6. Match the Following:


a. Variable - iii. Stores data

b. Expression - i. Combination of values

c. Statement - ii. Performs an action

Answers:

a - iii

b - i

c - ii

Control Structures, Data Structures - Arrays and Linked Lists, Queues

7. MCQ: Which of the following is a control structure in Python?


A. if-else

B. Array

C. Linked List

D. Queue

Answer: A. if-else

8. Fill in the Blanks: The data structure that allows adding elements at one end and removing from the other is called ______.


Answer: Queue

9. Match the Following:


a. Array - i. Fixed size

b. Linked List - ii. Dynamic size

c. Queue - iii. FIFO

Answers:

a - i

b - ii

c - iii

Functions

10. MCQ: How do you define a function in Python?


A. def function_name():

B. function function_name():

C. create function_name():

D. define function_name():

Answer: A. def function_name():

11. Fill in the Blanks: Functions help in reducing ________ in code.


Answer: Redundancy

12. Match the Following:


a. def - i. Keyword to define a function

b. return - ii. Sends back a value

c. parameter - iii. Input to a function

Answers:

a - i

b - ii

c - iii

Conditionals, Recursion, and Iteration

13. MCQ: What is a base case in recursion?


A. A loop condition

B. A recursive call

C. A condition where recursion stops

D. An iterative process

Answer: C. A condition where recursion stops

14. Fill in the Blanks: The keyword used to create a loop that repeats as long as a condition is true is ______.


Answer: while

15. Match the Following:


a. if - iii. Conditional statement

b. for - i. Iterative loop

c. recursion - ii. Function calling itself

Answers:

a - iii

b - i

c - ii

Strings

16. MCQ: Which of the following is a valid way to concatenate strings in Python?


A. str1 - str2

B. str1 + str2

C. str1 * str2

D. str1 / str2

Answer: B. str1 + str2

17. Fill in the Blanks: The method to convert a string to lowercase is ______.


Answer: lower()

18. Match the Following:


a. upper() - ii. Converts to uppercase

b. find() - iii. Searches for a substring

c. replace() - i. Replaces a substring

Answers:

a - ii

b - iii

c - i

Lists and Tuples

19. MCQ: Which of the following is a mutable data type in Python?


A. List

B. Tuple

C. String

D. Integer

Answer: A. List

20. Fill in the Blanks: Tuples are immutable, whereas lists are ______.


Answer: mutable

21. Match the Following:


a. list.append() - ii. Adds an element

b. tuple.count() - iii. Counts occurrences

c. list.sort() - i. Sorts the list

Answers:

a - ii

b - iii

c - i

Dictionaries

22. MCQ: How do you access the value associated with a key in a dictionary?


A. dict.key

B. dict[key]

C. dict.key()

D. dict[key()]

Answer: B. dict[key]

23. Fill in the Blanks: The method to add a key-value pair to a dictionary is ______.


Answer: update()

24. Match the Following:


a. keys() - ii. Returns keys

b. values() - iii. Returns values

c. items() - i. Returns key-value pairs

Answers:

a - ii

b - iii

c - i

Object-Oriented Programming

25. MCQ: What is the term for a blueprint of an object in OOP?


A. Function

B. Class

C. Module

D. Package

Answer: B. Class

26. Fill in the Blanks: The process of creating an instance of a class is called ______.


Answer: instantiation

27. Match the Following:


a. init - iii. Constructor

b. self - i. Refers to the instance

c. inheritance - ii. Deriving from a class

Answers:

a - iii

b - i

c - ii

Files and Error Handling

28. MCQ: Which keyword is used to handle exceptions in Python?


A. catch

B. handle

C. except

D. throw

Answer: C. except

29. Fill in the Blanks: The method used to read the entire contents of a file is ______.


Answer: read()

30. Match the Following:


a. open() - i. Opens a file

b. close() - ii. Closes a file

c. IOError - iii. File handling error

Answers:

a - i

b - ii

c - iii

Testing, Debugging, and Profiling

31. MCQ: What is the purpose of unit testing?


A. To find syntax errors

B. To test individual units of code

C. To optimize performance

D. To debug the entire program

Answer: B. To test individual units of code

32. Fill in the Blanks: The Python module used for debugging is ______.


Answer: pdb

33. Match the Following:


a. unittest - i. Testing framework

b. assert - iii. Statement for testing

c. cProfile - ii. Profiling tool

Answers:

a - i

b - iii

c - ii

Handling Data with Python

34. MCQ: Which library is commonly used for data manipulation in Python?


A. NumPy

B. Pandas

C. SciPy

D. Matplotlib

Answer: B. Pandas

35. Fill in the Blanks: The data structure used in Pandas for 1-dimensional data is called ______.


Answer: Series

36. Match the Following:


a. read_csv() - ii. Reads CSV files

b. DataFrame - iii. 2D data structure

c. merge() - i. Combines dataframes

Answers:

a - ii

b - iii

c - i

Python Graphical User Interface Development

37. MCQ: Which library is commonly used for creating GUIs in Python?


A. NumPy

B. Matplotlib

C. Tkinter

D. SciPy

Answer: C. Tkinter

38. Fill in the Blanks: The method to start the main loop in a Tkinter application is ______.


Answer: mainloop()

39. Match the Following:


a. Button - i. Creates a button

b. Label - ii. Displays text

c. Entry - iii. Single-line text field

Answers:

a - i

b - ii

c - iii

No comments:

Search Assignments and Papers Here...


Custom Search

An Appeal to SCDL students

Dear SCDL Student,

We at http://scdlpapers.blogspot.com tries to collect and spread the knowledge in terms of the solved papers and assignments which we are getting through SCDL Alumni.
Now we request you to help other students through mutual sharing. Please send your assignment questions/papers to "mindgrill@gmail.com" . We will publish them on this blog along with your name.
Your help can be boon for many students to clear their exams.

Best of Luck and waiting for your contributions.

Team @ MindGrill