0% found this document useful (0 votes)
6 views2 pages

Asg2 Python Bca614

The document is an assignment for the BCA course at Teerthanker Mahaveer University, focusing on Python programming, specifically modules and dictionaries. It includes conceptual and coding questions, as well as output tracing questions related to Python code. The assignment is due on April 15, 2025, and is to be submitted to Mr. Pulkit Raj Saxena.

Uploaded by

murshad.045100
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)
6 views2 pages

Asg2 Python Bca614

The document is an assignment for the BCA course at Teerthanker Mahaveer University, focusing on Python programming, specifically modules and dictionaries. It includes conceptual and coding questions, as well as output tracing questions related to Python code. The assignment is due on April 15, 2025, and is to be submitted to Mr. Pulkit Raj Saxena.

Uploaded by

murshad.045100
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/ 2

Teerthanker Mahaveer University

College of Computing Sciences and Information Technologies

Assignment-2
Course Code: BCA001
Year: III Semester: VI Academic Session: 2024-25
Course Code: BCA614 Course Name: Python Programming

Date:3 APRIL 2025


Submitted To: Mr. Pulkit Raj Saxena Sign:

Submitted By-

Student Name: ______________________________________ SEC: ______

Enrollment Number: __________________________________

Submission Date: 15 APRIL 2025 Submitted On: _ _ _ _ _ _ _ _ _


TOPIC: Modules and Dictionaries
Section A: Conceptual & Coding Questions
1. What is a module in Python? How is it useful?
2. How do you create and import a custom module in Python? Provide an example.
3. Explain the difference between a built-in module and a user-defined module.
4. Write a Python program that creates a module named math_operations.py
containing functions for addition, subtraction, multiplication, and division. Import
this module in another script and use its functions.
5. What is the difference between import module_name and from module_name
import function_name? Give an example.
6. Write a Python program to import the random module and generate a random
number between 1 and 100.
7. What is the purpose of the __name__ == "__main__" construct in a Python module?
8. Define a dictionary in Python and explain how it differs from a list.
9. Write a Python script to create a dictionary containing the names of five students as
keys and their marks as values. Write a function to find the highest marks from the
dictionary.
10.How can you iterate through keys and values in a dictionary? Provide an example.

Section B: Output Tracing Questions


Predict the output of the following Python code:
1. def test(): 6. d = {"a": 10, "b": 20, "c": 30}
return {1: "one", 2: "two", 3: "three"} print(d.get("b", 0) + d.get("d", 5))
d = test()
print(d[2])
2. def update_dict(d): 7. d = {"apple": 5, "banana": 10, "cherry": 15}
d["x"] = 50 d["banana"] = 20
print(d)
data = {"a": 10, "b": 20}
update_dict(data)
print(data)
3. def modify_dict(d): 8. d = {1: "a", 2: "b", 3: "c"}
d.pop("key1", None) for key in d:
print(key, d[key])
data = {"key1": 100, "key2": 200}
modify_dict(data)
print(data)
4. d = {} 9. d = {"x": 10, "y": 20, "z": 30}
d[1] = "one" for key, value in d.items():
d[2] = "two" print(f"{key}: {value}")
d[1] = "ONE"
print(d)
5. def merge_dicts(d1, d2): 10. d = {"fruit": "apple", "count": 10}
d1.update(d2) d.clear()
print(d)
dict1 = {"a": 1, "b": 2}
dict2 = {"b": 3, "c": 4}
merge_dicts(dict1, dict2)
print(dict1)

You might also like