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

PythonquesAnswers

The document provides an overview of fundamental concepts in Python, including classes, objects, exceptions, constructors, and various data types. It explains the implementation of these concepts with examples, such as defining a class and creating an object, handling exceptions, and using built-in functions. Additionally, it covers file handling, first-class functions, and control flow statements like loops and decision-making structures.

Uploaded by

bahinki
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)
2 views14 pages

PythonquesAnswers

The document provides an overview of fundamental concepts in Python, including classes, objects, exceptions, constructors, and various data types. It explains the implementation of these concepts with examples, such as defining a class and creating an object, handling exceptions, and using built-in functions. Additionally, it covers file handling, first-class functions, and control flow statements like loops and decision-making structures.

Uploaded by

bahinki
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

Python

1. What is class and object? How they are implemented in Python explain with examples?
A class is a blueprint or template used to create objects.
It defines properties (variables) and behaviors (functions/methods) that the objects created from
it will have.
Eg
class Student:
name = "Unknown"
age = 0
An object is a real instance of a class.
It represents a real-world entity created using the class.
Eg:
s1 = Student()
2. Explain different type of operators used in Python with example.
3. What are exceptions in Python? List the common exception in Python.
Exceptions in Python are runtime errors that occur while a program is being executed.
When an exception occurs, the normal flow of the program is interrupted, and Python stops
execution unless the error is handled.
Eg:
a = 10
b=0
print(a / b)
output:
ZeroDivisionError: division by zero

4. What do you mean by constructor in Python?Explain its type.


A constructor in Python is a special method of a class that is automatically executed when an
object is created.
It is mainly used to initialize (assign values to) the data members of a class.
In Python, the constructor method is named __init__()
Eg:
class Student:
def __init__(self):
print("Constructor is called")

5. What is splitting? Explain with example?


Splitting in Python means dividing a string into multiple smaller parts (substrings) based on a
specified separator.
It is done using the split() method.

6. Explain various mode of opening a file in Python.


7. Briefly explain the following statement with syntax
a) Try
b) catch
8. What is sys module? Write down uses of sys module
in Python.

9. What is First class function? Write any four


properties of first class function
10. Define tuple. Explain its four functions?

Four Common Tuple Functions


1. len()
2. max()
3. min()
4. count()
11. Difference between list and tuple.

12. Define set. Explain how it is created in Python?

13. Write a program in Python to determine whether a number is prime or not?


14. Explain input and print function with example in Python.

15. Briefly explain History and Versions of Python?


16. Difference between break and continue statement.

17. Explain the concept of inheritance with example in python.


18. Explain various operations performed on Lists.

19. What are modules. Write a module to add two numbers.

20. What are functions. Explain with example the process


of creating and calling a function.
21. What is the need of indentation in python?

22. Write a program to find the largest of ‘n’ numbers,


using a user defined function largest ().
23. Explain any five-conversion function with example in python.
1. int()
2. float()
3. list()
4. str()
5. tuple()
24. Explain Dictionary and how it is created in Python?

25. Write short notes with example on (CO3)


a) for loop
b) while loop
25. What are various decision making statement. Give
example.
26. note on polymorphism

26.
27. Explain the basic data types available in Python with examples
1. Numeric Types
2. String (str)
3. Boolean (bool)
4. Sequence Types
5. Set

You might also like