Sample Question Paper Answers 20.5.23

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

1. a.

Mutable objects can be modified


after they are created. Examples
include lists, dictionaries, and sets.
Immutable objects cannot be modified
after they are created. Examples
include strings, numbers, and tuples.
c. def execmain():

x = int(input("Enter a number:"))

if abs(x) == x:
print("You entered a positive number")
else:
x = -1
print("Number made positive:", x)

execmain(

e. [1, 2, 4, 6, 8, 9, 0, -1, -2, -3]

2. a. Similarity:
Both lists and dictionaries are used to
store data in Python.
Difference:
A list is an ordered collection of
elements while a dictionary is an
unordered collection of key-value pairs.

b. def checkval():

x = int(input("Enter a number:"))

print(x, "is even")

if x % 2 == 0:
print(x, "should be positive")
elif x < 0:
pass
else:
print(x, "is odd")

checkval()

e. i. Mydata is a text file.


ii. File = open("Mydata", "a")

File.write("ABC")
File.close()

You might also like