CBSE computer and communication technology

Sponsor Area

Question
CBSEENCO12011626

Out of the following, find those identifiers, which can not be used for naming Variable or Functions in a Python program:

_Cost, Price*Qty, float, Switch,
Address One, Delete, Number12, do

Solution

Price*Qty, float, Address One, do

These above identifiers cannot be used for naming Variable or Functions in a python program.

Sponsor Area

Question
CBSEENCO12011627

Name the Python Library modules which need to be imported to invoke the following functions
(i) load()
(ii) pow()

Solution

The Python Library modules which need to be imported to invoke the given functions are,

(i) pickle

(ii) math

Question
CBSEENCO12011628

Rewrite the following code in python after removing all syntax error(s). Underline each correction done in the code.

for Name in [Amar, Shveta, Parag]
     IF Name[0]='S':
          print(Name)

Solution

for Name in [ 'Amar','Shveta','Parag']:
	if Name[0] == 'S':
		print(Name)

Question
CBSEENCO12011629

Find and write the output of the following python code:

Numbers=[9,18,27,36]
for Num in Numbers:
	for N in range(1, Num%8):
		print(N,'#',end= '' )
	print()

Solution

Output: 

1#
1#2#
1#2#3#

Question
CBSEENCO12011630

Find and write the output of the following python code:
class Notes:

	def __init__(self,N=100,Nt='CBSE'): #constructor
		self.Nno=N
		self.NName=Nt

	def Allocate(self, N,Nt):
		self.Nno= self.Nno + N
		self.NName= Nt + self.NName

	def Show(self):
		print(self.Nno,'#',self.NName)

s=Notes()
t=Notes(200)
u=Notes(300,'Made Easy')
s.Show()
t.Show()
u.Show()
s.Allocate(4, 'Made ')
t.Allocate(10,'Easy ')
u.Allocate(25,'Made Easy')
s.Show()
t.Show()
u.Show()

Solution

Output:

100 # CBSE
200 # CBSE
300 # Made Easy
104 # Made CBSE
210 # Easy CBSE
325 # Made EasyMade Easy