important Question CS
important Question CS
Answer:
A dictionary in Python is an unordered, mutable collection of key-value pairs.
Each key in a dictionary must be unique, and it is used to access its associated
value.
Difference:
Answer:
An empty dictionary can be created using curly braces {} or the dict() function.
Example:-
empty_dict1 = {}
empty_dict2 = dict()
Answer:
Keys in a dictionary are unique identifiers used to store and retrieve values. They
must be immutable types like strings, numbers, or tuples. Keys ensure quick
lookups and data organization.
Answer:
You can access a value by specifying its key inside square brackets [ ] or using
the get() method.
Example:
my_dict = {"name": "John", "age": 25}
# Using square brackets
print(my_dict["name"]) # Output: John
Answer:
# Using del
del my_dict["name"]
# Using pop
age = my_dict.pop("age")
# Using clear
my_dict.clear()
Answer:
A Python module is a file containing Python code, such as functions, classes, or
variables, which can be reused in other programs. Modules help organize code and
promote reusability.
Example:
import math
num = 25
sqrt_value = math.sqrt(num)
factorial_value = math.factorial(5)
# Print results
Output
Factorial of 5: 120
Answer:
A digital footprint refers to the trail of data left by a person's online activities, such
as browsing history, social media posts, and online purchases.
Importance:
Answer:
Plagiarism is the act of using someone else's work or ideas without proper
acknowledgment, leading to ethical and legal issues.
Avoiding Plagiarism:
Answer:
Advantages:
Disadvantages: