Python Important Questions IA2
Python Important Questions IA2
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.