0% found this document useful (0 votes)
2 views1 page

2nd Assignment - 12 Question

The document contains 12 Python exercises focused on class creation and manipulation, including importing modules, defining functions, and managing attributes. Each exercise provides a specific task, such as displaying namespaces, using built-in functions, and modifying class attributes. Solutions are implied to be available for each exercise, guiding users through practical applications of Python programming concepts.

Uploaded by

nk200498
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views1 page

2nd Assignment - 12 Question

The document contains 12 Python exercises focused on class creation and manipulation, including importing modules, defining functions, and managing attributes. Each exercise provides a specific task, such as displaying namespaces, using built-in functions, and modifying class attributes. Solutions are implied to be available for each exercise, guiding users through practical applications of Python programming concepts.

Uploaded by

nk200498
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

Python class, Basic exercises [12 exercises with solution]

1. Write a Python program to import a built-in


array module and display the namespace the said module.
Click me to see the solution
of
2. Write a Python program to create a class and display the namespace of that
class.
Click me to see the solution
3. Write a Python program to create an instance of a specified class and display
the namespace of the said instance.
Click me to see the solution
4. 'builtins' module provides direct access to all 'built-in' identifiers of
Python.
Write a Python program that imports the abs() function using the builtins module,
displays the documentation of the abs() function and finds the absolute value of -
155.

5. Define a Python function student(). Using function attributes display the names
of all arguments.
Click me to see the solution
6. Write a Python function student_data () that will print the ID of a student
(student_id). If the user passes an argument
student_name or student_class the function will print the student name and class.
Click me to see the solution
7. Write a simple Python class named Student and display its type. Also, display
the ____dict___ attribute keys and the value of the ____module___ attribute of the
Student class.
Click me to see the solution
8. Write a Python program to create two empty classes, Student and Marks. Now
create some instances and check whether they are instances of the said classes or
not. Also, check whether the said classes are subclasses of the built-in object
class or not.

9. Write a Python class named Student with two attributes student_name, marks.
Modify the attribute values of the said class and print the original and modified
values of the said. attributes.
Click me to see the solution
10. Write a Python class named Student with two attributes student_id,
student_name. Add a new attribute student_class and display the entire attribute
and the values of the class. Now remove the student_name attribute and display the
entire attribute with values.
Click me to see the solution
11. Write a Python class named Student with two attributes: student_id,
student_name. Add a new attribute: student_class. Create a function to display all
attributes and their values in the Student class.
Click me to see the solution
12. Write a Python class named Student with two instances student1, student2 and
assign values to the instances' attributes. Print all the attributes of the
student1, student2 instances with their values in the given format.

You might also like