0% found this document useful (0 votes)
4 views14 pages

Python Important Questions IA2

The document outlines important Python questions for IA2, covering topics such as the OS path module, string handling methods, file operations, assertions, and class definitions. It includes specific examples and explanations for various functions and methods, as well as programming tasks like creating a Rectangle class and handling exceptions. The content is structured to facilitate understanding of key Python concepts and practices.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views14 pages

Python Important Questions IA2

The document outlines important Python questions for IA2, covering topics such as the OS path module, string handling methods, file operations, assertions, and class definitions. It includes specific examples and explanations for various functions and methods, as well as programming tasks like creating a Rectangle class and handling exceptions. The content is structured to facilitate understanding of key Python concepts and practices.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 14

Python Important Questions for IA2

1. Explain OS path module with an example


2. Explain useful following functions:
• capitalize
• count
• find
• lower
• upper
• replace — with example.

3. Explain the concept of file path. Also discuss absolute and relative path.
4. Explain Python string handling methods with examples:
• split
• endswith
• ljust
• center
• isalpha
• isnumeric
• isspace
• isalnum
• isdecimal
• istitle
• join
• split
• startswith
• rjust
• strip
• rstrip
• lstrip
5. Explain the following file operations in Python with suitable example:
(i) Copying files & folders
(ii) Moving files & folders
(iii) Permanently deleting files & folders
6.Briefly explain assertions & raising an exception.
7. Explain the __str__ and the __init__ method with an example.
8. List out the difference between shutil.copy() and shutil.copytree() method.
9. Write a function named Divexp which takes two parameters a, b and returns a value c (c =
a/b). Write suitable assertions for a ≠ 0 in function Divexp and raise an exception for when
b = 0. Develop a suitable program which reads two values from the console and calls a
function Divexp.

10. Define a class and object. Construct the class called Rectangle and initialize it with height
= 100, width = 200, starting point as (x = 0, y = 0). Write a program to display the center
point coordinates of a rectangle.

You might also like